diff options
Diffstat (limited to 'src/commands/moderation')
-rw-r--r-- | src/commands/moderation/ban.ts | 21 | ||||
-rw-r--r-- | src/commands/moderation/kick.ts | 12 | ||||
-rw-r--r-- | src/commands/moderation/role.ts | 43 |
3 files changed, 55 insertions, 21 deletions
diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index e59a528..0d57203 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -70,7 +70,12 @@ export default class BanCommand extends BushCommand { ] }); } - async *genResponses(message: Message | CommandInteraction, user: User, reason?: string, time?: string): AsyncIterable<string> { + async *genResponses( + message: Message | CommandInteraction, + user: User, + reason?: string, + time?: string + ): AsyncIterable<string> { const duration = moment.duration(); let modlogEnry: Modlog; let banEntry: Ban; @@ -136,17 +141,21 @@ export default class BanCommand extends BushCommand { } try { await user.send( - `You were banned in ${message.guild.name} ${translatedTime.length >= 1 ? `for ${translatedTime.join(', ')}` : 'permanently'} with reason \`${ - reason || 'No reason given' - }\`` + `You were banned in ${message.guild.name} ${ + translatedTime.length >= 1 ? `for ${translatedTime.join(', ')}` : 'permanently' + } with reason \`${reason || 'No reason given'}\`` ); } catch (e) { yield 'Error sending message to user'; } await message.guild.members.ban(user, { - reason: `Banned by ${message instanceof CommandInteraction ? message.user.tag : message.author.tag} with ${reason ? `reason ${reason}` : 'no reason'}` + reason: `Banned by ${message instanceof CommandInteraction ? message.user.tag : message.author.tag} with ${ + reason ? `reason ${reason}` : 'no reason' + }` }); - yield `Banned <@!${user.id}> ${translatedTime.length >= 1 ? `for ${translatedTime.join(', ')}` : 'permanently'} with reason \`${reason || 'No reason given'}\``; + yield `Banned <@!${user.id}> ${ + translatedTime.length >= 1 ? `for ${translatedTime.join(', ')}` : 'permanently' + } with reason \`${reason || 'No reason given'}\``; } catch { yield 'Error banning :/'; await banEntry.destroy(); diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts index 182485a..c5581f6 100644 --- a/src/commands/moderation/kick.ts +++ b/src/commands/moderation/kick.ts @@ -46,7 +46,11 @@ export default class KickCommand extends BushCommand { }); } - private async *genResponses(message: Message | CommandInteraction, user: GuildMember, reason?: string): AsyncIterable<string> { + private async *genResponses( + message: Message | CommandInteraction, + user: GuildMember, + reason?: string + ): AsyncIterable<string> { let modlogEnry: Modlog; // Create guild entry so postgres doesn't get mad when I try and add a modlog entry await Guild.findOrCreate({ @@ -77,7 +81,11 @@ export default class KickCommand extends BushCommand { yield 'Error sending message to user'; } try { - await user.kick(`Kicked by ${message instanceof Message ? message.author.tag : message.user.tag} with ${reason ? `reason ${reason}` : 'no reason'}`); + await user.kick( + `Kicked by ${message instanceof Message ? message.author.tag : message.user.tag} with ${ + reason ? `reason ${reason}` : 'no reason' + }` + ); } catch { yield 'Error kicking :/'; await modlogEnry.destroy(); diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts index 0c7d7db..b01d578 100644 --- a/src/commands/moderation/role.ts +++ b/src/commands/moderation/role.ts @@ -77,17 +77,23 @@ export default class RoleCommand extends BushCommand { if (!message.member.permissions.has('MANAGE_ROLES') && !this.client.ownerID.includes(message.author.id)) { const mappedRole = this.client.util.moulberryBushRoleMap.find((m) => m.id === role.id); if (!mappedRole || !this.roleWhitelist[mappedRole.name]) { - return message.util.reply(`<:error:837123021016924261> <@&${role.id}> is not whitelisted, and you do not have manage roles permission.`, { - allowedMentions: AllowedMentions.none() - }); + return message.util.reply( + `<:error:837123021016924261> <@&${role.id}> is not whitelisted, and you do not have manage roles permission.`, + { + allowedMentions: AllowedMentions.none() + } + ); } const allowedRoles = this.roleWhitelist[mappedRole.name].map((r) => { return this.client.util.moulberryBushRoleMap.find((m) => m.name === r).id; }); if (!message.member.roles.cache.some((role) => allowedRoles.includes(role.id))) { - return message.util.reply(`<:error:837123021016924261> <@&${role.id}> is whitelisted, but you do not have any of the roles required to manage it.`, { - allowedMentions: AllowedMentions.none() - }); + return message.util.reply( + `<:error:837123021016924261> <@&${role.id}> is whitelisted, but you do not have any of the roles required to manage it.`, + { + allowedMentions: AllowedMentions.none() + } + ); } } if (!this.client.ownerID.includes(message.author.id)) { @@ -102,9 +108,12 @@ export default class RoleCommand extends BushCommand { }); } if (role.managed) { - await message.util.reply(`<:error:837123021016924261> <@&${role.id}> is managed by an integration and cannot be managed.`, { - allowedMentions: AllowedMentions.none() - }); + await message.util.reply( + `<:error:837123021016924261> <@&${role.id}> is managed by an integration and cannot be managed.`, + { + allowedMentions: AllowedMentions.none() + } + ); } } // No checks if the user has MANAGE_ROLES @@ -112,16 +121,24 @@ export default class RoleCommand extends BushCommand { try { await user.roles.remove(role.id); } catch { - return message.util.reply(`<:error:837123021016924261> Could not remove <@&${role.id}> from <@${user.id}>.`, { allowedMentions: AllowedMentions.none() }); + return message.util.reply(`<:error:837123021016924261> Could not remove <@&${role.id}> from <@${user.id}>.`, { + allowedMentions: AllowedMentions.none() + }); } - return message.util.reply(`<:checkmark:837109864101707807> Successfully removed <@&${role.id}> from <@${user.id}>!`, { allowedMentions: AllowedMentions.none() }); + return message.util.reply(`<:checkmark:837109864101707807> Successfully removed <@&${role.id}> from <@${user.id}>!`, { + allowedMentions: AllowedMentions.none() + }); } else { try { await user.roles.add(role.id); } catch { - return message.util.reply(`<:error:837123021016924261> Could not add <@&${role.id}> to <@${user.id}>.`, { allowedMentions: AllowedMentions.none() }); + return message.util.reply(`<:error:837123021016924261> Could not add <@&${role.id}> to <@${user.id}>.`, { + allowedMentions: AllowedMentions.none() + }); } - return message.util.reply(`<:checkmark:837109864101707807> Successfully added <@&${role.id}> to <@${user.id}>!`, { allowedMentions: AllowedMentions.none() }); + return message.util.reply(`<:checkmark:837109864101707807> Successfully added <@&${role.id}> to <@${user.id}>!`, { + allowedMentions: AllowedMentions.none() + }); } } } |