2020-05-06 01:40:46 +02:00
|
|
|
const { Setting } = require('../../../../interfaces/');
|
|
|
|
|
|
|
|
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-22 21:15:18 +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
|
|
|
|
};
|
|
|
|
|
2020-05-22 22:13:47 +02:00
|
|
|
if (prefix === 'reset') prefix = this.default.prefix;
|
|
|
|
|
2020-05-21 12:47:58 +02:00
|
|
|
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;
|