mrmBot-Matrix/commands/general/reload.js

28 lines
1,016 B
JavaScript
Raw Normal View History

import Command from "../../classes/command.js";
class ReloadCommand extends Command {
// quite possibly one of the hackiest commands in the bot
run() {
return new Promise((resolve) => {
const owners = process.env.OWNER.split(",");
if (!owners.includes(this.message.author.id)) resolve("Only the bot owner can reload commands!");
if (this.args.length === 0) resolve("You need to provide a command to reload!");
2021-07-06 12:53:09 +00:00
this.ipc.broadcast("reload", this.args[0]);
this.ipc.register("reloadSuccess", () => {
this.ipc.unregister("reloadSuccess");
this.ipc.unregister("reloadFail");
resolve(`The command \`${this.args[0]}\` has been reloaded.`);
});
this.ipc.register("reloadFail", (message) => {
this.ipc.unregister("reloadSuccess");
this.ipc.unregister("reloadFail");
resolve(message.result);
});
});
}
static description = "Reloads a command";
static arguments = ["[command]"];
}
export default ReloadCommand;