thaldrin/DiscordModules/Settings/prefix.js

63 lines
1.9 KiB
JavaScript
Raw Normal View History

2019-11-10 08:42:09 +00:00
const Command = require('../../src/structures/Command');
module.exports = class Prefix extends Command {
constructor() {
super({
name: 'prefix',
description: 'Add or Remove a prefix',
aliases: [],
module: 'Settings',
cooldown: 10,
guildOnly: true,
2019-11-11 17:08:27 +00:00
developerOnly: false,
AuthorPermissions: [ 'MANAGE_GUILD' ]
2019-11-10 08:42:09 +00:00
});
}
async command(ctx) {
2019-11-11 17:26:18 +00:00
let PrefixEmbed = new ctx.utils.discord.MessageEmbed();
2019-11-10 08:42:09 +00:00
PrefixEmbed.setColor(ctx.config.color);
let ARG = ctx.args[0];
ctx.args.shift();
let Prefix = ctx.args.join(' ');
let Server = await ctx.db.servers.get(ctx.guild.id);
Server.prefix.shift();
Server.prefix.shift();
Server.prefix.shift();
switch (ARG) {
case 'a':
case 'add':
if (ctx.args === [] || ctx.args.join(' ').trim() === '') return ctx.send('No Prefix was given');
ctx.utils.db.prefix
.add(ctx, Prefix)
.then(async () => {
let NServer = await ctx.db.servers.get(ctx.guild.id);
PrefixEmbed.setTitle(`Prefixes for ${ctx.guild.name}`);
2019-11-11 17:08:27 +00:00
PrefixEmbed.setDescription(`${NServer.prefix.join(' | ') || ctx.db.defaults.server.prefix}`);
2019-11-10 08:42:09 +00:00
ctx.send(PrefixEmbed);
})
.catch((err) => ctx.send(err));
break;
case 'r':
case 'remove':
if (ctx.args === [] || ctx.args.join(' ').trim() === '') return ctx.send('No Prefix was given');
ctx.utils.db.prefix
.remove(ctx, Prefix)
2019-11-11 17:08:27 +00:00
.then(async () => {
2019-11-10 08:42:09 +00:00
let NServer = await ctx.db.servers.get(ctx.guild.id);
2019-11-11 17:08:27 +00:00
PrefixEmbed.setTitle(`Prefixes for ${ctx.guild.name}`);
PrefixEmbed.setDescription(`${NServer.prefix.join(' | ') || ctx.db.defaults.server.prefix}`);
ctx.send(PrefixEmbed);
2019-11-10 08:42:09 +00:00
})
.catch((err) => ctx.send(err));
break;
default:
PrefixEmbed.setTitle('Help');
PrefixEmbed.addField('a / add <prefix>', 'Add a Prefix', true);
PrefixEmbed.addField('r / remove <prefix>', 'Remove a Prefix', true);
ctx.send(PrefixEmbed);
break;
}
}
};