diff --git a/structure/client/components/settings/utility/StickyRole.js b/structure/client/components/settings/utility/StickyRole.js new file mode 100644 index 0000000..dc5e94d --- /dev/null +++ b/structure/client/components/settings/utility/StickyRole.js @@ -0,0 +1,65 @@ +const { Setting } = require('../../../../interfaces/'); + +class StickyRoleSetting extends Setting { + + constructor(client) { + + super(client, { + name: 'stickyrole', + module: 'utility', + aliases: [ + 'sticky' + ], + usage: '', + 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; \ No newline at end of file