From 48661511dd485957506e7900c8e86916aa3ea3af Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sun, 29 Aug 2021 23:05:39 -0400 Subject: the config command is basically done for now --- src/commands/config/config.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/commands/config/config.ts') diff --git a/src/commands/config/config.ts b/src/commands/config/config.ts index 2a17883..df650fe 100644 --- a/src/commands/config/config.ts +++ b/src/commands/config/config.ts @@ -170,11 +170,11 @@ export default class SettingsCommand extends BushCommand { public override async exec( message: BushMessage | BushSlashMessage, args: { - [x in GuildSettings | ('view' | 'set' | 'add' | 'remove') | ('setting' | 'action') | 'value']: - | string - | undefined - | Channel - | Role; + setting?: GuildSettings; + subcommandGroup?: GuildSettings; + action?: 'view' | 'add' | 'remove' | 'set'; + subcommand?: 'view' | 'add' | 'remove' | 'set'; + value: string | Channel | Role; } ): Promise { if (!message.guild) return await message.util.reply(`${util.emojis.error} This command can only be used in servers.`); @@ -182,14 +182,14 @@ export default class SettingsCommand extends BushCommand { return await message.util.reply( `${util.emojis.error} You must have the **MANAGE_GUILD** permissions to run this command.` ); - const setting = _.camelCase(args[settingsArr.find((s) => args[s]) ?? 'setting'] as string | undefined) as - | GuildSettings - | undefined; - const action = (args[ - (['view', 'set', 'add', 'remove'] as ('view' | 'set' | 'add' | 'remove')[]).find((a) => args[a]) ?? 'action' - ] ?? 'view') as 'view' | 'set' | 'add' | 'remove'; + const setting = message.util.isSlash ? (_.camelCase(args.subcommandGroup)! as GuildSettings) : args.setting!; + const action = message.util.isSlash ? args.subcommand! : args.action!; const value = args.value; + client.console.debug(setting); + client.console.debug(action); + client.console.debug(value); + let msg; if (!setting || action === 'view') { @@ -219,13 +219,13 @@ export default class SettingsCommand extends BushCommand { const existing = (await message.guild.getSetting(setting)) as string[]; const updated = util.addOrRemoveFromArray('add', existing, parseVal(value)); await message.guild.setSetting(setting, updated); - const messageOptions = await this.generateMessageOptions(message); + const messageOptions = await this.generateMessageOptions(message, setting); msg = (await message.util.reply(messageOptions)) as Message; break; } case 'set': { await message.guild.setSetting(setting, parseVal(value)); - const messageOptions = await this.generateMessageOptions(message); + const messageOptions = await this.generateMessageOptions(message, setting); msg = (await message.util.reply(messageOptions)) as Message; break; } -- cgit