From 6f108a832347acb94f3e769e10a85f936002adb1 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Tue, 18 Jan 2022 16:33:26 +0200 Subject: [PATCH] channelignore --- .../settings/administration/IgnoreChannels.js | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/structure/components/settings/administration/IgnoreChannels.js diff --git a/src/structure/components/settings/administration/IgnoreChannels.js b/src/structure/components/settings/administration/IgnoreChannels.js new file mode 100644 index 0000000..fe34bda --- /dev/null +++ b/src/structure/components/settings/administration/IgnoreChannels.js @@ -0,0 +1,66 @@ +const Util = require("../../../../Util"); +const { Setting, CommandOption } = require("../../../interfaces"); + +class IgnoreSetting extends Setting { + + constructor(client) { + + super(client, { + name: 'ignore', + module: 'administration', + default: { + channels: [], + bypass: [] + }, + commandOptions: [ + new CommandOption({ + name: 'list', + description: '', + type: 'STRING', + choices: [ + { name: 'channels', value: 'channels' }, + { name: 'bypass', value: 'bypass' } + ] + }), + new CommandOption({ + name: 'method', + description: '', + type: 'STRING', + choices: [ + { name: 'add', value: 'add' }, + { name: 'remove', value: 'remove' }, + { name: 'set', value: 'set' }, + { name: 'reset', value: 'reset' }, + ] + }) + ] + }); + + } + + async execute(interaction, opts, setting) { + + const { list, method } = opts; + if (!list || !method) return { error: true, index: 'SETTING_MISSING_ARG' }; + + const response = await this._prompt(interaction, { + index: `SETTING_PROMPT_${method.value.toUpperCase()}`, + params: { list: list.value } + }); + if (response.error) return response; + const params = Util.parseQuotes(response).map(([param]) => param); + + let values = []; + const { guild } = interaction; + if (list.value === 'bypass') values = await guild.resolveRoles(params).then((roles) => roles.map((r) => r.id)); + else values = await guild.resolveChannels(params).then((channels) => channels.map((c) => c.id)); + + this[method.value](setting[list.value], values); + + return { error: false, index: 'SETTING_SUCCESS', params: { updated: list.value } }; + + } + +} + +module.exports = IgnoreSetting; \ No newline at end of file