channelignore
This commit is contained in:
parent
c4f2ac9016
commit
6f108a8323
@ -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;
|
Loading…
Reference in New Issue
Block a user