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

62 lines
1.4 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) {
2020-05-22 21:15:18 +02:00
const [ 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
};
2020-05-22 22:13:47 +02:00
if (prefix === 'reset') prefix = this.default.prefix;
await message.guild._updateSettings({ [this.index]: prefix });
2020-05-07 17:08:07 +02:00
return {
2020-05-22 22:13:47 +02:00
msg: message.format('S_GUILDPREFIX_SUCCESS', { prefix }),
2020-05-07 17:08:07 +02:00
error: false
};
}
2020-05-22 21:15:18 +02:00
fields(guild) {
return {
name: '》Prefix',
value: `\`${guild.prefix}\``
};
}
}
module.exports = GuildPrefixSetting;