thaldrin/DiscordModules/Settings/prefix.js
2019-11-11 18:26:18 +01:00

62 lines
1.9 KiB
JavaScript

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,
developerOnly: false,
AuthorPermissions: [ 'MANAGE_GUILD' ]
});
}
async command(ctx) {
let PrefixEmbed = new ctx.utils.discord.MessageEmbed();
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}`);
PrefixEmbed.setDescription(`${NServer.prefix.join(' | ') || ctx.db.defaults.server.prefix}`);
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)
.then(async () => {
let NServer = await ctx.db.servers.get(ctx.guild.id);
PrefixEmbed.setTitle(`Prefixes for ${ctx.guild.name}`);
PrefixEmbed.setDescription(`${NServer.prefix.join(' | ') || ctx.db.defaults.server.prefix}`);
ctx.send(PrefixEmbed);
})
.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;
}
}
};