From 0cf2c9d88c7b13aca0ab62275bb0e3c02725b31c Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Mon, 9 May 2022 16:17:44 +0300 Subject: [PATCH] small fixes --- .../components/commands/developer/Eval.js | 3 ++- .../components/commands/information/Guild.js | 3 ++- src/structure/components/inhibitors/Disabled.js | 2 +- .../settings/administration/IgnoreChannels.js | 3 ++- .../settings/moderation/ModerationPoints.js | 1 + .../components/settings/moderation/WordWatcher.js | 1 + src/structure/interfaces/commands/Command.js | 1 + .../interfaces/commands/SettingsCommand.js | 14 +++++++------- src/utilities/SettingsMigrator.js | 5 +++-- 9 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/structure/components/commands/developer/Eval.js b/src/structure/components/commands/developer/Eval.js index 79eb491..9bdc91e 100644 --- a/src/structure/components/commands/developer/Eval.js +++ b/src/structure/components/commands/developer/Eval.js @@ -12,7 +12,8 @@ class EvalCommand extends Command { super(client, { name: 'eval', aliases: ['e', 'evaluate'], - restricted: true + restricted: true, + module: 'developer' }); } diff --git a/src/structure/components/commands/information/Guild.js b/src/structure/components/commands/information/Guild.js index cd07cdc..5658f17 100644 --- a/src/structure/components/commands/information/Guild.js +++ b/src/structure/components/commands/information/Guild.js @@ -11,7 +11,8 @@ class GuildCommand extends SlashCommand { super(client, { name: 'server', description: 'Display server related information', - guildOnly: true + guildOnly: true, + module: 'information' }); } diff --git a/src/structure/components/inhibitors/Disabled.js b/src/structure/components/inhibitors/Disabled.js index 4336f70..23ff325 100644 --- a/src/structure/components/inhibitors/Disabled.js +++ b/src/structure/components/inhibitors/Disabled.js @@ -15,7 +15,7 @@ class Disabled extends Inhibitor { if (!invoker.guild) return super._succeed(); const settings = await invoker.guild.settings(); - if (settings.disabledCommands?.includes(command.resolveable)) return super._fail({ + if (settings.commands.disabled?.includes(command.resolveable)) return super._fail({ modifier: invoker.format('INHIBITOR_DISABLED', { globally: false }, { code: true }) }); diff --git a/src/structure/components/settings/administration/IgnoreChannels.js b/src/structure/components/settings/administration/IgnoreChannels.js index ac80447..ec72d05 100644 --- a/src/structure/components/settings/administration/IgnoreChannels.js +++ b/src/structure/components/settings/administration/IgnoreChannels.js @@ -8,7 +8,8 @@ class IgnoreSetting extends Setting { super(client, { name: 'ignore', module: 'administration', - display: 'Have the bot ignore commands in given channels', + description: 'Have the bot ignore commands in given channels', + display: 'Ignore channels', default: { channels: [], bypass: [] diff --git a/src/structure/components/settings/moderation/ModerationPoints.js b/src/structure/components/settings/moderation/ModerationPoints.js index 0589181..0e1c284 100644 --- a/src/structure/components/settings/moderation/ModerationPoints.js +++ b/src/structure/components/settings/moderation/ModerationPoints.js @@ -8,6 +8,7 @@ class ModerationPoints extends Setting { constructor(client) { super(client, { name: 'modpoints', + display: 'Moderation Points', description: 'Configure severity values for infractions, used by automod', module: 'moderation', default: { diff --git a/src/structure/components/settings/moderation/WordWatcher.js b/src/structure/components/settings/moderation/WordWatcher.js index e4fc388..195a891 100644 --- a/src/structure/components/settings/moderation/WordWatcher.js +++ b/src/structure/components/settings/moderation/WordWatcher.js @@ -6,6 +6,7 @@ class WordWatcher extends FilterSetting { constructor(client) { super(client, { name: 'wordwatcher', + display: 'Word Watcher', description: 'Flag messages for potentially offensive content instead of deleting automatically', module: 'moderation', default: { diff --git a/src/structure/interfaces/commands/Command.js b/src/structure/interfaces/commands/Command.js index e3ea696..c3d096d 100644 --- a/src/structure/interfaces/commands/Command.js +++ b/src/structure/interfaces/commands/Command.js @@ -25,6 +25,7 @@ class Command extends Component { this.name = options.name; this.module = options.module; + if(!options.module) this.client.logger.warn(`Command ${this.name} is missing module information.`); this.description = options.description || ""; this.tags = options.tags || []; diff --git a/src/structure/interfaces/commands/SettingsCommand.js b/src/structure/interfaces/commands/SettingsCommand.js index bfc3843..2e3ecc9 100644 --- a/src/structure/interfaces/commands/SettingsCommand.js +++ b/src/structure/interfaces/commands/SettingsCommand.js @@ -49,7 +49,7 @@ class SettingsCommand extends SlashCommand { const subCommand = new CommandOption({ name: setting.name, description: setting.description, - type: 'SUB_COMMAND', + type: setting.commandType, //'SUB_COMMAND', options: setting.commandOptions }); this.options.push(subCommand); @@ -80,8 +80,8 @@ class SettingsCommand extends SlashCommand { async execute(invoker, opts) { - const { guild } = invoker; - const settingName = invoker.subcommand.name; + const { guild, subcommand, subcommandGroup } = invoker; + const settingName = subcommandGroup?.name || subcommand.name; if (settingName === 'list') return this._listSettings(invoker); @@ -92,14 +92,14 @@ class SettingsCommand extends SlashCommand { const missing = guild.me.permissions.missing(setting.clientPermissions); if (missing.length) return invoker.reply({ emoji: 'failure', - index: 'SETTING_MISSINGCLIENTPERMISSIONS', + index: 'SETTING_MISSING_CLIENTPERMISSIONS', params: { permissions: missing.map((m) => `\`${PermissionNames[m]}\``).join(', ') } }); } await invoker.deferReply(); const settings = await guild.settings(); - if (!Object.keys(opts).length) return this._showSetting(invoker, setting); + if (!Object.keys(opts).length && this.subcommand(subcommand.name).options.length) return this._showSetting(invoker, setting); try { // Pass setting values copy so the changes don't persist unless successful and actually saved @@ -167,8 +167,8 @@ class SettingsCommand extends SlashCommand { async _showSetting(invoker, setting) { - const { guild } = invoker; - const embed = setting.usageEmbed(guild); + const { guild, subcommand } = invoker; + const embed = setting.usageEmbed(guild, null, this.subcommand(subcommand.name)); const dataFields = await setting.fields(guild); // eslint-disable-next-line no-return-assign dataFields.forEach((field) => { diff --git a/src/utilities/SettingsMigrator.js b/src/utilities/SettingsMigrator.js index df6769a..a81c597 100644 --- a/src/utilities/SettingsMigrator.js +++ b/src/utilities/SettingsMigrator.js @@ -200,7 +200,7 @@ class SettingsMigrator { autorole: result.autorole, stickyrole: result.stickyrole ? { ...result.stickyrole, enabled: Boolean(result.stickyrole.roles.length) } : undefined, welcomer: result.welcomer, - disabledCommands: result.disabledCommands, + commands: { disabled: result.disabledCommands, custom: {} }, prefix: result.prefix }; return settings; @@ -322,7 +322,8 @@ class SettingsMigrator { for(const cmd of cmds) if(!resolved.includes(cmd)) resolved.push(cmd); } } - settings.disabledCommands = resolved; + // TODO Add custom command imports + settings.commands = { disabled: resolved, custom: {} }; } if (modpoints) {