diff --git a/src/structure/components/commands/administration/SettingCommand.js b/src/structure/components/commands/administration/SettingCommand.js index 9936346..0a98b38 100644 --- a/src/structure/components/commands/administration/SettingCommand.js +++ b/src/structure/components/commands/administration/SettingCommand.js @@ -13,7 +13,7 @@ class SettingCommand extends SlashCommand { options: [ new CommandOption({ name: 'category', - description: "Select a category to view settings for.", + description: "Select a category to configure settings for.", type: 'STRING', choices: [ { @@ -30,8 +30,14 @@ class SettingCommand extends SlashCommand { } ], required: true + }), + new CommandOption({ + name: 'view', + description: "Pass this option to view the current configuration for the category", + type: 'BOOLEAN' }) - ] + ], + defaultPermission: false }); } @@ -45,6 +51,8 @@ class SettingCommand extends SlashCommand { return wrapper.reply({ content: "Could not find any settings in that category." }); } + const viewMode = options.view?.value || false; + const selectMenu = { type: 'SELECT_MENU', custom_id: 'setting', //eslint-disable-line camelcase @@ -71,14 +79,14 @@ class SettingCommand extends SlashCommand { ] }); - // eslint-disable-next-line prefer-const - let hook = { collector: null }; // Hook for fishing out the collector to end it when the user swaps settings + // Hook for fishing out the collector to end it when the user swaps settings + const hook = { collector: null }; new InteractionCollector(this.client, { channel: wrapper.channel, message, componentType: 'SELECT_MENU', idle: 600_000 // 10 min - }).on('collect', (interaction) => { + }).on('collect', async (interaction) => { this.client.logger.debug(`Setting interaction collected`); if (interaction.customId !== 'setting') return; @@ -97,7 +105,13 @@ class SettingCommand extends SlashCommand { }); this.client.logger.debug(`Passing to setting`); - return setting.execute(wrapper, selectMenu, hook); + try { + if (!viewMode) await setting.execute(wrapper, selectMenu, hook); + else await this._showSetting(wrapper, setting); + } catch (err) { + this.client.logger.error(`Error during setting execution:\n${err.stack || err}`); + wrapper.channel.send(`Internal error while trying to process **${setting.name}** setting`); + } }).on('end', () => { this.client.logger.debug(`Setting collector ended`); @@ -106,6 +120,10 @@ class SettingCommand extends SlashCommand { } + async _showSetting(wrapper, setting) { + + } + } -module.exports = SettingCommand; \ No newline at end of file +//module.exports = SettingCommand; \ No newline at end of file