From 34f0d1d3ff3e2a90193c9a4d4de29d8335160d6a Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Fri, 2 Jul 2021 19:33:29 -0400 Subject: started restructuring moderation commands, note: nothing currently works :flushed: --- src/commands/moderation/kick.ts | 125 ++++++++++++++++++++-------------------- 1 file changed, 62 insertions(+), 63 deletions(-) (limited to 'src/commands/moderation/kick.ts') 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 ', - 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 { - 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 { + // 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 { - 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 { + 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 { - 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); + // } } } -- cgit