mrmBot-Matrix/commands/general/reload.js

42 lines
1.3 KiB
JavaScript
Raw Normal View History

import Command from "../../classes/command.js";
import { load } from "../../utils/handler.js";
import { checkStatus } from "../../utils/soundplayer.js";
import { paths } from "../../utils/collections.js";
class ReloadCommand extends Command {
async run() {
const owners = process.env.OWNER.split(",");
if (!owners.includes(this.author.id)) return "Only the bot owner can reload commands!";
const commandName = this.options.cmd ?? this.args.join(" ");
if (!commandName || !commandName.trim()) return "You need to provide a command to reload!";
await this.acknowledge();
const path = paths.get(commandName);
if (!path) return "I couldn't find that command!";
const result = await load(this.client, path, await checkStatus(), true);
if (result !== commandName) return "I couldn't reload that command!";
if (process.env.PM2_USAGE) {
process.send({
type: "process:msg",
data: {
type: "reload",
message: commandName
}
});
}
return `The command \`${commandName}\` has been reloaded.`;
}
2022-03-31 19:53:22 +00:00
static flags = [{
name: "cmd",
type: 3,
description: "The command to reload",
required: true
}];
static description = "Reloads a command";
static arguments = ["[command]"];
static adminOnly = true;
}
export default ReloadCommand;