galactic-bot/structure/client/components/settings/administration/DisabledCommands.js

61 lines
1.6 KiB
JavaScript
Raw Normal View History

const { Setting } = require('../../../../interfaces/');
2020-07-28 05:00:24 +02:00
class DisabledCommandsSetting extends Setting {
constructor(client) {
super(client, {
2020-07-28 05:00:24 +02:00
name: 'disabledCommands',
module: 'administration',
aliases: ['disabled', 'disableCommands', 'disableCommand', 'disableCmd', 'disableCmds', 'disabledCmds', 'disable'],
usage: "<+|-|list> [command..]",
resolve: 'GUILD',
default: {
disabledCommands: []
},
2020-05-24 10:54:33 +02:00
examples: [
2020-07-28 05:00:24 +02:00
'list',
'add command:ban',
'remove command:ban'
],
archivable: false
});
}
async handle(message, params) {
2020-05-24 10:54:33 +02:00
const parameters = params.join(' ').toLowerCase();
2020-05-24 10:54:33 +02:00
let type = null;
for(const [ key, value ] of Object.entries(Constants.Types)) {
if(value.includes(parameters)) type = key;
}
if(!type) return {
msg: message.format('S_PERMISSIONTYPE_INVALIDTYPE'),
error: true
};
2020-05-24 10:54:33 +02:00
await message.guild._updateSettings({ [this.index]: type });
2020-05-24 10:54:33 +02:00
const description = message.format('S_PERMISSIONTYPE_DESCRIPTIONS', { type }, true);
return {
2020-05-24 10:54:33 +02:00
msg: `${message.format('S_PERMISSIONTYPE_SUCCESS', { type, description })}`,
error: false
};
}
fields(guild) {
return [
{
name: '》 Disabled Commands',
2020-05-24 10:54:33 +02:00
value: `\`${guild._settings.permissionType}\``
}
];
}
}
2020-07-28 05:00:24 +02:00
module.exports = DisabledCommandsSetting;