disabled export for component based settings cmd

This commit is contained in:
Erik 2022-01-13 21:52:30 +02:00
parent ca271b7590
commit 1dba466101
No known key found for this signature in database
GPG Key ID: FEFF4B220DDF5589

View File

@ -13,7 +13,7 @@ class SettingCommand extends SlashCommand {
options: [ options: [
new CommandOption({ new CommandOption({
name: 'category', name: 'category',
description: "Select a category to view settings for.", description: "Select a category to configure settings for.",
type: 'STRING', type: 'STRING',
choices: [ choices: [
{ {
@ -30,8 +30,14 @@ class SettingCommand extends SlashCommand {
} }
], ],
required: true 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." }); return wrapper.reply({ content: "Could not find any settings in that category." });
} }
const viewMode = options.view?.value || false;
const selectMenu = { const selectMenu = {
type: 'SELECT_MENU', type: 'SELECT_MENU',
custom_id: 'setting', //eslint-disable-line camelcase custom_id: 'setting', //eslint-disable-line camelcase
@ -71,14 +79,14 @@ class SettingCommand extends SlashCommand {
] ]
}); });
// eslint-disable-next-line prefer-const // Hook for fishing out the collector to end it when the user swaps settings
let hook = { collector: null }; // Hook for fishing out the collector to end it when the user swaps settings const hook = { collector: null };
new InteractionCollector(this.client, { new InteractionCollector(this.client, {
channel: wrapper.channel, channel: wrapper.channel,
message, message,
componentType: 'SELECT_MENU', componentType: 'SELECT_MENU',
idle: 600_000 // 10 min idle: 600_000 // 10 min
}).on('collect', (interaction) => { }).on('collect', async (interaction) => {
this.client.logger.debug(`Setting interaction collected`); this.client.logger.debug(`Setting interaction collected`);
if (interaction.customId !== 'setting') return; if (interaction.customId !== 'setting') return;
@ -97,7 +105,13 @@ class SettingCommand extends SlashCommand {
}); });
this.client.logger.debug(`Passing to setting`); 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', () => { }).on('end', () => {
this.client.logger.debug(`Setting collector ended`); this.client.logger.debug(`Setting collector ended`);
@ -106,6 +120,10 @@ class SettingCommand extends SlashCommand {
} }
async _showSetting(wrapper, setting) {
}
} }
module.exports = SettingCommand; //module.exports = SettingCommand;