JaBa/commands/Administration/addcommand.js

42 lines
1.1 KiB
JavaScript
Raw Normal View History

const Command = require("../../base/Command");
2022-01-04 02:18:28 +05:00
class Addcommand extends Command {
constructor(client) {
super(client, {
name: "addcommand",
dirname: __dirname,
enabled: true,
guildOnly: true,
aliases: ["addc"],
memberPermissions: ["MANAGE_GUILD"],
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
nsfw: false,
ownerOnly: false,
cooldown: 1000
});
}
async run(message, args, data) {
if (!args[0]) return message.error("administration/addcommand:MISSING_NAME");
const name = args[0].split("\n")[0];
if (this.client.commands.get(name) || this.client.aliases.get(name) || data.guild.customCommands.find((c) => c.name === name)) return message.error("administration/addcommand:COMMAND_ALREADY_EXISTS");
const answer = (args[0].split("\n")[1] || "") + args.slice(1).join(" ");
if (!answer) return message.error("administration/addcommand:MISSING_ANSWER");
data.guild.customCommands.push({
name: name.toLowerCase(),
answer: answer
});
data.guild.save();
message.success("administration/addcommand:SUCCESS", {
commandName: name,
prefix: data.guild.prefix
});
}
2022-01-13 00:26:23 +05:00
}
2022-01-04 02:18:28 +05:00
module.exports = Addcommand;