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

60 lines
1.6 KiB
JavaScript

const { Setting } = require('../../../../interfaces/');
class DisabledCommandsSetting extends Setting {
constructor(client) {
super(client, {
name: 'disabledCommands',
module: 'administration',
aliases: ['disabled', 'disableCommands', 'disableCommand', 'disableCmd', 'disableCmds', 'disabledCmds', 'disable'],
usage: "<+|-|list> [command..]",
resolve: 'GUILD',
default: {
disabledCommands: []
},
examples: [
'list',
'add command:ban',
'remove command:ban'
]
});
}
async handle(message, params) {
const parameters = params.join(' ').toLowerCase();
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
};
await message.guild._updateSettings({ [this.index]: type });
const description = message.format('S_PERMISSIONTYPE_DESCRIPTIONS', { type }, true);
return {
msg: `${message.format('S_PERMISSIONTYPE_SUCCESS', { type, description })}`,
error: false
};
}
fields(guild) {
return [
{
name: '》Disabled Commands',
value: `\`${guild._settings.permissionType}\``
}
];
}
}
module.exports = DisabledCommandsSetting;