diff options
Diffstat (limited to 'src/commands/moderation')
-rw-r--r-- | src/commands/moderation/ban.ts | 18 | ||||
-rw-r--r-- | src/commands/moderation/kick.ts | 15 | ||||
-rw-r--r-- | src/commands/moderation/lockdown.ts | 4 | ||||
-rw-r--r-- | src/commands/moderation/modlog.ts | 19 | ||||
-rw-r--r-- | src/commands/moderation/mute.ts | 29 | ||||
-rw-r--r-- | src/commands/moderation/removeReactionEmoji.ts | 8 | ||||
-rw-r--r-- | src/commands/moderation/role.ts | 20 | ||||
-rw-r--r-- | src/commands/moderation/slowmode.ts | 12 | ||||
-rw-r--r-- | src/commands/moderation/unban.ts | 14 | ||||
-rw-r--r-- | src/commands/moderation/unmute.ts | 8 | ||||
-rw-r--r-- | src/commands/moderation/warn.ts | 10 |
11 files changed, 78 insertions, 79 deletions
diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index 874d5ed..27a0ffc 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -5,7 +5,7 @@ import { User } from 'discord.js'; export default class BanCommand extends BushCommand { public constructor() { super('ban', { - aliases: ['ban'], + aliases: ['ban', 'forceban'], category: 'moderation', description: { content: 'Ban a member from the server.', @@ -91,14 +91,14 @@ export default class BanCommand extends BushCommand { ): Promise<unknown> { const member = message.guild.members.cache.get(user.id) as BushGuildMember; const useForce = force && message.author.isOwner(); - const canModerateResponse = this.client.util.moderationPermissionCheck(message.member, member, 'ban', true, useForce); + const canModerateResponse = util.moderationPermissionCheck(message.member, member, 'ban', true, useForce); if (canModerateResponse !== true) { return message.util.reply(canModerateResponse); } if (!Number.isInteger(days) || days < 0 || days > 7) { - return message.util.reply(`${this.client.util.emojis.error} The delete days must be an integer between 0 and 7.`); + return message.util.reply(`${util.emojis.error} The delete days must be an integer between 0 and 7.`); } let time: number; @@ -120,17 +120,17 @@ export default class BanCommand extends BushCommand { const responseMessage = () => { switch (responseCode) { case 'missing permissions': - return `${this.client.util.emojis.error} Could not ban **${member.user.tag}** because I do not have permissions`; + return `${util.emojis.error} Could not ban **${member.user.tag}** because I do not have permissions`; case 'error banning': - return `${this.client.util.emojis.error} An error occurred while trying to ban **${member.user.tag}**.`; + return `${util.emojis.error} An error occurred while trying to ban **${member.user.tag}**.`; case 'error creating ban entry': - return `${this.client.util.emojis.error} While banning **${member.user.tag}**, there was an error creating a ban entry, please report this to my developers.`; + return `${util.emojis.error} While banning **${member.user.tag}**, there was an error creating a ban entry, please report this to my developers.`; case 'error creating modlog entry': - return `${this.client.util.emojis.error} While banning **${member.user.tag}**, there was an error creating a modlog entry, please report this to my developers.`; + return `${util.emojis.error} While banning **${member.user.tag}**, there was an error creating a modlog entry, please report this to my developers.`; case 'failed to dm': - return `${this.client.util.emojis.warn} Banned **${member.user.tag}** however I could not send them a dm.`; + return `${util.emojis.warn} Banned **${member.user.tag}** however I could not send them a dm.`; case 'success': - return `${this.client.util.emojis.success} Successfully banned **${member.user.tag}**.`; + return `${util.emojis.success} Successfully banned **${member.user.tag}**.`; } }; return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() }); diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts index 74ace94..bc7d9d2 100644 --- a/src/commands/moderation/kick.ts +++ b/src/commands/moderation/kick.ts @@ -60,8 +60,11 @@ export default class KickCommand extends BushCommand { { user, reason, force }: { user: BushUser; reason?: string; force: boolean } ): Promise<unknown> { const member = message.guild.members.cache.get(user.id) as BushGuildMember; + + if (!member) message.util.reply(`${util.emojis.error} You cannot kick members that are not in the server.`); + const useForce = force && message.author.isOwner(); - const canModerateResponse = this.client.util.moderationPermissionCheck(message.member, member, 'kick', true, useForce); + const canModerateResponse = util.moderationPermissionCheck(message.member, member, 'kick', true, useForce); if (canModerateResponse !== true) { return message.util.reply(canModerateResponse); @@ -75,15 +78,15 @@ export default class KickCommand extends BushCommand { const responseMessage = () => { switch (responseCode) { case 'missing permissions': - return `${this.client.util.emojis.error} Could not kick **${member.user.tag}** because I am missing the \`Kick Members\` permission.`; + return `${util.emojis.error} Could not kick **${member.user.tag}** because I am missing the \`Kick Members\` permission.`; case 'error kicking': - return `${this.client.util.emojis.error} An error occurred while trying to kick **${member.user.tag}**.`; + return `${util.emojis.error} An error occurred while trying to kick **${member.user.tag}**.`; case 'error creating modlog entry': - return `${this.client.util.emojis.error} While muting **${member.user.tag}**, there was an error creating a modlog entry, please report this to my developers.`; + return `${util.emojis.error} While muting **${member.user.tag}**, there was an error creating a modlog entry, please report this to my developers.`; case 'failed to dm': - return `${this.client.util.emojis.warn} Kicked **${member.user.tag}** however I could not send them a dm.`; + return `${util.emojis.warn} Kicked **${member.user.tag}** however I could not send them a dm.`; case 'success': - return `${this.client.util.emojis.success} Successfully kicked **${member.user.tag}**.`; + return `${util.emojis.success} Successfully kicked **${member.user.tag}**.`; } }; 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 e67d110..4eaeceb 100644 --- a/src/commands/moderation/lockdown.ts +++ b/src/commands/moderation/lockdown.ts @@ -35,8 +35,8 @@ export default class LockdownCommand extends BushCommand { return await message.util.reply('no'); if (!all) { if (!['GUILD_TEXT', 'GUILD_NEWS'].includes(message.channel.type)) - return message.util.reply(`${this.client.util.emojis.error} You can only lock down text and announcement channels.`); - const lockdownSuccess = await this.client.util.lockdownChannel({ + return message.util.reply(`${util.emojis.error} You can only lock down text and announcement channels.`); + const lockdownSuccess = await util.lockdownChannel({ channel: message.channel as BushTextChannel | BushNewsChannel, moderator: message.author }); diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts index e3da45f..c55b9a3 100644 --- a/src/commands/moderation/modlog.ts +++ b/src/commands/moderation/modlog.ts @@ -42,13 +42,13 @@ export default class ModlogCommand extends BushCommand { `**User**: <@!${log.user}> (${log.user})`, `**Moderator**: <@!${log.moderator}> (${log.moderator})` ]; - if (log.duration) modLog.push(`**Duration**: ${this.client.util.humanizeDuration(log.duration)}`); + if (log.duration) modLog.push(`**Duration**: ${util.humanizeDuration(log.duration)}`); modLog.push(`**Reason**: ${log.reason || 'No Reason Specified.'}`); return modLog.join(`\n`); } async exec(message: BushMessage | BushSlashMessage, { search }: { search: BushUser | string }): Promise<unknown> { - const foundUser = search instanceof User ? search : await this.client.util.resolveUserAsync(search); + const foundUser = search instanceof User ? search : await util.resolveUserAsync(search); if (foundUser) { const logs = await ModLog.findAll({ where: { @@ -57,31 +57,30 @@ export default class ModlogCommand extends BushCommand { }, order: [['createdAt', 'ASC']] }); - if (!logs.length) - return message.util.reply(`${this.client.util.emojis.error} **${foundUser.tag}** does not have any modlogs.`); + if (!logs.length) return message.util.reply(`${util.emojis.error} **${foundUser.tag}** does not have any modlogs.`); const niceLogs: string[] = []; for (const log of logs) { niceLogs.push(this.generateModlogInfo(log)); } - const chunked: string[][] = this.client.util.chunk(niceLogs, 3); + const chunked: string[][] = util.chunk(niceLogs, 3); const embedPages = chunked.map( (chunk) => new MessageEmbed({ title: `${foundUser.tag}'s Mod Logs`, description: chunk.join('\n**―――――――――――――――――――――――――――**\n'), - color: this.client.util.colors.default + color: util.colors.default }) ); - return await this.client.util.buttonPaginate(message, embedPages, '', true); + return await util.buttonPaginate(message, embedPages, '', true); } else if (search) { const entry = await ModLog.findByPk(search as string); - if (!entry) return message.util.send(`${this.client.util.emojis.error} That modlog does not exist.`); + if (!entry) return message.util.send(`${util.emojis.error} That modlog does not exist.`); const embed = new MessageEmbed({ title: `Case ${entry.id}`, description: this.generateModlogInfo(entry), - color: this.client.util.colors.default + color: util.colors.default }); - return await this.client.util.buttonPaginate(message, [embed]); + return await util.buttonPaginate(message, [embed]); } } } diff --git a/src/commands/moderation/mute.ts b/src/commands/moderation/mute.ts index 2004eb8..0b10ee1 100644 --- a/src/commands/moderation/mute.ts +++ b/src/commands/moderation/mute.ts @@ -60,10 +60,11 @@ export default class MuteCommand extends BushCommand { message: BushMessage | BushSlashMessage, { user, reason, force }: { user: BushUser; reason?: { duration: number; contentWithoutTime: string }; force: boolean } ): Promise<unknown> { - const error = this.client.util.emojis.error; const member = message.guild.members.cache.get(user.id) as BushGuildMember; + if (!member) message.util.reply(`${util.emojis.error} You cannot kick members that are not in the server.`); + const useForce = force && message.author.isOwner(); - const canModerateResponse = this.client.util.moderationPermissionCheck(message.member, member, 'mute', true, useForce); + const canModerateResponse = util.moderationPermissionCheck(message.member, member, 'mute', true, useForce); const victimBoldTag = `**${member.user.tag}**`; if (canModerateResponse !== true) { @@ -85,29 +86,29 @@ export default class MuteCommand extends BushCommand { duration: time }); - const responseMessage = () => { - const prefix = message.guild.getSetting('prefix'); + const responseMessage = async () => { + const prefix = await message.guild.getSetting('prefix'); switch (responseCode) { case 'missing permissions': - return `${error} Could not mute ${victimBoldTag} because I am missing the \`Manage Roles\` permission.`; + return `${util.emojis.error} Could not mute ${victimBoldTag} because I am missing the \`Manage Roles\` permission.`; case 'no mute role': - return `${error} Could not mute ${victimBoldTag}, you must set a mute role with \`${prefix}muterole\`.`; + return `${util.emojis.error} Could not mute ${victimBoldTag}, you must set a mute role with \`${prefix}muterole\`.`; case 'invalid mute role': - return `${error} Could not mute ${victimBoldTag} because the current mute role no longer exists. Please set a new mute role with \`${prefix}muterole\`.`; + return `${util.emojis.error} Could not mute ${victimBoldTag} because the current mute role no longer exists. Please set a new mute role with \`${prefix}muterole\`.`; case 'mute role not manageable': - return `${error} Could not mute ${victimBoldTag} because I cannot assign the current mute role, either change the role's position or set a new mute role with \`${prefix}muterole\`.`; + return `${util.emojis.error} Could not mute ${victimBoldTag} because I cannot assign the current mute role, either change the role's position or set a new mute role with \`${prefix}muterole\`.`; case 'error giving mute role': - return `${error} Could not mute ${victimBoldTag}, there was an error assigning them the mute role.`; + return `${util.emojis.error} Could not mute ${victimBoldTag}, there was an error assigning them the mute role.`; case 'error creating modlog entry': - return `${error} There was an error creating a modlog entry, please report this to my developers.`; + return `${util.emojis.error} There was an error creating a modlog entry, please report this to my developers.`; case 'error creating mute entry': - return `${error} There was an error creating a punishment entry, please report this to my developers.`; + return `${util.emojis.error} There was an error creating a punishment entry, please report this to my developers.`; case 'failed to dm': - return `${this.client.util.emojis.warn} Muted **${member.user.tag}** however I could not send them a dm.`; + return `${util.emojis.warn} Muted **${member.user.tag}** however I could not send them a dm.`; case 'success': - return `${this.client.util.emojis.success} Successfully muted **${member.user.tag}**.`; + return `${util.emojis.success} Successfully muted **${member.user.tag}**.`; } }; - return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() }); + return await message.util.reply({ content: await responseMessage(), allowedMentions: AllowedMentions.none() }); } } diff --git a/src/commands/moderation/removeReactionEmoji.ts b/src/commands/moderation/removeReactionEmoji.ts index b0079c6..cb1be04 100644 --- a/src/commands/moderation/removeReactionEmoji.ts +++ b/src/commands/moderation/removeReactionEmoji.ts @@ -49,13 +49,13 @@ export default class RemoveReactionEmojiCommand extends BushCommand { .catch(() => {}); if (success) { return await message.util.reply( - `${this.client.util.emojis.success} Removed all reactions of \`${ - id ? emojiID : emoji - }\` from the message with the id of \`${messageToRemoveFrom.id}\`.` + `${util.emojis.success} Removed all reactions of \`${id ? emojiID : emoji}\` from the message with the id of \`${ + messageToRemoveFrom.id + }\`.` ); } else { return await message.util.reply( - `${this.client.util.emojis.error} There was an error removing all reactions of \`${ + `${util.emojis.error} There was an error removing all reactions of \`${ id ? emojiID : emoji }\` from the message with the id of \`${messageToRemoveFrom.id}\`.` ); diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts index 3470ab9..63fb3a2 100644 --- a/src/commands/moderation/role.ts +++ b/src/commands/moderation/role.ts @@ -103,7 +103,7 @@ export default class RoleCommand extends BushCommand { } if (!mappedRole || !mappings.roleWhitelist[mappedRole.name]) { return await message.util.reply({ - content: `${this.client.util.emojis.error} <@&${role.id}> is not whitelisted, and you do not have manage roles permission.`, + content: `${util.emojis.error} <@&${role.id}> is not whitelisted, and you do not have manage roles permission.`, allowedMentions: AllowedMentions.none() }); } @@ -115,7 +115,7 @@ export default class RoleCommand extends BushCommand { }); if (!message.member.roles.cache.some((role) => allowedRoles.includes(role.id))) { return await message.util.reply({ - content: `${this.client.util.emojis.error} <@&${role.id}> is whitelisted, but you do not have any of the roles required to manage it.`, + content: `${util.emojis.error} <@&${role.id}> is whitelisted, but you do not have any of the roles required to manage it.`, allowedMentions: AllowedMentions.none() }); } @@ -131,25 +131,25 @@ export default class RoleCommand extends BushCommand { const responseMessage = () => { switch (responseCode) { case 'user hierarchy': - return `${this.client.util.emojis.error} <@&${role.id}> is higher or equal to your highest role.`; + return `${util.emojis.error} <@&${role.id}> is higher or equal to your highest role.`; case 'role managed': - return `${this.client.util.emojis.error} <@&${role.id}> is managed by an integration and cannot be managed.`; + return `${util.emojis.error} <@&${role.id}> is managed by an integration and cannot be managed.`; case 'client hierarchy': - return `${this.client.util.emojis.error} <@&${role.id}> is higher or equal to my highest role.`; + return `${util.emojis.error} <@&${role.id}> is higher or equal to my highest role.`; case 'error creating modlog entry': - return `${this.client.util.emojis.error} There was an error creating a modlog entry, please report this to my developers.`; + return `${util.emojis.error} There was an error creating a modlog entry, please report this to my developers.`; case 'error creating role entry' || 'error removing role entry': - return `${this.client.util.emojis.error} There was an error ${ + return `${util.emojis.error} There was an error ${ action === 'add' ? 'creating' : 'removing' } a punishment entry, please report this to my developers.`; case 'error adding role' || 'error removing role': - return `${this.client.util.emojis.error} An error occurred while trying to ${action} <@&${role.id}> ${ + return `${util.emojis.error} An error occurred while trying to ${action} <@&${role.id}> ${ action === 'add' ? 'to' : 'from' } **${user.user.tag}**.`; case 'success': - return `${this.client.util.emojis.success} Successfully ${action === 'add' ? 'added' : 'removed'} <@&${role.id}> ${ + return `${util.emojis.success} Successfully ${action === 'add' ? 'added' : 'removed'} <@&${role.id}> ${ action === 'add' ? 'to' : 'from' - } **${user.user.tag}**${duration ? ` for ${this.client.util.humanizeDuration(duration)}` : ''}.`; + } **${user.user.tag}**${duration ? ` for ${util.humanizeDuration(duration)}` : ''}.`; } }; diff --git a/src/commands/moderation/slowmode.ts b/src/commands/moderation/slowmode.ts index 8384562..019e545 100644 --- a/src/commands/moderation/slowmode.ts +++ b/src/commands/moderation/slowmode.ts @@ -54,10 +54,10 @@ export default class SlowModeCommand extends BushCommand { { length, channel }: { length: number | 'off' | 'none' | 'disable'; channel: TextChannel | ThreadChannel } ): Promise<unknown> { if (message.channel.type === 'DM') - return await message.util.reply(`${this.client.util.emojis.error} This command cannot be run in dms.`); + return await message.util.reply(`${util.emojis.error} This command cannot be run in dms.`); if (!channel) channel = message.channel as ThreadChannel | TextChannel; if (!(channel instanceof TextChannel) || !(channel instanceof ThreadChannel)) - return await message.util.reply(`${this.client.util.emojis.error} <#${channel.id}> is not a text or thread channel.`); + return await message.util.reply(`${util.emojis.error} <#${channel.id}> is not a text or thread channel.`); if (length) { length = typeof length === 'string' && !['off', 'none', 'disable'].includes(length) @@ -73,14 +73,12 @@ export default class SlowModeCommand extends BushCommand { .catch(() => {}); if (!setSlowmode) return await message.util.reply( - `${this.client.util.emojis.error} There was an error changing the slowmode of <#${ - (channel as ThreadChannel | TextChannel).id - }>.` + `${util.emojis.error} There was an error changing the slowmode of <#${(channel as ThreadChannel | TextChannel).id}>.` ); else return await message.util.reply( - `${this.client.util.emojis.success} Successfully changed the slowmode of ${channel} ${ - length2 ? `to \`${this.client.util.humanizeDuration(length2)}` : '`off' + `${util.emojis.success} Successfully changed the slowmode of ${channel} ${ + length2 ? `to \`${util.humanizeDuration(length2)}` : '`off' }\`.` ); } diff --git a/src/commands/moderation/unban.ts b/src/commands/moderation/unban.ts index 0de2489..26878d9 100644 --- a/src/commands/moderation/unban.ts +++ b/src/commands/moderation/unban.ts @@ -53,7 +53,7 @@ export default class UnbanCommand extends BushCommand { } async exec(message: BushMessage | BushSlashMessage, { user, reason }: { user: User; reason?: string }): Promise<unknown> { if (!(user instanceof User)) { - user = this.client.util.resolveUser(user, this.client.users.cache); + user = util.resolveUser(user, this.client.users.cache); } const responseCode = await message.guild.unban({ user, @@ -64,17 +64,17 @@ export default class UnbanCommand extends BushCommand { const responseMessage = () => { switch (responseCode) { case 'missing permissions': - return `${this.client.util.emojis.error} Could not unban **${user.tag}** because I do not have permissions`; + return `${util.emojis.error} Could not unban **${user.tag}** because I do not have permissions`; case 'error unbanning': - return `${this.client.util.emojis.error} An error occurred while trying to unban **${user.tag}**.`; + return `${util.emojis.error} An error occurred while trying to unban **${user.tag}**.`; case 'error removing ban entry': - return `${this.client.util.emojis.error} While unbanning **${user.tag}**, there was an error removing their ban entry, please report this to my developers.`; + return `${util.emojis.error} While unbanning **${user.tag}**, there was an error removing their ban entry, please report this to my developers.`; case 'error creating modlog entry': - return `${this.client.util.emojis.error} While unbanning **${user.tag}**, there was an error creating a modlog entry, please report this to my developers.`; + return `${util.emojis.error} While unbanning **${user.tag}**, there was an error creating a modlog entry, please report this to my developers.`; case 'user not banned': - return `${this.client.util.emojis.warn} **${user.tag}** but I tried to unban them anyways.`; + return `${util.emojis.warn} **${user.tag}** but I tried to unban them anyways.`; case 'success': - return `${this.client.util.emojis.success} Successfully unbanned **${user.tag}**.`; + return `${util.emojis.success} Successfully unbanned **${user.tag}**.`; } }; return await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() }); diff --git a/src/commands/moderation/unmute.ts b/src/commands/moderation/unmute.ts index 277ca91..807cf2c 100644 --- a/src/commands/moderation/unmute.ts +++ b/src/commands/moderation/unmute.ts @@ -51,9 +51,9 @@ export default class UnmuteCommand extends BushCommand { }); } async exec(message: BushMessage | BushSlashMessage, { user, reason }: { user: BushUser; reason?: string }): Promise<unknown> { - const error = this.client.util.emojis.error; + const error = util.emojis.error; const member = message.guild.members.cache.get(user.id) as BushGuildMember; - const canModerateResponse = this.client.util.moderationPermissionCheck(message.member, member, 'unmute'); + const canModerateResponse = util.moderationPermissionCheck(message.member, member, 'unmute'); const victimBoldTag = `**${member.user.tag}**`; if (canModerateResponse !== true) { @@ -83,9 +83,9 @@ export default class UnmuteCommand extends BushCommand { case 'error removing mute entry': return `${error} While muting ${victimBoldTag}, there was an error removing their mute entry, please report this to my developers.`; case 'failed to dm': - return `${this.client.util.emojis.warn} unmuted **${member.user.tag}** however I could not send them a dm.`; + return `${util.emojis.warn} unmuted **${member.user.tag}** however I could not send them a dm.`; case 'success': - return `${this.client.util.emojis.success} Successfully unmuted **${member.user.tag}**.`; + return `${util.emojis.success} Successfully unmuted **${member.user.tag}**.`; } }; 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 d5bf009..c5b4f43 100644 --- a/src/commands/moderation/warn.ts +++ b/src/commands/moderation/warn.ts @@ -61,7 +61,7 @@ export default class WarnCommand extends BushCommand { ): Promise<unknown> { const member = message.guild.members.cache.get(user.id) as BushGuildMember; const useForce = force && message.author.isOwner(); - const canModerateResponse = this.client.util.moderationPermissionCheck(message.member, member, 'warn', true, useForce); + const canModerateResponse = util.moderationPermissionCheck(message.member, member, 'warn', true, useForce); const victimBoldTag = `**${member.user.tag}**`; if (canModerateResponse !== true) { @@ -76,19 +76,17 @@ export default class WarnCommand extends BushCommand { switch (response) { case 'error creating modlog entry': return message.util.reply( - `${this.client.util.emojis.error} While warning ${victimBoldTag}, there was an error creating a modlog entry, please report this to my developers.` + `${util.emojis.error} While warning ${victimBoldTag}, there was an error creating a modlog entry, please report this to my developers.` ); case 'failed to dm': return message.util.reply( - `${this.client.util.emojis.warn} **${member.user.tag}** has been warned for the ${this.client.util.ordinal( + `${util.emojis.warn} **${member.user.tag}** has been warned for the ${util.ordinal( caseNum )} time, however I could not send them a dm.` ); case 'success': return message.util.reply( - `${this.client.util.emojis.success} Successfully warned **${member.user.tag}** for the ${this.client.util.ordinal( - caseNum - )} time.` + `${util.emojis.success} Successfully warned **${member.user.tag}** for the ${util.ordinal(caseNum)} time.` ); } } |