galactic-bot/structure/client/components/settings/utility/GuildPrefix.js

54 lines
1.2 KiB
JavaScript
Raw Normal View History

const { Setting } = require('../../../../interfaces/');
class GuildPrefixSetting extends Setting {
2020-05-07 17:08:07 +02:00
constructor(client) {
super(client, {
name: 'guildPrefix',
index: 'prefix',
module: 'utility',
display: 'prefix',
aliases: [
'prefix'
],
guarded: true,
resolve: 'GUILD',
default: {
2020-05-07 17:08:07 +02:00
prefix: '-'
},
custom: true
});
this.client = client;
}
async handle(message, params, operator) {
if (operator === 'RESET') {
return await super._handleReset(message, params);
}
// let { params, parsedArguments } = await this._parseArguments(params);
let [ prefix ] = params;
const MaxCharacters = 6;
if(prefix.length > MaxCharacters) return {
msg: message.format('S_GPREFIX_LENGTH', { length: prefix.length, max: MaxCharacters }),
error: true
};
await message.guild._updateSettings({ prefix });
2020-05-07 17:08:07 +02:00
return {
msg: message.format(`S_${this.name.toUpperCase()}_SUCCESS`, { prefix }),
2020-05-07 17:08:07 +02:00
error: false
};
}
}
module.exports = GuildPrefixSetting;