aboutsummaryrefslogtreecommitdiff
path: root/src/commands/config/blacklist.ts
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-06-16 14:32:18 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-06-16 14:32:18 -0400
commit0e87bbd3940d89defcb04926587b35c8f4d1947f (patch)
treee50860d4dc25a11d4c3977b583284c4bcad1b077 /src/commands/config/blacklist.ts
parent661e4c9935aeb8760dafc7ced4bbec6cc356a033 (diff)
downloadtanzanite-0e87bbd3940d89defcb04926587b35c8f4d1947f.tar.gz
tanzanite-0e87bbd3940d89defcb04926587b35c8f4d1947f.tar.bz2
tanzanite-0e87bbd3940d89defcb04926587b35c8f4d1947f.zip
remove util classes, move config out of src
Diffstat (limited to 'src/commands/config/blacklist.ts')
-rw-r--r--src/commands/config/blacklist.ts41
1 files changed, 27 insertions, 14 deletions
diff --git a/src/commands/config/blacklist.ts b/src/commands/config/blacklist.ts
index de457c0..80acd0b 100644
--- a/src/commands/config/blacklist.ts
+++ b/src/commands/config/blacklist.ts
@@ -1,4 +1,17 @@
-import { AllowedMentions, BushCommand, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
+import {
+ addOrRemoveFromArray,
+ AllowedMentions,
+ Arg,
+ BushCommand,
+ clientSendAndPermCheck,
+ emojis,
+ format,
+ getGlobal,
+ setGlobal,
+ type ArgType,
+ type CommandMessage,
+ type SlashMessage
+} from '#lib';
import assert from 'assert';
import { ApplicationCommandOptionType, GuildMember, PermissionFlagsBits, User } from 'discord.js';
@@ -23,7 +36,7 @@ export default class BlacklistCommand extends BushCommand {
{
id: 'target',
description: 'The channel/user to blacklist.',
- type: util.arg.union('channel', 'user'),
+ type: Arg.union('channel', 'user'),
readableType: 'channel|user',
prompt: 'What channel or user that you would like to blacklist/unblacklist?',
retry: '{error} Pick a valid user or channel.',
@@ -41,7 +54,7 @@ export default class BlacklistCommand extends BushCommand {
}
],
slash: true,
- clientPermissions: (m) => util.clientSendAndPermCheck(m),
+ clientPermissions: (m) => clientSendAndPermCheck(m),
userPermissions: [PermissionFlagsBits.ManageGuild]
});
}
@@ -59,26 +72,26 @@ export default class BlacklistCommand extends BushCommand {
const global = args.global && message.author.isOwner();
const target =
typeof args.target === 'string'
- ? (await util.arg.cast('textChannel', message, args.target)) ?? (await util.arg.cast('user', message, args.target))
+ ? (await Arg.cast('textChannel', message, args.target)) ?? (await Arg.cast('user', message, args.target))
: args.target;
- if (!target) return await message.util.reply(`${util.emojis.error} Choose a valid channel or user.`);
+ if (!target) return await message.util.reply(`${emojis.error} Choose a valid channel or user.`);
const targetID = target.id;
if (!message.inGuild() && !global)
- return await message.util.reply(`${util.emojis.error} You have to be in a guild to disable commands.`);
+ return await message.util.reply(`${emojis.error} You have to be in a guild to disable commands.`);
if (!global) assert(message.inGuild());
const blacklistedUsers = global
- ? util.getGlobal('blacklistedUsers')
+ ? getGlobal('blacklistedUsers')
: (await message.guild!.getSetting('blacklistedChannels')) ?? [];
const blacklistedChannels = global
- ? util.getGlobal('blacklistedChannels')
+ ? getGlobal('blacklistedChannels')
: (await message.guild!.getSetting('blacklistedUsers')) ?? [];
if (action === 'toggle') {
action = blacklistedUsers.includes(targetID) || blacklistedChannels.includes(targetID) ? 'unblacklist' : 'blacklist';
}
- const newValue = util.addOrRemoveFromArray(
+ const newValue = addOrRemoveFromArray(
action === 'blacklist' ? 'add' : 'remove',
target instanceof User ? blacklistedUsers : blacklistedChannels,
targetID
@@ -87,22 +100,22 @@ export default class BlacklistCommand extends BushCommand {
const key = target instanceof User ? 'blacklistedUsers' : 'blacklistedChannels';
const success = await (global
- ? util.setGlobal(key, newValue)
+ ? setGlobal(key, newValue)
: message.guild!.setSetting(key, newValue, message.member as GuildMember)
).catch(() => false);
if (!success)
return await message.util.reply({
- content: `${util.emojis.error} There was an error${global ? ' globally' : ''} ${action}ing ${util.format.input(
+ content: `${emojis.error} There was an error${global ? ' globally' : ''} ${action}ing ${format.input(
target instanceof User ? target.tag : target.name
)}.`,
allowedMentions: AllowedMentions.none()
});
else
return await message.util.reply({
- content: `${util.emojis.success} Successfully ${action}ed ${util.format.input(
- target instanceof User ? target.tag : target.name
- )}${global ? ' globally' : ''}.`,
+ content: `${emojis.success} Successfully ${action}ed ${format.input(target instanceof User ? target.tag : target.name)}${
+ global ? ' globally' : ''
+ }.`,
allowedMentions: AllowedMentions.none()
});
}