JaBa/commands/Administration/addcommand.js

42 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-12-10 21:39:54 +05:00
const Command = require("../../base/Command.js");
class Addcommand extends Command {
2021-12-26 19:29:37 +05:00
constructor(client) {
2021-12-10 21:39:54 +05:00
super(client, {
name: "addcommand",
dirname: __dirname,
enabled: true,
guildOnly: true,
2021-12-26 19:29:37 +05:00
aliases: ["custom-command"],
memberPermissions: ["MANAGE_GUILD"],
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
2021-12-10 21:39:54 +05:00
nsfw: false,
ownerOnly: false,
cooldown: 2000
2021-12-10 21:39:54 +05:00
});
}
2021-12-26 19:29:37 +05:00
async run(message, args, data) {
2021-12-10 21:39:54 +05:00
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();
2021-12-26 19:29:37 +05:00
message.success("administration/addcommand:SUCCESS", {
commandName: name,
prefix: data.guild.prefix
});
2021-12-10 21:39:54 +05:00
}
};
module.exports = Addcommand;