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

62 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: {
2020-07-28 05:00:24 +02:00
disabledCommands: [
'command:strike'
]
},
2020-05-24 10:54:33 +02:00
examples: [
2020-07-28 05:00:24 +02:00
'list',
'add command:strike',
'remove command:strike'
2020-05-24 10:54:33 +02:00
]
});
}
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 [
{
2020-07-28 05:00:24 +02:00
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;