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

57 lines
1.3 KiB
JavaScript

const { Setting } = require('../../../../interfaces/');
class GuildPrefixSetting extends Setting {
constructor(client) {
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) {
let [ prefix ] = params;
const MaxCharacters = 6;
if(prefix.length > MaxCharacters) return {
msg: message.format('S_GUILDPREFIX_LENGTH', { length: prefix.length, max: MaxCharacters }),
error: true
};
if(prefix.includes(' ')) return {
msg: message.format('S_GUILDPREFIX_SPACES'),
error: true
};
await message.guild._updateSettings({ [this.index]: prefix });
return {
msg: message.format(`S_GUILDPREFIX_SUCCESS`, { prefix }),
error: false
};
}
data(guild) {
return `**Prefix:** \`${guild.prefix}\``;
}
}
module.exports = GuildPrefixSetting;