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

54 lines
1.3 KiB
JavaScript

const { Setting } = require('../../../../interfaces/');
class GuildPrefixSetting extends Setting {
constructor(client, opts = {}) {
super(client, {
name: 'guildPrefix',
index: 'prefix',
module: 'utility',
display: 'prefix',
aliases: [
'prefix'
],
guarded: true,
resolve: 'GUILD',
default: {
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 });
return {
msg: message.format(`S_${this.name.toUpperCase()}_SUCCESS`, { prefix }),
error: false
}
}
}
module.exports = GuildPrefixSetting;