const { Setting } = require('../../../../interfaces/'); class WelcomerSetting extends Setting { constructor(client) { super(client, { name: 'welcomer', module: 'utility', aliases: [ ], usage: '', examples: [ 'welcomer Welcome to {guildname}!', 'welcomer ', 'welcomer reset' ], guarded: false, resolve: 'GUILD', default: { welcomer: { message: 'Welcome to {guildname}!', enabled: false } }, custom: true }); } async handle(message, params) { const { guild } = message; const setting = guild._settings[this.index] || this.default[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_WELCOMER_TOGGLE'; langParams.toggle = message.format('ON_OFF_TOGGLE', { toggle: setting.enabled }, true); } else { setting.message = message.content.replace(guild.prefix, '').replace(message._caller, '').replace(message._settingCaller, '').trim(); index = 'S_WELCOMER_SET'; langParams.change = setting.message; } 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 }, { name: '》 Message', value: `\`${setting.message.substring(0, 1021)}${setting.message.length > 1021 ? '...' : ''}\``, inline: false } ]; } } module.exports = WelcomerSetting;