diff --git a/src/client/DiscordClient.ts b/src/client/DiscordClient.ts index 84d83e8..c16a563 100644 --- a/src/client/DiscordClient.ts +++ b/src/client/DiscordClient.ts @@ -231,10 +231,10 @@ class DiscordClient extends Client // Needs to load in after connecting to discord await this.#moderationManager.initialise(); - this.#setActivity(); + this.setActivity(); this.#activityInterval = setInterval(() => { - this.#setActivity(); + this.setActivity(); }, Util.random(5, 10) * 60 * 60 * 1000); this.#built = true; @@ -341,7 +341,7 @@ class DiscordClient extends Client return this.#options.logger; } - async #setActivity () + async setActivity () { if (!this.shard || !this.user) throw new Error('Missing shard or user'); diff --git a/src/client/components/commands/administration/Moderation.ts b/src/client/components/commands/administration/Moderation.ts index 3ffb934..b43b55d 100644 --- a/src/client/components/commands/administration/Moderation.ts +++ b/src/client/components/commands/administration/Moderation.ts @@ -7,6 +7,7 @@ class ModerationModule extends SettingsCommand { super(client, { name: 'moderation', + aliases: [ 'mod' ], description: 'Configure the moderation settings', moduleName: 'administration' }); diff --git a/src/client/components/commands/information/Commands.ts b/src/client/components/commands/information/Commands.ts index 3cb2e81..a17ba9d 100644 --- a/src/client/components/commands/information/Commands.ts +++ b/src/client/components/commands/information/Commands.ts @@ -23,20 +23,22 @@ class Commands extends SlashCommand description: [ 'List commands from a specific module' ] }], memberPermissions: [], - guildOnly: true + // guildOnly: true }); } async execute (invoker: InvokerWrapper, { module }: CommandParams) { - const guild = invoker.guild!; - const settings = await guild.settings(); - const { commands: { disabled } } = settings; + const { guild } = invoker; + const settings = await guild?.settings(); + let disabled: string[] = []; + if (settings) + ({ commands: { disabled } } = settings); + let commands: Collection | null = null; if (module) commands = module.asModule.components.filter((c): c is Command => c.type === 'command'); - // eslint-disable-next-line prefer-destructuring else ({ commands } = this.client.registry); const amt = commands.size; @@ -49,12 +51,12 @@ class Commands extends SlashCommand const _module = command.module.name; if (!modules[_module]) modules[_module] = []; - const emoji = disabled?.includes(command.resolveable) ? Emojis.failure : Emojis.success; + const emoji = disabled?.includes(command.resolveable) || !guild && command.guildOnly ? Emojis.failure : Emojis.success; modules[_module].push(`${emoji} ${Util.capitalise(command.name)}`); } const embed: APIEmbed = { - title: guild.format('COMMAND_COMMANDS_TITLE'), + title: invoker.format('COMMAND_COMMANDS_TITLE'), fields: [], footer: { text: `• ${amt} commands` } }; diff --git a/src/client/components/observers/CommandHandler.ts b/src/client/components/observers/CommandHandler.ts index 5d1a4ac..4764eee 100644 --- a/src/client/components/observers/CommandHandler.ts +++ b/src/client/components/observers/CommandHandler.ts @@ -464,14 +464,13 @@ class CommandHandler extends Observer // Clean up params for option parsing for (const flag of Object.values(args)) { - // console.log('flags loop', flag.name, flag._rawValue); + // console.log('flags loop', flag.name, flag.rawValue); const removed = await flag.parse(); + // console.log(removed); if (!(removed instanceof Array) && removed.error) { if (flag.choices.length) - { return { error: true, index: 'O_COMMANDHANDLER_INVALID_CHOICE', params: { option: flag.name, value: flag.rawValue as string, choices: flag.choices.map((c) => c.value).join('`, `') } }; - } return { option: flag, ...removed }; } for (const r of removed as string[]) @@ -512,7 +511,8 @@ class CommandHandler extends Observer } cloned.rawValue = params[index]; removed = await cloned.parse(); - if (!(removed instanceof Array) && !removed.error) + // Successfully parsed a value, move on to removing the raw value from the params + if ((removed instanceof Array)) break; index++; } @@ -529,7 +529,6 @@ class CommandHandler extends Observer if (removed instanceof Array) for (const r of removed) params.splice(params.indexOf(r), 1, null); - } const strings = []; @@ -679,11 +678,8 @@ class CommandHandler extends Observer }; } }; - return invoker.reply({ ...messages[info.type](), edit: invoker.replied }); - } - } export default CommandHandler; \ No newline at end of file diff --git a/src/client/interfaces/commands/ModerationCommand.ts b/src/client/interfaces/commands/ModerationCommand.ts index 9c0a10d..476db82 100644 --- a/src/client/interfaces/commands/ModerationCommand.ts +++ b/src/client/interfaces/commands/ModerationCommand.ts @@ -87,10 +87,11 @@ abstract class ModerationCommand extends SlashCommand if (opts.options?.some((opt) => opt.type === CommandOptionType.SUB_COMMAND)) baseOptions = []; + const sorted = [ ...baseOptions, ...opts.options || [] ].sort((a) => a.type === CommandOptionType.STRING ? 0 : -1); super(client, { ...opts, options: opts.overrideOptions - ? opts.options : [ ...baseOptions, ...opts.options || [] ] + ? opts.options : sorted }); } } diff --git a/src/localization/en_gb/observers/en_gb_commandHandler.lang b/src/localization/en_gb/observers/en_gb_commandHandler.lang index b5f8e33..62bc05c 100644 --- a/src/localization/en_gb/observers/en_gb_commandHandler.lang +++ b/src/localization/en_gb/observers/en_gb_commandHandler.lang @@ -59,9 +59,15 @@ The members must be exact matches for this option. [O_COMMANDHANDLER_TYPETEXT_CHANNEL] The command option {option} requires a text channel. +[O_COMMANDHANDLER_TYPETEXT_CHANNELS] +The command option {option} requires text channels. + [O_COMMANDHANDLER_TYPEVOICE_CHANNEL] The command option {option} requires a voice channel. +[O_COMMANDHANDLER_TYPEVOICE_CHANNELS] +The command option {option} requires voice channels. + [O_COMMANDHANDLER_TYPECHANNELS] The command option {option} requires channels.