2020-05-06 01:40:46 +02:00
|
|
|
const { Setting } = require('../../../../interfaces/');
|
2020-06-16 00:15:13 +02:00
|
|
|
const options = require('../../../../../options.json');
|
2020-05-06 01:40:46 +02:00
|
|
|
|
|
|
|
class GuildPrefixSetting extends Setting {
|
|
|
|
|
2020-05-07 17:08:07 +02:00
|
|
|
constructor(client) {
|
2020-05-06 01:40:46 +02:00
|
|
|
|
|
|
|
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: '-'
|
2020-05-06 01:40:46 +02:00
|
|
|
},
|
|
|
|
custom: true
|
|
|
|
});
|
|
|
|
|
|
|
|
this.client = client;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-05-21 12:47:58 +02:00
|
|
|
async handle(message, params) {
|
2020-05-06 01:40:46 +02:00
|
|
|
|
2020-05-25 13:13:34 +02:00
|
|
|
const [ prefix ] = params;
|
2020-05-06 01:40:46 +02:00
|
|
|
|
|
|
|
const MaxCharacters = 6;
|
|
|
|
if(prefix.length > MaxCharacters) return {
|
2020-05-18 01:13:24 +02:00
|
|
|
msg: message.format('S_GUILDPREFIX_LENGTH', { length: prefix.length, max: MaxCharacters }),
|
2020-05-06 01:40:46 +02:00
|
|
|
error: true
|
|
|
|
};
|
|
|
|
|
2020-05-21 12:47:58 +02:00
|
|
|
if(prefix.includes(' ')) return {
|
|
|
|
msg: message.format('S_GUILDPREFIX_SPACES'),
|
|
|
|
error: true
|
|
|
|
};
|
|
|
|
|
|
|
|
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-06 01:40:46 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-05-22 21:15:18 +02:00
|
|
|
fields(guild) {
|
|
|
|
return {
|
|
|
|
name: '》Prefix',
|
|
|
|
value: `\`${guild.prefix}\``
|
|
|
|
};
|
2020-05-18 01:13:24 +02:00
|
|
|
}
|
|
|
|
|
2020-05-06 01:40:46 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = GuildPrefixSetting;
|