diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-08-29 23:05:39 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-08-29 23:05:39 -0400 |
commit | 48661511dd485957506e7900c8e86916aa3ea3af (patch) | |
tree | a32447c7899eea73eff004b31a0454817afac356 /src/commands/config/config.ts | |
parent | f1353ac5735158bca58a50535f43ff1561cf1e07 (diff) | |
download | tanzanite-48661511dd485957506e7900c8e86916aa3ea3af.tar.gz tanzanite-48661511dd485957506e7900c8e86916aa3ea3af.tar.bz2 tanzanite-48661511dd485957506e7900c8e86916aa3ea3af.zip |
the config command is basically done for now
Diffstat (limited to 'src/commands/config/config.ts')
-rw-r--r-- | src/commands/config/config.ts | 26 |
1 files changed, 13 insertions, 13 deletions
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<unknown> { 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; } |