diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-01-23 18:13:05 -0500 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-01-23 18:13:05 -0500 |
commit | a3f8d3884a1deca5eccfb6d990e2a7b42fbbe08a (patch) | |
tree | 9b0f8ed8a93c22c90512751e3f2f5937e1925760 /src/commands/moderation | |
parent | 5557677f1570eb564a30cfcebb6030235dc84d47 (diff) | |
download | tanzanite-a3f8d3884a1deca5eccfb6d990e2a7b42fbbe08a.tar.gz tanzanite-a3f8d3884a1deca5eccfb6d990e2a7b42fbbe08a.tar.bz2 tanzanite-a3f8d3884a1deca5eccfb6d990e2a7b42fbbe08a.zip |
fix discord.js breaking changes, some other stuff
Diffstat (limited to 'src/commands/moderation')
-rw-r--r-- | src/commands/moderation/_activePunishments.ts | 10 | ||||
-rw-r--r-- | src/commands/moderation/ban.ts | 14 | ||||
-rw-r--r-- | src/commands/moderation/block.ts | 11 | ||||
-rw-r--r-- | src/commands/moderation/evidence.ts | 7 | ||||
-rw-r--r-- | src/commands/moderation/hideCase.ts | 5 | ||||
-rw-r--r-- | src/commands/moderation/kick.ts | 11 | ||||
-rw-r--r-- | src/commands/moderation/lockdown.ts | 16 | ||||
-rw-r--r-- | src/commands/moderation/modlog.ts | 8 | ||||
-rw-r--r-- | src/commands/moderation/mute.ts | 11 | ||||
-rw-r--r-- | src/commands/moderation/purge.ts | 15 | ||||
-rw-r--r-- | src/commands/moderation/removeReactionEmoji.ts | 11 | ||||
-rw-r--r-- | src/commands/moderation/role.ts | 19 | ||||
-rw-r--r-- | src/commands/moderation/slowmode.ts | 17 | ||||
-rw-r--r-- | src/commands/moderation/timeout.ts | 11 | ||||
-rw-r--r-- | src/commands/moderation/unban.ts | 12 | ||||
-rw-r--r-- | src/commands/moderation/unblock.ts | 11 | ||||
-rw-r--r-- | src/commands/moderation/unlockdown.ts | 13 | ||||
-rw-r--r-- | src/commands/moderation/unmute.ts | 11 | ||||
-rw-r--r-- | src/commands/moderation/untimeout.ts | 11 | ||||
-rw-r--r-- | src/commands/moderation/warn.ts | 9 |
20 files changed, 137 insertions, 96 deletions
diff --git a/src/commands/moderation/_activePunishments.ts b/src/commands/moderation/_activePunishments.ts index 98c4912..5b1674c 100644 --- a/src/commands/moderation/_activePunishments.ts +++ b/src/commands/moderation/_activePunishments.ts @@ -1,5 +1,6 @@ // import { BushCommand, ModLog, ModLogModel, type BushGuildMember, type BushMessage, type BushSlashMessage } from '#lib'; // import { FindOptions, Op } from 'sequelize'; +// import { Permissions } from 'discord.js'; // const punishmentTypes = ['ban', 'kick', 'mute', 'warn', 'role'] as const; @@ -19,8 +20,8 @@ // match: 'option', // prompt: 'Only show active punishments from what user?', // optional: true, -// slashType: 'USER', -// slashResolve: 'member' +// slashType: ApplicationCommandOptionType.User, +// slashResolve: 'Member' // }, // { // id: 'type', @@ -29,7 +30,7 @@ // readableType: punishmentTypes.map((v) => `'${v}'`).join('|'), // match: 'option', // optional: true, -// slashType: 'STRING', +// slashType: ApplicationCommandOptionType.String, // choices: punishmentTypes.map((v) => ({ name: v, value: v })) // } // ], @@ -37,9 +38,10 @@ // channel: 'guild', // hidden: true, // clientPermissions: (m) => util.clientSendAndPermCheck(m), -// userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES']) +// userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES]) // }); // } +// // public override async exec( // message: BushMessage | BushSlashMessage, // args: { moderator?: BushGuildMember; type: typeof punishmentTypes[number] } diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index aeb03f0..33f980d 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -8,7 +8,7 @@ import { type BushSlashMessage, type OptionalArgType } from '#lib'; -import { type User } from 'discord.js'; +import { ApplicationCommandOptionType, Permissions, type User } from 'discord.js'; export default class BanCommand extends BushCommand { public constructor() { @@ -25,7 +25,7 @@ export default class BanCommand extends BushCommand { type: util.arg.union('user', 'snowflake'), prompt: 'What user would you like to ban?', retry: '{error} Choose a valid user to ban.', - slashType: 'USER' + slashType: ApplicationCommandOptionType.User }, { id: 'reason_and_duration', @@ -34,7 +34,7 @@ export default class BanCommand extends BushCommand { match: 'rest', prompt: 'Why should this user be banned and for how long?', retry: '{error} Choose a valid ban reason and duration.', - slashType: 'STRING', + slashType: ApplicationCommandOptionType.String, optional: true }, { @@ -46,7 +46,7 @@ export default class BanCommand extends BushCommand { retry: '{error} Choose between 0 and 7 days to delete messages from the user for.', type: util.arg.range('integer', 0, 7, true), optional: true, - slashType: 'INTEGER', + slashType: ApplicationCommandOptionType.Integer, choices: [...Array(8).keys()].map((v) => ({ name: v.toString(), value: v })) }, { @@ -62,8 +62,8 @@ export default class BanCommand extends BushCommand { ], slash: true, channel: 'guild', - clientPermissions: ['BAN_MEMBERS'], - userPermissions: ['BAN_MEMBERS'] + clientPermissions: [Permissions.FLAGS.BAN_MEMBERS], + userPermissions: [Permissions.FLAGS.BAN_MEMBERS] }); } @@ -141,6 +141,8 @@ export default class BanCommand extends BushCommand { return `${util.emojis.warn} Banned ${victim} however I could not send them a dm.`; case banResponse.SUCCESS: return `${util.emojis.success} Successfully banned ${victim}.`; + default: + return `${util.emojis.error} An error occurred: ${util.format.input(responseCode)}}`; } }; return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() }); diff --git a/src/commands/moderation/block.ts b/src/commands/moderation/block.ts index 57f909a..0b6458d 100644 --- a/src/commands/moderation/block.ts +++ b/src/commands/moderation/block.ts @@ -11,6 +11,7 @@ import { type OptionalArgType } from '#lib'; import assert from 'assert'; +import { ApplicationCommandOptionType, Permissions } from 'discord.js'; export default class BlockCommand extends BushCommand { public constructor() { @@ -27,7 +28,7 @@ export default class BlockCommand extends BushCommand { type: 'user', prompt: 'What user would you like to block?', retry: '{error} Choose a valid user to block.', - slashType: 'USER' + slashType: ApplicationCommandOptionType.User }, { id: 'reason_and_duration', @@ -37,7 +38,7 @@ export default class BlockCommand extends BushCommand { prompt: 'Why should this user be blocked and for how long?', retry: '{error} Choose a valid block reason and duration.', optional: true, - slashType: 'STRING' + slashType: ApplicationCommandOptionType.String }, { id: 'force', @@ -52,8 +53,8 @@ export default class BlockCommand extends BushCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, 'MANAGE_CHANNELS'), - userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES']) + clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_CHANNELS]), + userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES]) }); } @@ -120,6 +121,8 @@ export default class BlockCommand extends BushCommand { return `${util.emojis.warn} Blocked ${victim} however I could not send them a dm.`; case blockResponse.SUCCESS: return `${util.emojis.success} Successfully blocked ${victim}.`; + default: + return `${util.emojis.error} An error occurred: ${util.format.input(responseCode)}}`; } }; return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() }); diff --git a/src/commands/moderation/evidence.ts b/src/commands/moderation/evidence.ts index cff63ed..155d804 100644 --- a/src/commands/moderation/evidence.ts +++ b/src/commands/moderation/evidence.ts @@ -1,5 +1,6 @@ import { BushCommand, ModLog, type BushMessage, type BushSlashMessage } from '#lib'; import { type ArgumentOptions, type Flag } from 'discord-akairo'; +import { ApplicationCommandOptionType, Permissions } from 'discord.js'; export default class EvidenceCommand extends BushCommand { public constructor() { @@ -15,7 +16,7 @@ export default class EvidenceCommand extends BushCommand { description: 'The case to modify the evidence of.', type: 'string', prompt: 'What case would you like to modify the evidence of?', - slashType: 'STRING', + slashType: ApplicationCommandOptionType.String, only: 'slash' }, { @@ -23,14 +24,14 @@ export default class EvidenceCommand extends BushCommand { description: 'The value to set the evidence to.', type: 'string', prompt: 'What would you like to modify the evidence to?', - slashType: 'STRING', + slashType: ApplicationCommandOptionType.String, only: 'slash' } ], slash: true, channel: 'guild', clientPermissions: (m) => util.clientSendAndPermCheck(m), - userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES']) + userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES]) }); } diff --git a/src/commands/moderation/hideCase.ts b/src/commands/moderation/hideCase.ts index e12d8c8..2c71119 100644 --- a/src/commands/moderation/hideCase.ts +++ b/src/commands/moderation/hideCase.ts @@ -1,4 +1,5 @@ import { BushCommand, ModLog, type BushMessage, type BushSlashMessage } from '#lib'; +import { ApplicationCommandOptionType, Permissions } from 'discord.js'; export default class HideCaseCommand extends BushCommand { public constructor() { @@ -15,12 +16,12 @@ export default class HideCaseCommand extends BushCommand { type: 'string', prompt: 'What modlog case would you like to hide?', retry: '{error} Choose a valid case id.', - slashType: 'STRING' + slashType: ApplicationCommandOptionType.String } ], slash: true, clientPermissions: (m) => util.clientSendAndPermCheck(m), - userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES']), + userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES]), channel: 'guild' }); } diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts index af486ac..4fd6c10 100644 --- a/src/commands/moderation/kick.ts +++ b/src/commands/moderation/kick.ts @@ -7,6 +7,7 @@ import { type BushMessage, type BushSlashMessage } from '#lib'; +import { ApplicationCommandOptionType, Permissions } from 'discord.js'; export default class KickCommand extends BushCommand { public constructor() { @@ -23,7 +24,7 @@ export default class KickCommand extends BushCommand { type: 'user', prompt: 'What user would you like to kick?', retry: '{error} Choose a valid user to kick.', - slashType: 'USER' + slashType: ApplicationCommandOptionType.User }, { id: 'reason', @@ -33,7 +34,7 @@ export default class KickCommand extends BushCommand { prompt: 'Why should this user be kicked?', retry: '{error} Choose a valid kick reason.', optional: true, - slashType: 'STRING' + slashType: ApplicationCommandOptionType.String }, { id: 'force', @@ -47,8 +48,8 @@ export default class KickCommand extends BushCommand { } ], slash: true, - clientPermissions: (m) => util.clientSendAndPermCheck(m, ['KICK_MEMBERS']), - userPermissions: ['KICK_MEMBERS'] + clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.KICK_MEMBERS]), + userPermissions: [Permissions.FLAGS.KICK_MEMBERS] }); } @@ -86,6 +87,8 @@ export default class KickCommand extends BushCommand { return `${util.emojis.warn} Kicked ${victim} however I could not send them a dm.`; case kickResponse.SUCCESS: return `${util.emojis.success} Successfully kicked ${victim}.`; + default: + return `${util.emojis.error} An error occurred: ${util.format.input(responseCode)}}`; } }; return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() }); diff --git a/src/commands/moderation/lockdown.ts b/src/commands/moderation/lockdown.ts index 87a2f05..350ce26 100644 --- a/src/commands/moderation/lockdown.ts +++ b/src/commands/moderation/lockdown.ts @@ -11,7 +11,7 @@ import { type OptionalArgType } from '#lib'; import assert from 'assert'; -import { Collection } from 'discord.js'; +import { ApplicationCommandOptionType, Collection, Permissions } from 'discord.js'; export default class LockdownCommand extends BushCommand { public constructor() { @@ -27,8 +27,8 @@ export default class LockdownCommand extends BushCommand { description: 'Specify a different channel to lockdown instead of the one you trigger the command in.', type: util.arg.union('textChannel', 'newsChannel', 'threadChannel'), prompt: 'What channel would you like to lockdown?', - slashType: 'CHANNEL', - channelTypes: ['GUILD_TEXT', 'GUILD_NEWS', 'GUILD_NEWS_THREAD', 'GUILD_PUBLIC_THREAD', 'GUILD_PRIVATE_THREAD'], + slashType: ApplicationCommandOptionType.Channel, + channelTypes: ['GuildText', 'GuildNews', 'GuildNewsThread', 'GuildPublicThread', 'GuildPrivateThread'], optional: true }, { @@ -37,7 +37,7 @@ export default class LockdownCommand extends BushCommand { type: 'string', match: 'rest', prompt: 'What is the reason for the lockdown?', - slashType: 'STRING', + slashType: ApplicationCommandOptionType.String, optional: true }, { @@ -46,14 +46,14 @@ export default class LockdownCommand extends BushCommand { match: 'flag', flag: '--all', prompt: 'Would you like to lockdown all configured channels?', - slashType: 'BOOLEAN', + slashType: ApplicationCommandOptionType.Boolean, optional: true } ], slash: true, channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_CHANNELS']), - userPermissions: ['MANAGE_CHANNELS'] + clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_CHANNELS]), + userPermissions: [Permissions.FLAGS.MANAGE_CHANNELS] }); } @@ -134,7 +134,7 @@ export default class LockdownCommand extends BushCommand { action === 'lockdown' ? 'locked down' : 'unlocked' } **${num}** channel${num > 0 ? 's' : ''}.`; } else { - throw new Error(`Unknown response: ${response}`); + return `${util.emojis.error} An error occurred: ${util.format.input(response)}}`; } assert(messageResponse); diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts index 8651afe..e7b3576 100644 --- a/src/commands/moderation/modlog.ts +++ b/src/commands/moderation/modlog.ts @@ -1,5 +1,5 @@ import { BushCommand, ButtonPaginator, ModLog, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; -import { MessageEmbed, User } from 'discord.js'; +import { ApplicationCommandOptionType, MessageEmbed, Permissions, User } from 'discord.js'; export default class ModlogCommand extends BushCommand { public constructor() { @@ -16,7 +16,7 @@ export default class ModlogCommand extends BushCommand { type: util.arg.union('user', 'string'), prompt: 'What case id or user would you like to see?', retry: '{error} Choose a valid case id or user.', - slashType: 'STRING' + slashType: ApplicationCommandOptionType.String }, { id: 'hidden', @@ -26,12 +26,12 @@ export default class ModlogCommand extends BushCommand { flag: ['--hidden', '-h'], default: false, optional: true, - slashType: 'BOOLEAN' + slashType: ApplicationCommandOptionType.Boolean } ], slash: true, clientPermissions: (m) => util.clientSendAndPermCheck(m), - userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES']) + userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES]) }); } diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts index 40e13e7..ea935ce 100644 --- a/src/commands/moderation/mute.ts +++ b/src/commands/moderation/mute.ts @@ -9,6 +9,7 @@ import { type OptionalArgType } from '#lib'; import assert from 'assert'; +import { ApplicationCommandOptionType, Permissions } from 'discord.js'; export default class MuteCommand extends BushCommand { public constructor() { @@ -25,7 +26,7 @@ export default class MuteCommand extends BushCommand { type: 'user', prompt: 'What user would you like to mute?', retry: '{error} Choose a valid user to mute.', - slashType: 'USER' + slashType: ApplicationCommandOptionType.User }, { id: 'reason_and_duration', @@ -35,7 +36,7 @@ export default class MuteCommand extends BushCommand { prompt: 'Why should this user be muted and for how long?', retry: '{error} Choose a valid mute reason and duration.', optional: true, - slashType: 'STRING' + slashType: ApplicationCommandOptionType.String }, { id: 'force', @@ -50,8 +51,8 @@ export default class MuteCommand extends BushCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_ROLES']), - userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES']) + clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_ROLES]), + userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES]) }); } @@ -118,6 +119,8 @@ export default class MuteCommand extends BushCommand { return `${util.emojis.warn} Muted ${victim} however I could not send them a dm.`; case muteResponse.SUCCESS: return `${util.emojis.success} Successfully muted ${victim}.`; + default: + return `${util.emojis.error} An error occurred: ${util.format.input(responseCode)}}`; } }; return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() }); diff --git a/src/commands/moderation/purge.ts b/src/commands/moderation/purge.ts index 8fa279b..b48f997 100644 --- a/src/commands/moderation/purge.ts +++ b/src/commands/moderation/purge.ts @@ -1,6 +1,6 @@ import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; import assert from 'assert'; -import { Collection, type Snowflake } from 'discord.js'; +import { ApplicationCommandOptionType, Collection, Permissions, type Snowflake } from 'discord.js'; export default class PurgeCommand extends BushCommand { public constructor() { @@ -18,7 +18,7 @@ export default class PurgeCommand extends BushCommand { readableType: 'integer', prompt: 'How many messages would you like to purge?', retry: '{error} Please pick a number between 1 and 100.', - slashType: 'INTEGER', + slashType: ApplicationCommandOptionType.Integer, minValue: 1, maxValue: 100 }, @@ -28,7 +28,7 @@ export default class PurgeCommand extends BushCommand { match: 'flag', flag: '--bot', prompt: 'Would you like to only delete messages that are from bots?', - slashType: 'BOOLEAN', + slashType: ApplicationCommandOptionType.Boolean, optional: true }, { @@ -37,13 +37,14 @@ export default class PurgeCommand extends BushCommand { match: 'option', type: 'user', flag: '--user', - slashType: 'BOOLEAN', + slashType: ApplicationCommandOptionType.Boolean, optional: true } ], slash: true, - clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_MESSAGES', 'EMBED_LINKS'], true), - userPermissions: ['MANAGE_MESSAGES'], + clientPermissions: (m) => + util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES, Permissions.FLAGS.EMBED_LINKS], true), + userPermissions: [Permissions.FLAGS.MANAGE_MESSAGES], channel: 'guild' }); } @@ -53,7 +54,7 @@ export default class PurgeCommand extends BushCommand { args: { amount: number; bot: boolean; user: ArgType<'user'> } ) { assert(message.channel); - if (message.channel.type === 'DM') return message.util.reply(`${util.emojis.error} You cannot run this command in dms.`); + if (!message.inGuild()) return message.util.reply(`${util.emojis.error} You cannot run this command in dms.`); if (args.amount > 100 || args.amount < 1) return message.util.reply(`${util.emojis.error} `); const messageFilter = (filterMessage: BushMessage): boolean => { diff --git a/src/commands/moderation/removeReactionEmoji.ts b/src/commands/moderation/removeReactionEmoji.ts index 919ee40..61759ae 100644 --- a/src/commands/moderation/removeReactionEmoji.ts +++ b/src/commands/moderation/removeReactionEmoji.ts @@ -1,6 +1,6 @@ import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; import assert from 'assert'; -import { Message, type Emoji } from 'discord.js'; +import { ApplicationCommandOptionType, Message, Permissions, type Emoji } from 'discord.js'; export default class RemoveReactionEmojiCommand extends BushCommand { public constructor() { @@ -17,7 +17,7 @@ export default class RemoveReactionEmojiCommand extends BushCommand { type: 'guildMessage', prompt: 'What message would you like to remove a reaction from?', retry: '{error} Please pick a valid message.', - slashType: 'STRING' + slashType: ApplicationCommandOptionType.String }, { id: 'emoji', @@ -27,13 +27,14 @@ export default class RemoveReactionEmojiCommand extends BushCommand { match: 'restContent', prompt: 'What emoji would you like to remove?', retry: '{error} Please pick a valid emoji.', - slashType: 'STRING' + slashType: ApplicationCommandOptionType.String } ], slash: true, channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_MESSAGES', 'EMBED_LINKS'], true), - userPermissions: ['MANAGE_MESSAGES', 'MANAGE_EMOJIS_AND_STICKERS'] // Can't undo the removal of 1000s of reactions + clientPermissions: (m) => + util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES, Permissions.FLAGS.EMBED_LINKS], true), + userPermissions: [Permissions.FLAGS.MANAGE_MESSAGES, Permissions.FLAGS.MANAGE_EMOJIS_AND_STICKERS] // Can't undo the removal of 1000s of reactions }); } diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts index f0d0448..0d4d91b 100644 --- a/src/commands/moderation/role.ts +++ b/src/commands/moderation/role.ts @@ -9,7 +9,7 @@ import { type OptionalArgType } from '#lib'; import { type ArgumentOptions, type Flag } from 'discord-akairo'; -import { type Snowflake } from 'discord.js'; +import { ApplicationCommandOptionType, Permissions, type Snowflake } from 'discord.js'; export default class RoleCommand extends BushCommand { public constructor() { @@ -24,7 +24,7 @@ export default class RoleCommand extends BushCommand { id: 'action', description: 'Whether to add or remove a role for the the user.', prompt: 'Would you like to add or remove a role?', - slashType: 'STRING', + slashType: ApplicationCommandOptionType.String, choices: [ { name: 'add', value: 'add' }, { name: 'remove', value: 'remove' } @@ -35,8 +35,8 @@ export default class RoleCommand extends BushCommand { id: 'member', description: 'The user to add/remove a role to/from.', prompt: 'What user do you want to add/remove a role to/from?', - slashType: 'USER', - slashResolve: 'member', + slashType: ApplicationCommandOptionType.User, + slashResolve: 'Member', optional: true, only: 'slash' }, @@ -44,7 +44,7 @@ export default class RoleCommand extends BushCommand { id: 'role', description: 'The role you would like to add/remove from the to/from.', prompt: 'What role would you like to add/remove from the user?', - slashType: 'ROLE', + slashType: ApplicationCommandOptionType.Role, optional: true, only: 'slash' }, @@ -52,7 +52,7 @@ export default class RoleCommand extends BushCommand { id: 'duration', description: 'The time before the role will be removed (ignored if removing a role).', prompt: 'How long would you like to role to last?', - slashType: 'STRING', + slashType: ApplicationCommandOptionType.String, optional: true, only: 'slash' } @@ -60,7 +60,8 @@ export default class RoleCommand extends BushCommand { slash: true, channel: 'guild', typing: true, - clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_ROLES', 'EMBED_LINKS'], true), + clientPermissions: (m) => + util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_ROLES, Permissions.FLAGS.EMBED_LINKS], true), userPermissions: [] }); } @@ -129,7 +130,7 @@ export default class RoleCommand extends BushCommand { if (!args.role) return await message.util.reply(`${util.emojis.error} You must specify a role.`); if (args.duration === null) args.duration = 0; if ( - !message.member!.permissions.has('MANAGE_ROLES') && + !message.member!.permissions.has(Permissions.FLAGS.MANAGE_ROLES) && message.member!.id !== message.guild?.ownerId && !message.member!.user.isOwner() ) { @@ -202,6 +203,8 @@ export default class RoleCommand extends BushCommand { return `${util.emojis.success} Successfully ${args.action === 'add' ? 'added' : 'removed'} <@&${args.role.id}> ${ args.action === 'add' ? 'to' : 'from' } ${victim}${args.duration ? ` for ${util.humanizeDuration(args.duration)}` : ''}.`; + default: + return `${util.emojis.error} An error occurred: ${util.format.input(responseCode)}}`; } }; diff --git a/src/commands/moderation/slowmode.ts b/src/commands/moderation/slowmode.ts index bfa6462..a724006 100644 --- a/src/commands/moderation/slowmode.ts +++ b/src/commands/moderation/slowmode.ts @@ -1,6 +1,6 @@ import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; import { Argument } from 'discord-akairo'; -import { type TextChannel, type ThreadChannel } from 'discord.js'; +import { ApplicationCommandOptionType, ChannelType, Permissions, type TextChannel, type ThreadChannel } from 'discord.js'; export default class SlowmodeCommand extends BushCommand { public constructor() { @@ -19,7 +19,7 @@ export default class SlowmodeCommand extends BushCommand { prompt: 'What would you like to set the slowmode to?', retry: '{error} Please set the slowmode to a valid length.', optional: true, - slashType: 'INTEGER' + slashType: ApplicationCommandOptionType.Integer }, { id: 'channel', @@ -28,14 +28,15 @@ export default class SlowmodeCommand extends BushCommand { prompt: 'What channel would you like to change?', retry: '{error} Choose a valid channel.', optional: true, - slashType: 'CHANNEL', - channelTypes: ['GUILD_TEXT', 'GUILD_PRIVATE_THREAD', 'GUILD_PUBLIC_THREAD'] + slashType: ApplicationCommandOptionType.Channel, + channelTypes: ['GuildText', 'GuildPrivateThread', 'GuildPublicThread'] } ], slash: true, channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_CHANNELS', 'EMBED_LINKS'], true), - userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES']) + clientPermissions: (m) => + util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_CHANNELS, Permissions.FLAGS.EMBED_LINKS], true), + userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES]) }); } @@ -49,10 +50,10 @@ export default class SlowmodeCommand extends BushCommand { channel: ArgType<'channel'>; } ) { - if (message.channel!.type === 'DM') + if (message.channel!.type === ChannelType.DM) return await message.util.reply(`${util.emojis.error} This command cannot be run in dms.`); if (!channel) channel = message.channel as any; - if (!(['GUILD_TEXT', 'GUILD_PRIVATE_THREAD', 'GUILD_PUBLIC_THREAD'] as const).includes(channel.type)) + if (![ChannelType.GuildText, ChannelType.GuildPrivateThread, ChannelType.GuildPublicThread].includes(channel.type)) return await message.util.reply(`${util.emojis.error} <#${channel.id}> is not a text or thread channel.`); if (length) { length = diff --git a/src/commands/moderation/timeout.ts b/src/commands/moderation/timeout.ts index ec79271..73b9d50 100644 --- a/src/commands/moderation/timeout.ts +++ b/src/commands/moderation/timeout.ts @@ -8,6 +8,7 @@ import { type BushSlashMessage } from '#lib'; import assert from 'assert'; +import { ApplicationCommandOptionType, Permissions } from 'discord.js'; export default class TimeoutCommand extends BushCommand { public constructor() { @@ -24,7 +25,7 @@ export default class TimeoutCommand extends BushCommand { type: 'user', prompt: 'What user would you like to timeout?', retry: '{error} Choose a valid user to timeout.', - slashType: 'USER' + slashType: ApplicationCommandOptionType.User }, { id: 'reason_and_duration', @@ -33,7 +34,7 @@ export default class TimeoutCommand extends BushCommand { match: 'rest', prompt: 'Why should this user be timed out and for how long?', retry: '{error} Choose a valid timeout reason and duration.', - slashType: 'STRING' + slashType: ApplicationCommandOptionType.String }, { id: 'force', @@ -48,8 +49,8 @@ export default class TimeoutCommand extends BushCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MODERATE_MEMBERS']), - userPermissions: ['MODERATE_MEMBERS'] + clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MODERATE_MEMBERS]), + userPermissions: [Permissions.FLAGS.MODERATE_MEMBERS] }); } @@ -101,6 +102,8 @@ export default class TimeoutCommand extends BushCommand { return `${util.emojis.warn} Timed out ${victim} however I could not send them a dm.`; case timeoutResponse.SUCCESS: return `${util.emojis.success} Successfully timed out ${victim}.`; + default: + return `${util.emojis.error} An error occurred: ${util.format.input(responseCode)}}`; } }; return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() }); diff --git a/src/commands/moderation/unban.ts b/src/commands/moderation/unban.ts index c939792..b2bdd72 100644 --- a/src/commands/moderation/unban.ts +++ b/src/commands/moderation/unban.ts @@ -7,6 +7,7 @@ import { type BushSlashMessage, type OptionalArgType } from '#lib'; +import { ApplicationCommandOptionType, Permissions } from 'discord.js'; export default class UnbanCommand extends BushCommand { public constructor() { @@ -23,7 +24,7 @@ export default class UnbanCommand extends BushCommand { type: 'globalUser', prompt: 'What user would you like to unban?', retry: '{error} Choose a valid user to unban.', - slashType: 'USER' + slashType: ApplicationCommandOptionType.User }, { id: 'reason', @@ -33,15 +34,16 @@ export default class UnbanCommand extends BushCommand { prompt: 'Why should this user be unbanned?', retry: '{error} Choose a valid unban reason.', optional: true, - slashType: 'STRING' + slashType: ApplicationCommandOptionType.String } ], slash: true, channel: 'guild', - clientPermissions: ['BAN_MEMBERS'], - userPermissions: ['BAN_MEMBERS'] + clientPermissions: [Permissions.FLAGS.BAN_MEMBERS], + userPermissions: [Permissions.FLAGS.BAN_MEMBERS] }); } + public override async exec( message: BushMessage | BushSlashMessage, { user, reason }: { user: ArgType<'user'>; reason: OptionalArgType<'string'> } @@ -68,6 +70,8 @@ export default class UnbanCommand extends BushCommand { case unbanResponse.DM_ERROR: case unbanResponse.SUCCESS: return `${util.emojis.success} Successfully unbanned ${victim}.`; + default: + return `${util.emojis.error} An error occurred: ${util.format.input(responseCode)}}`; } }; return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() }); diff --git a/src/commands/moderation/unblock.ts b/src/commands/moderation/unblock.ts index 454de8b..1abf2be 100644 --- a/src/commands/moderation/unblock.ts +++ b/src/commands/moderation/unblock.ts @@ -11,6 +11,7 @@ import { type OptionalArgType } from '#lib'; import assert from 'assert'; +import { ApplicationCommandOptionType, Permissions } from 'discord.js'; export default class UnblockCommand extends BushCommand { public constructor() { @@ -27,7 +28,7 @@ export default class UnblockCommand extends BushCommand { type: 'user', prompt: 'What user would you like to unblock?', retry: '{error} Choose a valid user to unblock.', - slashType: 'USER' + slashType: ApplicationCommandOptionType.User }, { id: 'reason', @@ -37,7 +38,7 @@ export default class UnblockCommand extends BushCommand { prompt: 'Why should this user be blocked and for how long?', retry: '{error} Choose a valid block reason and duration.', optional: true, - slashType: 'STRING' + slashType: ApplicationCommandOptionType.String }, { id: 'force', @@ -52,8 +53,8 @@ export default class UnblockCommand extends BushCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, 'MANAGE_CHANNELS'), - userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES']) + clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_CHANNELS]), + userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES]) }); } @@ -102,6 +103,8 @@ export default class UnblockCommand extends BushCommand { return `${util.emojis.warn} Unblocked ${victim} however I could not send them a dm.`; case unblockResponse.SUCCESS: return `${util.emojis.success} Successfully unblocked ${victim}.`; + default: + return `${util.emojis.error} An error occurred: ${util.format.input(responseCode)}}`; } }; return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() }); diff --git a/src/commands/moderation/unlockdown.ts b/src/commands/moderation/unlockdown.ts index 3d363ac..d7ba5ee 100644 --- a/src/commands/moderation/unlockdown.ts +++ b/src/commands/moderation/unlockdown.ts @@ -1,5 +1,6 @@ import { LockdownCommand } from '#commands'; import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage, type OptionalArgType } from '#lib'; +import { ApplicationCommandOptionType, Permissions } from 'discord.js'; export default class UnlockdownCommand extends BushCommand { public constructor() { @@ -15,8 +16,8 @@ export default class UnlockdownCommand extends BushCommand { description: 'Specify a different channel to unlockdown instead of the one you trigger the command in.', type: util.arg.union('textChannel', 'newsChannel', 'threadChannel'), prompt: 'What channel would you like to unlockdown?', - slashType: 'CHANNEL', - channelTypes: ['GUILD_TEXT', 'GUILD_NEWS', 'GUILD_NEWS_THREAD', 'GUILD_PUBLIC_THREAD', 'GUILD_PRIVATE_THREAD'], + slashType: ApplicationCommandOptionType.Channel, + channelTypes: ['GuildText', 'GuildNews', 'GuildNewsThread', 'GuildPublicThread', 'GuildPrivateThread'], optional: true }, { @@ -25,7 +26,7 @@ export default class UnlockdownCommand extends BushCommand { type: 'string', match: 'rest', prompt: 'What is the reason for the unlock?', - slashType: 'STRING', + slashType: ApplicationCommandOptionType.String, optional: true }, { @@ -34,14 +35,14 @@ export default class UnlockdownCommand extends BushCommand { match: 'flag', flag: '--all', prompt: 'Would you like to unlockdown all configured channels?', - slashType: 'BOOLEAN', + slashType: ApplicationCommandOptionType.Boolean, optional: true } ], slash: true, channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_CHANNELS']), - userPermissions: ['MANAGE_CHANNELS'] + clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_CHANNELS]), + userPermissions: [Permissions.FLAGS.MANAGE_CHANNELS] }); } diff --git a/src/commands/moderation/unmute.ts b/src/commands/moderation/unmute.ts index 3bd399f..9974b8d 100644 --- a/src/commands/moderation/unmute.ts +++ b/src/commands/moderation/unmute.ts @@ -9,6 +9,7 @@ import { type BushSlashMessage, type OptionalArgType } from '#lib'; +import { ApplicationCommandOptionType, Permissions } from 'discord.js'; export default class UnmuteCommand extends BushCommand { public constructor() { @@ -25,7 +26,7 @@ export default class UnmuteCommand extends BushCommand { type: 'user', prompt: 'What user would you like to unmute?', retry: '{error} Choose a valid user to unmute.', - slashType: 'USER' + slashType: ApplicationCommandOptionType.User }, { id: 'reason', @@ -35,7 +36,7 @@ export default class UnmuteCommand extends BushCommand { prompt: 'Why should this user be unmuted?', retry: '{error} Choose a valid unmute reason.', optional: true, - slashType: 'STRING' + slashType: ApplicationCommandOptionType.String }, { id: 'force', @@ -50,8 +51,8 @@ export default class UnmuteCommand extends BushCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_ROLES']), - userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES']) + clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MANAGE_ROLES]), + userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES]) }); } @@ -98,6 +99,8 @@ export default class UnmuteCommand extends BushCommand { return `${util.emojis.warn} unmuted ${victim} however I could not send them a dm.`; case unmuteResponse.SUCCESS: return `${util.emojis.success} Successfully unmuted ${victim}.`; + default: + return `${util.emojis.error} An error occurred: ${util.format.input(responseCode)}}`; } }; return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() }); diff --git a/src/commands/moderation/untimeout.ts b/src/commands/moderation/untimeout.ts index c5518b4..6ebd777 100644 --- a/src/commands/moderation/untimeout.ts +++ b/src/commands/moderation/untimeout.ts @@ -9,6 +9,7 @@ import { type OptionalArgType } from '#lib'; import assert from 'assert'; +import { ApplicationCommandOptionType, Permissions } from 'discord.js'; export default class UntimeoutCommand extends BushCommand { public constructor() { @@ -25,7 +26,7 @@ export default class UntimeoutCommand extends BushCommand { type: 'user', prompt: 'What user would you like to untimeout?', retry: '{error} Choose a valid user to untimeout.', - slashType: 'USER' + slashType: ApplicationCommandOptionType.User }, { id: 'reason', @@ -34,7 +35,7 @@ export default class UntimeoutCommand extends BushCommand { match: 'rest', prompt: 'Why should this user have their timeout removed?', retry: '{error} Choose a valid reason to remove the timeout.', - slashType: 'STRING', + slashType: ApplicationCommandOptionType.String, optional: true }, { @@ -50,8 +51,8 @@ export default class UntimeoutCommand extends BushCommand { ], slash: true, channel: 'guild', - clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MODERATE_MEMBERS']), - userPermissions: ['MODERATE_MEMBERS'] + clientPermissions: (m) => util.clientSendAndPermCheck(m, [Permissions.FLAGS.MODERATE_MEMBERS]), + userPermissions: [Permissions.FLAGS.MODERATE_MEMBERS] }); } @@ -92,6 +93,8 @@ export default class UntimeoutCommand extends BushCommand { return `${util.emojis.warn} Removed ${victim}'s timeout however I could not send them a dm.`; case removeTimeoutResponse.SUCCESS: return `${util.emojis.success} Successfully removed ${victim}'s timeout.`; + default: + return `${util.emojis.error} An error occurred: ${util.format.input(responseCode)}}`; } }; return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() }); diff --git a/src/commands/moderation/warn.ts b/src/commands/moderation/warn.ts index aebf300..af45782 100644 --- a/src/commands/moderation/warn.ts +++ b/src/commands/moderation/warn.ts @@ -9,6 +9,7 @@ import { type BushSlashMessage, type OptionalArgType } from '#lib'; +import { ApplicationCommandOptionType, Permissions } from 'discord.js'; export default class WarnCommand extends BushCommand { public constructor() { @@ -25,7 +26,7 @@ export default class WarnCommand extends BushCommand { type: 'user', prompt: 'What user would you like to warn?', retry: '{error} Choose a valid user to warn.', - slashType: 'USER' + slashType: ApplicationCommandOptionType.User }, { id: 'reason', @@ -33,7 +34,7 @@ export default class WarnCommand extends BushCommand { match: 'rest', prompt: 'Why should this user be warned?', retry: '{error} Choose a valid warn reason.', - slashType: 'STRING', + slashType: ApplicationCommandOptionType.String, optional: true }, { @@ -50,7 +51,7 @@ export default class WarnCommand extends BushCommand { slash: true, channel: 'guild', clientPermissions: (m) => util.clientSendAndPermCheck(m), - userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES']) + userPermissions: (m) => util.userGuildPermCheck(m, [Permissions.FLAGS.MANAGE_MESSAGES]) }); } @@ -85,6 +86,8 @@ export default class WarnCommand extends BushCommand { )} time, however I could not send them a dm.`; case warnResponse.SUCCESS: return `${util.emojis.success} Successfully warned ${victim} for the ${util.ordinal(caseNum ?? 0)} time.`; + default: + return `${util.emojis.error} An error occurred: ${util.format.input(response)}}`; } }; return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() }); |