forked from Galactic/galactic-bot
65 lines
1.6 KiB
JavaScript
65 lines
1.6 KiB
JavaScript
|
const { Setting } = require('../../../../interfaces/');
|
||
|
|
||
|
class StickyRoleSetting extends Setting {
|
||
|
|
||
|
constructor(client) {
|
||
|
|
||
|
super(client, {
|
||
|
name: 'stickyrole',
|
||
|
module: 'utility',
|
||
|
aliases: [
|
||
|
'sticky'
|
||
|
],
|
||
|
usage: '<value>',
|
||
|
examples: [
|
||
|
'stickyrole on'
|
||
|
],
|
||
|
guarded: false,
|
||
|
resolve: 'GUILD',
|
||
|
default: {
|
||
|
stickyrole: {
|
||
|
enabled: false
|
||
|
}
|
||
|
},
|
||
|
custom: true,
|
||
|
premium: 1
|
||
|
});
|
||
|
|
||
|
}
|
||
|
|
||
|
async handle(message, params) {
|
||
|
|
||
|
const { guild } = message;
|
||
|
const setting = guild._settings[this.index];
|
||
|
const { resolver } = this.client;
|
||
|
const langParams = {};
|
||
|
let index = null;
|
||
|
|
||
|
if (resolver.resolveBoolean(params[0]) !== null) {
|
||
|
setting.enabled = resolver.resolveBoolean(params[0]);
|
||
|
index = 'S_STICKYROLE_TOGGLE';
|
||
|
langParams.toggle = message.format('ON_OFF_TOGGLE', { toggle: setting.enabled }, true);
|
||
|
}
|
||
|
|
||
|
await message.guild._updateSettings({ [this.index]: setting });
|
||
|
return {
|
||
|
error: false,
|
||
|
msg: message.format(index, langParams)
|
||
|
};
|
||
|
|
||
|
}
|
||
|
|
||
|
async fields(guild) {
|
||
|
const setting = guild._settings[this.index] || this.default[this.index];
|
||
|
return [
|
||
|
{
|
||
|
name: '》Enabled',
|
||
|
value: setting.enabled,
|
||
|
inline: false
|
||
|
}
|
||
|
];
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
module.exports = StickyRoleSetting;
|