diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-02 19:33:29 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-02 19:33:29 -0400 |
commit | 34f0d1d3ff3e2a90193c9a4d4de29d8335160d6a (patch) | |
tree | f5a069b332b649f510aac741ae2484e853efc6a2 /src/commands/moderation/kick.ts | |
parent | 6c3ab0e2e4239a2122d1d8ce8ed7bc9673fdde6a (diff) | |
download | tanzanite-34f0d1d3ff3e2a90193c9a4d4de29d8335160d6a.tar.gz tanzanite-34f0d1d3ff3e2a90193c9a4d4de29d8335160d6a.tar.bz2 tanzanite-34f0d1d3ff3e2a90193c9a4d4de29d8335160d6a.zip |
started restructuring moderation commands,
note: nothing currently works :flushed:
Diffstat (limited to 'src/commands/moderation/kick.ts')
-rw-r--r-- | src/commands/moderation/kick.ts | 125 |
1 files changed, 62 insertions, 63 deletions
diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts index 09d6abf..df538bc 100644 --- a/src/commands/moderation/kick.ts +++ b/src/commands/moderation/kick.ts @@ -1,7 +1,5 @@ -import { CommandInteraction, GuildMember, Message } from 'discord.js'; +import { GuildMember, Message } from 'discord.js'; import { BushCommand } from '../../lib/extensions/discord-akairo/BushCommand'; -import { BushSlashMessage } from '../../lib/extensions/discord-akairo/BushSlashMessage'; -import { Guild, ModLog, ModLogType } from '../../lib/models'; export default class KickCommand extends BushCommand { public constructor() { @@ -20,7 +18,12 @@ export default class KickCommand extends BushCommand { { id: 'reason', type: 'string', - match: 'restContent' + match: 'restContent', + prompt: { + start: 'Why would you like to kick this user?', + retry: '{error} Choose a valid user to kick.', + optional: true + } } ], clientPermissions: ['KICK_MEMBERS'], @@ -28,19 +31,19 @@ export default class KickCommand extends BushCommand { description: { content: 'Kick a member from the server.', usage: 'kick <member> <reason>', - examples: ['kick @Tyman being cool'] + examples: ['kick @user bad'] }, slashOptions: [ { type: 'USER', name: 'user', - description: 'The user to kick', + description: 'What user would you like to kick?', required: true }, { type: 'STRING', name: 'reason', - description: 'The reason to show in modlogs and audit log', + description: 'Why would you like to kick this user?', required: false } ], @@ -48,63 +51,59 @@ export default class KickCommand extends BushCommand { }); } - 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({ - where: { - id: message.guild.id - }, - defaults: { - id: message.guild.id - } - }); - try { - modlogEnry = ModLog.build({ - user: user.id, - guild: message.guild.id, - moderator: message instanceof Message ? message.author.id : message.user.id, - type: ModLogType.KICK, - reason - }); - await modlogEnry.save(); - } catch (e) { - this.client.console.error(`KickCommand`, `Error saving to database. ${e?.stack}`); - yield `${this.client.util.emojis.error} Error saving to database. Please report this to a developer.`; - return; - } - try { - await user.send(`You were kicked in ${message.guild.name} with reason \`${reason || 'No reason given'}\``); - } catch (e) { - yield `${this.client.util.emojis.warn} Unable to dm user`; - } - try { - await user.kick( - `Kicked by ${message instanceof Message ? message.author.tag : message.user.tag} with ${ - reason ? `reason ${reason}` : 'no reason' - }` - ); - } catch { - yield `${this.client.util.emojis.error} Error kicking :/`; - await modlogEnry.destroy(); - return; - } - yield `${this.client.util.emojis.success} Kicked <@!${user.id}> with reason \`${reason || 'No reason given'}\``; - } + // 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({ + // where: { + // id: message.guild.id + // }, + // defaults: { + // id: message.guild.id + // } + // }); + // try { + // modlogEnry = ModLog.build({ + // user: user.id, + // guild: message.guild.id, + // moderator: message instanceof Message ? message.author.id : message.user.id, + // type: ModLogType.KICK, + // reason + // }); + // await modlogEnry.save(); + // } catch (e) { + // this.client.console.error(`KickCommand`, `Error saving to database. ${e?.stack}`); + // yield `${this.client.util.emojis.error} Error saving to database. Please report this to a developer.`; + // return; + // } + // try { + // await user.send(`You were kicked in ${message.guild.name} with reason \`${reason || 'No reason given'}\``); + // } catch (e) { + // yield `${this.client.util.emojis.warn} Unable to dm user`; + // } + // try { + // await user.kick( + // `Kicked by ${message instanceof Message ? message.author.tag : message.user.tag} with ${ + // reason ? `reason ${reason}` : 'no reason' + // }` + // ); + // } catch { + // yield `${this.client.util.emojis.error} Error kicking :/`; + // await modlogEnry.destroy(); + // return; + // } + // yield `${this.client.util.emojis.success} Kicked <@!${user.id}> with reason \`${reason || 'No reason given'}\``; + // } - 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 exec(message: Message, { user, reason }: { user: GuildMember; reason?: string }): Promise<unknown> { + return message.util.reply(`${this.client.util.emojis.error} This command is not finished.`); - async execSlash(message: BushSlashMessage, { user, reason }: { user: GuildMember; reason?: string }): Promise<void> { - for await (const response of this.genResponses(message.interaction, user, reason)) { - await message.interaction.reply(response); - } + // for await (const response of this.genResponses(message, user, reason)) { + // await message.util.send(response); + // } } } |