diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-12-29 16:15:06 -0500 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-12-29 16:15:06 -0500 |
commit | 08d7e6eb125c5ff6846c3a92491de79d291b8e12 (patch) | |
tree | 4abdaeee3ad258ef8fa0d7b517ea49d262d18b0b /src/commands | |
parent | f9cf43fc47be2d497d92d728ea892246df96d736 (diff) | |
download | tanzanite-08d7e6eb125c5ff6846c3a92491de79d291b8e12.tar.gz tanzanite-08d7e6eb125c5ff6846c3a92491de79d291b8e12.tar.bz2 tanzanite-08d7e6eb125c5ff6846c3a92491de79d291b8e12.zip |
misc improvements & typings changes
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/admin/channelPermissions.ts | 2 | ||||
-rw-r--r-- | src/commands/admin/roleAll.ts | 4 | ||||
-rw-r--r-- | src/commands/config/_customAutomodPhrases.ts (renamed from src/commands/config/customAutomodPhrases.ts) | 38 | ||||
-rw-r--r-- | src/commands/config/_levelRoles.ts (renamed from src/commands/config/levelRoles.ts) | 38 | ||||
-rw-r--r-- | src/commands/config/blacklist.ts | 13 | ||||
-rw-r--r-- | src/commands/dev/__template.ts | 4 | ||||
-rw-r--r-- | src/commands/dev/dm.ts | 17 | ||||
-rw-r--r-- | src/commands/dev/say.ts | 2 | ||||
-rw-r--r-- | src/commands/dev/superUser.ts | 7 | ||||
-rw-r--r-- | src/commands/moderation/_activePunishments.ts (renamed from src/commands/moderation/activePunishments.ts) | 0 | ||||
-rw-r--r-- | src/commands/moderation/removeReactionEmoji.ts | 6 | ||||
-rw-r--r-- | src/commands/moderation/unmute.ts | 8 | ||||
-rw-r--r-- | src/commands/moderation/warn.ts | 8 | ||||
-rw-r--r-- | src/commands/utilities/remind.ts | 2 | ||||
-rw-r--r-- | src/commands/utilities/reminders.ts | 2 | ||||
-rw-r--r-- | src/commands/utilities/steal.ts | 4 | ||||
-rw-r--r-- | src/commands/utilities/suicide.ts | 2 | ||||
-rw-r--r-- | src/commands/utilities/uuid.ts | 4 |
18 files changed, 63 insertions, 98 deletions
diff --git a/src/commands/admin/channelPermissions.ts b/src/commands/admin/channelPermissions.ts index 8c7c540..026f1a6 100644 --- a/src/commands/admin/channelPermissions.ts +++ b/src/commands/admin/channelPermissions.ts @@ -62,7 +62,7 @@ export default class ChannelPermissionsCommand extends BushCommand { state: 'true' | 'false' | 'neutral'; } ) { - if (!message.guild) return await message.util.reply(`${util.emojis.error} This command can only be run in a server.`); + if (!message.inGuild()) return await message.util.reply(`${util.emojis.error} This command can only be run in a server.`); if (!message.member!.permissions.has('ADMINISTRATOR') && !message.member!.user.isOwner()) return await message.util.reply(`${util.emojis.error} You must have admin perms to use this command.`); if (message.util.isSlashMessage(message)) await message.interaction.deferReply(); diff --git a/src/commands/admin/roleAll.ts b/src/commands/admin/roleAll.ts index 5ef379a..6e82011 100644 --- a/src/commands/admin/roleAll.ts +++ b/src/commands/admin/roleAll.ts @@ -37,8 +37,8 @@ export default class RoleAllCommand extends BushCommand { }); } - public override async exec(message: BushMessage | BushSlashMessage, args: { role: ArgType<'role'>; bots: boolean }) { - if (!message.guild) return await message.util.reply(`${util.emojis.error} This command can only be run in a server.`); + public override async exec(message: BushMessage | BushSlashMessage, args: { role: ArgType<'role'>; bots: ArgType<'boolean'> }) { + if (!message.inGuild()) return await message.util.reply(`${util.emojis.error} This command can only be run in a server.`); if (!message.member!.permissions.has('ADMINISTRATOR') && !message.member!.user.isOwner()) return await message.util.reply(`${util.emojis.error} You must have admin perms to use this command.`); if (message.util.isSlashMessage(message)) await message.interaction.deferReply(); diff --git a/src/commands/config/customAutomodPhrases.ts b/src/commands/config/_customAutomodPhrases.ts index cf37595..cd59c9a 100644 --- a/src/commands/config/customAutomodPhrases.ts +++ b/src/commands/config/_customAutomodPhrases.ts @@ -12,37 +12,22 @@ // { // id: 'required_argument', // type: 'string', -// prompt: { -// start: 'What would you like to set your first argument to be?', -// retry: '{error} Pick a valid argument.', -// optional: false -// } +// description: 'This is the first argument.', +// prompt: 'What would you like to set your first argument to be?', +// retry: '{error} Pick a valid argument.', +// slashType: 'STRING' // }, // { // id: 'optional_argument', // type: 'string', -// prompt: { -// start: 'What would you like to set your second argument to be?', -// retry: '{error} Pick a valid argument.', -// optional: true -// } +// description: 'This is the second argument.', +// prompt: 'What would you like to set your second argument to be?', +// retry: '{error} Pick a valid argument.', +// optional: true, +// slashType: 'STRING' // } // ], // slash: true, -// slashOptions: [ -// { -// name: 'required_argument', -// description: 'What would you like to set your first argument to be?', -// type: 'STRING', -// required: true -// }, -// { -// name: 'optional_argument', -// description: 'What would you like to set your second argument to be?', -// type: 'STRING', -// required: false -// } -// ], // channel: 'guild', // clientPermissions: (m) => util.clientSendAndPermCheck(m), // userPermissions: ['MANAGE_GUILD'] @@ -52,8 +37,5 @@ // public override async exec( // message: BushMessage | BushSlashMessage, // args: { required_argument: string; optional_argument: string } -// ) { -// return await message.util.reply(`${util.emojis.error} Do not use the template command.`); -// args; -// } +// ) {} // } diff --git a/src/commands/config/levelRoles.ts b/src/commands/config/_levelRoles.ts index 7f99580..af7e637 100644 --- a/src/commands/config/levelRoles.ts +++ b/src/commands/config/_levelRoles.ts @@ -10,39 +10,24 @@ // examples: ['level-role 1 2'], // args: [ // { -// id: 'action', -// customType: ['add', 'remove'] -// }, -// { -// id: 'role', -// type: 'role', +// id: 'required_argument', +// type: 'string', +// description: 'This is the first argument.', // prompt: 'What would you like to set your first argument to be?', // retry: '{error} Pick a valid argument.', -// optional: false +// slashType: 'STRING' // }, // { -// id: 'level', -// type: 'integer', +// id: 'optional_argument', +// type: 'string', +// description: 'This is the second argument.', // prompt: 'What would you like to set your second argument to be?', // retry: '{error} Pick a valid argument.', -// optional: false +// optional: true, +// slashType: 'STRING' // } // ], // slash: true, -// slashOptions: [ -// { -// name: 'role', -// description: 'What would you like to set your first argument to be?', -// type: 'STRING', -// required: true -// }, -// { -// name: 'level', -// description: 'What would you like to set your second argument to be?', -// type: 'STRING', -// required: true -// } -// ], // channel: 'guild', // clientPermissions: (m) => util.clientSendAndPermCheck(m), // userPermissions: ['MANAGE_GUILD', 'MANAGE_ROLES'] @@ -52,8 +37,5 @@ // public override async exec( // message: BushMessage | BushSlashMessage, // args: { required_argument: string; optional_argument: string } -// ) { -// return await message.util.reply(`${util.emojis.error} Do not use the template command.`); -// args; -// } +// ) {} // } diff --git a/src/commands/config/blacklist.ts b/src/commands/config/blacklist.ts index d119774..d15b8d7 100644 --- a/src/commands/config/blacklist.ts +++ b/src/commands/config/blacklist.ts @@ -1,4 +1,4 @@ -import { AllowedMentions, ArgType, BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; +import { AllowedMentions, BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; import { User } from 'discord.js'; export default class BlacklistCommand extends BushCommand { @@ -16,10 +16,7 @@ export default class BlacklistCommand extends BushCommand { readableType: "'blacklist'|'unblacklist'", prompt: 'Would you like to add or remove someone or something from/to the blacklist?', slashType: 'STRING', - choices: [ - { name: 'blacklist', value: 'blacklist' }, - { name: 'unblacklist', value: 'unblacklist' } - ], + choices: ['blacklist', 'unblacklist'].map((c) => ({ name: c, value: c })), only: 'slash' }, { @@ -51,7 +48,11 @@ export default class BlacklistCommand extends BushCommand { public override async exec( message: BushMessage | BushSlashMessage, - args: { action?: 'blacklist' | 'unblacklist'; target: ArgType<'channel'> | ArgType<'user'> | string; global: boolean } + args: { + action?: 'blacklist' | 'unblacklist'; + target: ArgType<'channel'> | ArgType<'user'> | string; // there is no way to combine channel and user in slash commands without making subcommands + global: ArgType<'boolean'>; + } ) { let action: 'blacklist' | 'unblacklist' | 'toggle' = args.action ?? (message?.util?.parsed?.alias as 'blacklist' | 'unblacklist' | undefined) ?? 'toggle'; diff --git a/src/commands/dev/__template.ts b/src/commands/dev/__template.ts index 4341198..11d9649 100644 --- a/src/commands/dev/__template.ts +++ b/src/commands/dev/__template.ts @@ -1,4 +1,4 @@ -import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; +import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage, type OptionalArgType } from '#lib'; export default class TemplateCommand extends BushCommand { public constructor() { @@ -39,7 +39,7 @@ export default class TemplateCommand extends BushCommand { public override async exec( message: BushMessage | BushSlashMessage, - args: { required_argument: string; optional_argument: string } + args: { required_argument: ArgType<'string'>; optional_argument: OptionalArgType<'string'> } ) { return await message.util.reply(`${util.emojis.error} Do not use the template command.`); args; diff --git a/src/commands/dev/dm.ts b/src/commands/dev/dm.ts index 4133b96..d702875 100644 --- a/src/commands/dev/dm.ts +++ b/src/commands/dev/dm.ts @@ -1,4 +1,4 @@ -import { ArgType, BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; +import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; export default class DMCommand extends BushCommand { public constructor() { @@ -21,10 +21,9 @@ export default class DMCommand extends BushCommand { id: 'content', type: 'string', match: 'rest', - description: 'This is the second argument.', - prompt: 'What would you like to set your second argument to be?', - retry: '{error} Pick a valid argument.', - optional: true, + description: 'The content to send to the user.', + prompt: 'What would you like to send to the user?', + retry: '{error} Pick something to send the user.', slashType: 'STRING' } ], @@ -35,10 +34,12 @@ export default class DMCommand extends BushCommand { userPermissions: [] }); } - public override async exec(message: BushMessage | BushSlashMessage, args: { user: ArgType<'user'>; content: string }) { + public override async exec( + message: BushMessage | BushSlashMessage, + args: { user: ArgType<'user'>; content: ArgType<'string'> } + ) { try { - const u = await client.users.fetch(args.user.id); - await u.send(args.content); + await client.users.send(args.user.id, args.content); } catch (e) { return message.util.reply(`${util.emojis.error} There was an error sending ${util.format.input(args.user.tag)} a dm.`); } diff --git a/src/commands/dev/say.ts b/src/commands/dev/say.ts index 80cbbe2..2c8151f 100644 --- a/src/commands/dev/say.ts +++ b/src/commands/dev/say.ts @@ -26,7 +26,7 @@ export default class SayCommand extends BushCommand { }); } - public override async exec(message: BushMessage, args: { content: string }) { + public override async exec(message: BushMessage | BushSlashMessage, args: { content: string }) { if (!message.author.isOwner()) return await message.util.reply(`${util.emojis.error} Only my developers can run this command.`); diff --git a/src/commands/dev/superUser.ts b/src/commands/dev/superUser.ts index 35e98aa..3a6406d 100644 --- a/src/commands/dev/superUser.ts +++ b/src/commands/dev/superUser.ts @@ -1,4 +1,4 @@ -import { ArgType, BushCommand, Global, type BushMessage, type BushSlashMessage } from '#lib'; +import { BushCommand, Global, type ArgType, type BushMessage } from '#lib'; import { type ArgumentOptions, type Flag } from 'discord-akairo'; export default class SuperUserCommand extends BushCommand { @@ -53,10 +53,7 @@ export default class SuperUserCommand extends BushCommand { return { action, user }; } - public override async exec( - message: BushMessage | BushSlashMessage, - { action, user }: { action: 'add' | 'remove'; user: ArgType<'user'> } - ) { + public override async exec(message: BushMessage, { action, user }: { action: 'add' | 'remove'; user: ArgType<'user'> }) { if (!message.author.isOwner()) return await message.util.reply(`${util.emojis.error} Only my developers can run this command.`); diff --git a/src/commands/moderation/activePunishments.ts b/src/commands/moderation/_activePunishments.ts index d40f2ba..d40f2ba 100644 --- a/src/commands/moderation/activePunishments.ts +++ b/src/commands/moderation/_activePunishments.ts diff --git a/src/commands/moderation/removeReactionEmoji.ts b/src/commands/moderation/removeReactionEmoji.ts index bede2cf..919ee40 100644 --- a/src/commands/moderation/removeReactionEmoji.ts +++ b/src/commands/moderation/removeReactionEmoji.ts @@ -1,4 +1,5 @@ -import { ArgType, BushCommand, type BushMessage } from '#lib'; +import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; +import assert from 'assert'; import { Message, type Emoji } from 'discord.js'; export default class RemoveReactionEmojiCommand extends BushCommand { @@ -37,9 +38,10 @@ export default class RemoveReactionEmojiCommand extends BushCommand { } public override async exec( - message: BushMessage, + message: BushMessage | BushSlashMessage, args: { message: ArgType<'guildMessage'> | string; emoji: ArgType<'emoji'> | ArgType<'snowflake'> } ) { + assert(message.channel); const resolvedMessage = args.message instanceof Message ? args.message : await message.channel.messages.fetch(args.message); const id = !(['string'] as const).includes(typeof args.emoji); diff --git a/src/commands/moderation/unmute.ts b/src/commands/moderation/unmute.ts index d36a5db..e7a19d6 100644 --- a/src/commands/moderation/unmute.ts +++ b/src/commands/moderation/unmute.ts @@ -1,12 +1,12 @@ import { AllowedMentions, - ArgType, BushCommand, Moderation, - OptionalArgType, + type ArgType, type BushGuildMember, type BushMessage, - type BushSlashMessage + type BushSlashMessage, + type OptionalArgType } from '#lib'; export default class UnmuteCommand extends BushCommand { @@ -56,7 +56,7 @@ export default class UnmuteCommand extends BushCommand { public override async exec( message: BushMessage | BushSlashMessage, - { user, reason, force }: { user: ArgType<'user'>; reason: OptionalArgType<'string'>; force: boolean } + { user, reason, force = false }: { user: ArgType<'user'>; reason: OptionalArgType<'string'>; force?: boolean } ) { const error = util.emojis.error; const member = message.guild!.members.cache.get(user.id) as BushGuildMember; diff --git a/src/commands/moderation/warn.ts b/src/commands/moderation/warn.ts index 95e409d..5093c9b 100644 --- a/src/commands/moderation/warn.ts +++ b/src/commands/moderation/warn.ts @@ -1,12 +1,12 @@ import { AllowedMentions, - ArgType, BushCommand, Moderation, - OptionalArgType, + type ArgType, type BushGuildMember, type BushMessage, - type BushSlashMessage + type BushSlashMessage, + type OptionalArgType } from '#lib'; export default class WarnCommand extends BushCommand { @@ -55,7 +55,7 @@ export default class WarnCommand extends BushCommand { public override async exec( message: BushMessage | BushSlashMessage, - { user, reason, force }: { user: ArgType<'user'>; reason: OptionalArgType<'string'>; force?: boolean } + { user, reason, force = false }: { user: ArgType<'user'>; reason: OptionalArgType<'string'>; force?: boolean } ) { const member = message.guild!.members.cache.get(user.id) as BushGuildMember; if (!member) return message.util.reply(`${util.emojis.error} I cannot warn users that are not in the server.`); diff --git a/src/commands/utilities/remind.ts b/src/commands/utilities/remind.ts index 8df24c1..6339343 100644 --- a/src/commands/utilities/remind.ts +++ b/src/commands/utilities/remind.ts @@ -1,4 +1,4 @@ -import { ArgType, BushCommand, Reminder, type BushMessage, type BushSlashMessage } from '#lib'; +import { BushCommand, Reminder, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; export default class RemindCommand extends BushCommand { public constructor() { diff --git a/src/commands/utilities/reminders.ts b/src/commands/utilities/reminders.ts index 7180aa9..34034d8 100644 --- a/src/commands/utilities/reminders.ts +++ b/src/commands/utilities/reminders.ts @@ -1,5 +1,5 @@ import { BushCommand, ButtonPaginator, Reminder, type BushMessage, type BushSlashMessage } from '#lib'; -import { MessageEmbedOptions } from 'discord.js'; +import { type MessageEmbedOptions } from 'discord.js'; import { Op } from 'sequelize'; export default class RemindersCommand extends BushCommand { diff --git a/src/commands/utilities/steal.ts b/src/commands/utilities/steal.ts index 480201a..67b8382 100644 --- a/src/commands/utilities/steal.ts +++ b/src/commands/utilities/steal.ts @@ -1,5 +1,5 @@ -import { ArgType, BushCommand, BushSlashMessage, type BushMessage } from '#lib'; -import { ArgumentOptions, ArgumentType, ArgumentTypeCaster, Flag } from 'discord-akairo'; +import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; +import { type ArgumentOptions, type ArgumentType, type ArgumentTypeCaster, type Flag } from 'discord-akairo'; import _ from 'lodash'; import { URL } from 'url'; diff --git a/src/commands/utilities/suicide.ts b/src/commands/utilities/suicide.ts index 641f7ec..f0d75a2 100644 --- a/src/commands/utilities/suicide.ts +++ b/src/commands/utilities/suicide.ts @@ -1,5 +1,5 @@ import { AllowedMentions, BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; -import { Message, MessageEmbed } from 'discord.js'; +import { MessageEmbed, type Message } from 'discord.js'; export default class TemplateCommand extends BushCommand { public constructor() { diff --git a/src/commands/utilities/uuid.ts b/src/commands/utilities/uuid.ts index 6195edd..d842b58 100644 --- a/src/commands/utilities/uuid.ts +++ b/src/commands/utilities/uuid.ts @@ -1,4 +1,4 @@ -import { BushCommand, type BushMessage } from '#lib'; +import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; export default class UuidCommand extends BushCommand { public constructor() { @@ -35,7 +35,7 @@ export default class UuidCommand extends BushCommand { } public override async exec( - message: BushMessage, + message: BushMessage | BushSlashMessage, { ign, dashed }: { ign: { match: RegExpMatchArray; matches: any[] }; dashed: boolean } ) { if (!ign) return await message.util.reply(`${util.emojis.error} Please enter a valid ign.`); |