diff options
Diffstat (limited to 'src/commands/moderation/kick.ts')
-rw-r--r-- | src/commands/moderation/kick.ts | 40 |
1 files changed, 10 insertions, 30 deletions
diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts index f31047e..182485a 100644 --- a/src/commands/moderation/kick.ts +++ b/src/commands/moderation/kick.ts @@ -1,13 +1,14 @@ -import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BushCommand } from '../../lib/extensions/BushCommand'; import { Guild, Modlog, ModlogType } from '../../lib/models'; import { GuildMember, Message } from 'discord.js'; import { ApplicationCommandOptionType } from 'discord-api-types'; import { CommandInteraction } from 'discord.js'; -export default class KickCommand extends BotCommand { +export default class KickCommand extends BushCommand { constructor() { super('kick', { aliases: ['kick'], + category: 'moderation', args: [ { id: 'user', @@ -45,11 +46,7 @@ export default class KickCommand extends BotCommand { }); } - 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({ @@ -64,8 +61,7 @@ export default class KickCommand extends BotCommand { modlogEnry = Modlog.build({ user: user.id, guild: message.guild.id, - moderator: - message instanceof Message ? message.author.id : message.user.id, + moderator: message instanceof Message ? message.author.id : message.user.id, type: ModlogType.KICK, reason }); @@ -76,43 +72,27 @@ export default class KickCommand extends BotCommand { return; } try { - await user.send( - `You were kicked in ${message.guild.name} with reason \`${ - reason || 'No reason given' - }\`` - ); + await user.send(`You were kicked in ${message.guild.name} with reason \`${reason || 'No reason given'}\``); } catch (e) { 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(); return; } - yield `Kicked <@!${user.id}> with reason \`${ - reason || 'No reason given' - }\``; + yield `Kicked <@!${user.id}> with reason \`${reason || 'No reason given'}\``; } - async exec( - message: Message, - { user, reason }: { user: GuildMember; reason?: string } - ): Promise<void> { + async exec(message: Message, { user, reason }: { user: GuildMember; reason?: string }): Promise<void> { for await (const response of this.genResponses(message, user, reason)) { await message.util.send(response); } } - async execSlash( - message: CommandInteraction, - { user, reason }: { user: GuildMember; reason?: string } - ): Promise<void> { + async execSlash(message: CommandInteraction, { user, reason }: { user: GuildMember; reason?: string }): Promise<void> { for await (const response of this.genResponses(message, user, reason)) { await message.reply(response); } |