From 7ebca4bae282b3dcea62d07106df165eb965c17b Mon Sep 17 00:00:00 2001 From: Navy Date: Sat, 11 Jul 2020 23:33:01 +0300 Subject: [PATCH] stickyrole setting --- .../components/settings/utility/StickyRole.js | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 structure/client/components/settings/utility/StickyRole.js 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