diff options
Diffstat (limited to 'src/commands/moderation')
-rw-r--r-- | src/commands/moderation/_lockdown.ts | 8 | ||||
-rw-r--r-- | src/commands/moderation/ban.ts | 2 | ||||
-rw-r--r-- | src/commands/moderation/evidence.ts | 4 | ||||
-rw-r--r-- | src/commands/moderation/hideCase.ts | 6 | ||||
-rw-r--r-- | src/commands/moderation/kick.ts | 8 | ||||
-rw-r--r-- | src/commands/moderation/modlog.ts | 12 | ||||
-rw-r--r-- | src/commands/moderation/mute.ts | 8 | ||||
-rw-r--r-- | src/commands/moderation/purge.ts | 2 | ||||
-rw-r--r-- | src/commands/moderation/removeReactionEmoji.ts | 6 | ||||
-rw-r--r-- | src/commands/moderation/role.ts | 4 | ||||
-rw-r--r-- | src/commands/moderation/slowmode.ts | 4 | ||||
-rw-r--r-- | src/commands/moderation/unban.ts | 7 | ||||
-rw-r--r-- | src/commands/moderation/unmute.ts | 6 | ||||
-rw-r--r-- | src/commands/moderation/warn.ts | 6 |
14 files changed, 37 insertions, 46 deletions
diff --git a/src/commands/moderation/_lockdown.ts b/src/commands/moderation/_lockdown.ts index 5df9f18..0086ff6 100644 --- a/src/commands/moderation/_lockdown.ts +++ b/src/commands/moderation/_lockdown.ts @@ -27,15 +27,15 @@ export default class LockdownCommand extends BushCommand { } ], channel: 'guild', - clientPermissions: ['SEND_MESSAGES'], - userPermissions: ['SEND_MESSAGES'], + clientPermissions: (m) => util.clientSendAndPermCheck(m), + userPermissions: [], hidden: true }); } - public override async exec(message: BushMessage | BushSlashMessage, { all }: { all: boolean }): Promise<unknown> { + public override async exec(message: BushMessage | BushSlashMessage, args: { all: boolean }): Promise<unknown> { return await message.util.reply('Unfortunately my developer is too lazy to implement this command.'); - if (!all) { + if (!args.all) { if (!['GUILD_TEXT', 'GUILD_NEWS'].includes(message.channel!.type)) return message.util.reply(`${util.emojis.error} You can only lock down text and announcement channels.`); diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index 4c2b3d3..b3d97d2 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -1,6 +1,6 @@ import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage } from '@lib'; import { Snowflake, User } from 'discord.js'; -import { Moderation } from '../../lib/common/moderation'; +import { Moderation } from '../../lib/common/Moderation'; export default class BanCommand extends BushCommand { public constructor() { diff --git a/src/commands/moderation/evidence.ts b/src/commands/moderation/evidence.ts index 250df24..a681bc1 100644 --- a/src/commands/moderation/evidence.ts +++ b/src/commands/moderation/evidence.ts @@ -27,8 +27,8 @@ export default class EvidenceCommand extends BushCommand { } ], channel: 'guild', - clientPermissions: ['SEND_MESSAGES'], - userPermissions: ['SEND_MESSAGES', 'MANAGE_MESSAGES'] + clientPermissions: (m) => util.clientSendAndPermCheck(m), + userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES']) }); } diff --git a/src/commands/moderation/hideCase.ts b/src/commands/moderation/hideCase.ts index 2ed788a..38cfe31 100644 --- a/src/commands/moderation/hideCase.ts +++ b/src/commands/moderation/hideCase.ts @@ -20,10 +20,8 @@ export default class HideCaseCommand extends BushCommand { } } ], - userPermissions: (message) => { - return message.member?.permissions.has('MANAGE_MESSAGES') ? null : ['MANAGE_MESSAGES']; - }, - clientPermissions: ['SEND_MESSAGES'], + clientPermissions: (m) => util.clientSendAndPermCheck(m), + userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES']), slash: true, slashOptions: [ { diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts index 715483a..9bd5658 100644 --- a/src/commands/moderation/kick.ts +++ b/src/commands/moderation/kick.ts @@ -1,5 +1,5 @@ -import { AllowedMentions, BushCommand, BushGuildMember, BushMessage, BushSlashMessage, BushUser } from '@lib'; -import { Moderation } from '../../lib/common/moderation'; +import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage, BushUser } from '@lib'; +import { Moderation } from '../../lib/common/Moderation'; export default class KickCommand extends BushCommand { public constructor() { @@ -51,7 +51,7 @@ export default class KickCommand extends BushCommand { required: false } ], - clientPermissions: ['SEND_MESSAGES', 'KICK_MEMBERS'], + clientPermissions: (m) => util.clientSendAndPermCheck(m, ['KICK_MEMBERS']), userPermissions: ['KICK_MEMBERS'] }); } @@ -60,7 +60,7 @@ export default class KickCommand extends BushCommand { message: BushMessage | BushSlashMessage, { user, reason, force }: { user: BushUser; reason?: string; force: boolean } ): Promise<unknown> { - const member = message.guild!.members.cache.get(user.id) as BushGuildMember; + const member = await message.guild!.members.fetch(user.id); if (!member) return await message.util.reply( diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts index d5c6f91..eb37681 100644 --- a/src/commands/moderation/modlog.ts +++ b/src/commands/moderation/modlog.ts @@ -1,5 +1,6 @@ import { BushCommand, BushMessage, BushSlashMessage, BushUser, ModLog } from '@lib'; import { MessageEmbed, User } from 'discord.js'; +import { ButtonPaginator } from '../../lib/common/ButtonPaginator'; export default class ModlogCommand extends BushCommand { public constructor() { @@ -27,7 +28,8 @@ export default class ModlogCommand extends BushCommand { default: false } ], - userPermissions: [], + clientPermissions: (m) => util.clientSendAndPermCheck(m), + userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES']), slash: true, slashOptions: [ { @@ -62,10 +64,6 @@ export default class ModlogCommand extends BushCommand { message: BushMessage | BushSlashMessage, { search, hidden }: { search: BushUser | string; hidden: boolean } ): Promise<unknown> { - if (!message.member?.permissions.has('MANAGE_MESSAGES')) - return await message.util.reply( - `${util.emojis.error} You must have the **Manage Message** permission to use this command.` - ); const foundUser = search instanceof User ? search : await util.resolveUserAsync(search); if (foundUser) { const logs = await ModLog.findAll({ @@ -90,7 +88,7 @@ export default class ModlogCommand extends BushCommand { color: util.colors.default }) ); - return await util.buttonPaginate(message, embedPages, undefined, true); + return await ButtonPaginator.send(message, embedPages, undefined, true); } else if (search) { const entry = await ModLog.findByPk(search as string); if (!entry || entry.pseudo || (entry.hidden && !hidden)) @@ -102,7 +100,7 @@ export default class ModlogCommand extends BushCommand { description: this.#generateModlogInfo(entry, true), color: util.colors.default }; - return await util.buttonPaginate(message, [embed]); + return await ButtonPaginator.send(message, [embed]); } } } diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts index 942c0b0..03ecf2a 100644 --- a/src/commands/moderation/mute.ts +++ b/src/commands/moderation/mute.ts @@ -1,5 +1,5 @@ import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage, BushUser } from '@lib'; -import { Moderation } from '../../lib/common/moderation'; +import { Moderation } from '../../lib/common/Moderation'; export default class MuteCommand extends BushCommand { public constructor() { @@ -52,8 +52,8 @@ export default class MuteCommand extends BushCommand { } ], channel: 'guild', - clientPermissions: ['SEND_MESSAGES', 'MANAGE_ROLES'], - userPermissions: ['MANAGE_MESSAGES'] + clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_ROLES']), + userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES']) }); } @@ -66,7 +66,7 @@ export default class MuteCommand extends BushCommand { }: { user: BushUser; reason?: { duration: number | null; contentWithoutTime: string }; force: boolean } ): Promise<unknown> { if (reason?.duration === null) reason.duration = 0; - const member = message.guild!.members.cache.get(user.id); + const member = await message.guild!.members.fetch(user.id).catch(() => null); if (!member) return await message.util.reply( `${util.emojis.error} The user you selected is not in the server or is not a valid user.` diff --git a/src/commands/moderation/purge.ts b/src/commands/moderation/purge.ts index 062dad0..a77e46a 100644 --- a/src/commands/moderation/purge.ts +++ b/src/commands/moderation/purge.ts @@ -37,7 +37,7 @@ export default class PurgeCommand extends BushCommand { required: false } ], - clientPermissions: ['MANAGE_MESSAGES', 'SEND_MESSAGES', 'EMBED_LINKS'], + clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_MESSAGES', 'EMBED_LINKS'], true), userPermissions: ['MANAGE_MESSAGES'], channel: 'guild' }); diff --git a/src/commands/moderation/removeReactionEmoji.ts b/src/commands/moderation/removeReactionEmoji.ts index dc05883..63e20bd 100644 --- a/src/commands/moderation/removeReactionEmoji.ts +++ b/src/commands/moderation/removeReactionEmoji.ts @@ -11,8 +11,6 @@ export default class RemoveReactionEmojiCommand extends BushCommand { usage: 'remove-reaction-emoji <message> <emoji>', examples: ['remove-reaction-emoji 791413052347252786 <:omegaclown:782630946435366942>'] }, - clientPermissions: ['MANAGE_MESSAGES', 'SEND_MESSAGES', 'EMBED_LINKS'], - userPermissions: ['MANAGE_MESSAGES', 'MANAGE_EMOJIS_AND_STICKERS'], // Can't undo the removal of 1000s of reactions args: [ { id: 'messageToRemoveFrom', @@ -32,7 +30,9 @@ export default class RemoveReactionEmojiCommand extends BushCommand { } } ], - channel: 'guild' + 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 }); } diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts index c39864b..fe34d75 100644 --- a/src/commands/moderation/role.ts +++ b/src/commands/moderation/role.ts @@ -50,8 +50,8 @@ export default class RoleCommand extends BushCommand { ], channel: 'guild', typing: true, - clientPermissions: ['MANAGE_ROLES', 'EMBED_LINKS', 'SEND_MESSAGES'], - userPermissions: ['SEND_MESSAGES'] + clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_ROLES', 'EMBED_LINKS'], true), + userPermissions: [] }); } diff --git a/src/commands/moderation/slowmode.ts b/src/commands/moderation/slowmode.ts index 94e40ca..d90f122 100644 --- a/src/commands/moderation/slowmode.ts +++ b/src/commands/moderation/slowmode.ts @@ -42,8 +42,8 @@ export default class SlowModeCommand extends BushCommand { } ], channel: 'guild', - clientPermissions: ['MANAGE_CHANNELS', 'SEND_MESSAGES', 'EMBED_LINKS'], - userPermissions: ['MANAGE_MESSAGES', 'SEND_MESSAGES'] + clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_CHANNELS', 'EMBED_LINKS'], true), + userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES']) }); } diff --git a/src/commands/moderation/unban.ts b/src/commands/moderation/unban.ts index a319ff9..61e27cf 100644 --- a/src/commands/moderation/unban.ts +++ b/src/commands/moderation/unban.ts @@ -1,5 +1,4 @@ import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage, BushUser } from '@lib'; -import { User } from 'discord.js'; export default class UnbanCommand extends BushCommand { public constructor() { @@ -14,7 +13,7 @@ export default class UnbanCommand extends BushCommand { args: [ { id: 'user', - type: 'user', + type: 'globalUser', prompt: { start: 'What user would you like to unban?', retry: '{error} Choose a valid user to unban.' @@ -55,10 +54,6 @@ export default class UnbanCommand extends BushCommand { message: BushMessage | BushSlashMessage, { user, reason }: { user: BushUser; reason?: string } ): Promise<unknown> { - if (!(user instanceof User)) { - user = util.resolveUser(user, client.users.cache) as BushUser; - } - const responseCode = await message.guild!.bushUnban({ user, moderator: message.author, diff --git a/src/commands/moderation/unmute.ts b/src/commands/moderation/unmute.ts index 3d592b7..e430b83 100644 --- a/src/commands/moderation/unmute.ts +++ b/src/commands/moderation/unmute.ts @@ -1,5 +1,5 @@ import { AllowedMentions, BushCommand, BushGuildMember, BushMessage, BushSlashMessage, BushUser } from '@lib'; -import { Moderation } from '../../lib/common/moderation'; +import { Moderation } from '../../lib/common/Moderation'; export default class UnmuteCommand extends BushCommand { public constructor() { @@ -52,8 +52,8 @@ export default class UnmuteCommand extends BushCommand { } ], channel: 'guild', - clientPermissions: ['SEND_MESSAGES', 'MANAGE_ROLES'], - userPermissions: ['MANAGE_MESSAGES'] + clientPermissions: (m) => util.clientSendAndPermCheck(m, ['MANAGE_ROLES']), + userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES']) }); } diff --git a/src/commands/moderation/warn.ts b/src/commands/moderation/warn.ts index 3df4b3b..6ae8442 100644 --- a/src/commands/moderation/warn.ts +++ b/src/commands/moderation/warn.ts @@ -1,5 +1,5 @@ import { BushCommand, BushGuildMember, BushMessage, BushSlashMessage, BushUser } from '@lib'; -import { Moderation } from '../../lib/common/moderation'; +import { Moderation } from '../../lib/common/Moderation'; export default class WarnCommand extends BushCommand { public constructor() { @@ -51,8 +51,8 @@ export default class WarnCommand extends BushCommand { } ], channel: 'guild', - clientPermissions: ['SEND_MESSAGES'], - userPermissions: ['MANAGE_MESSAGES'] + clientPermissions: (m) => util.clientSendAndPermCheck(m), + userPermissions: (m) => util.userGuildPermCheck(m, ['MANAGE_MESSAGES']) }); } |