galactic-bot/structure/client/components/settings/administration/Silent.js
2021-05-08 20:42:30 +03:00

49 lines
1.1 KiB
JavaScript

const { Setting } = require('../../../../interfaces');
class SilentSetting extends Setting {
constructor(client) {
super(client, {
name: 'silent',
module: 'administration',
usage: "<'on'|'off'>",
resolve: 'GUILD',
default: {
silent: false
}
});
}
async handle(message, params) {
const parameters = params.join(' ');
const boolean = this.client.resolver.resolveBoolean(parameters);
if(boolean === null) return {
msg: message.format('S_SILENT_INVALID'),
error: true
};
await message.guild._updateSettings({
[this.index]: boolean
});
return {
msg: message.format('S_SILENT_SUCCESS', { value: boolean }),
error: false
};
}
fields(guild) {
return [
{
name: '》 Status',
value: guild.format('SETTING_STATUS', { bool: Boolean(guild._settings.silent) }, true),
inline: true
}
];
}
}
module.exports = SilentSetting;