2023-03-15 14:09:09 +00:00
|
|
|
import Command from "../../classes/command.js";
|
|
|
|
import { load } from "../../utils/handler.js";
|
|
|
|
import { paths } from "../../utils/collections.js";
|
|
|
|
|
|
|
|
class ReloadCommand extends Command {
|
|
|
|
async run() {
|
|
|
|
const owners = process.env.OWNER.split(",");
|
2023-03-15 14:46:45 +00:00
|
|
|
if (!owners.includes(this.author)) return "Only the bot owner can reload commands!";
|
2023-03-15 14:09:09 +00:00
|
|
|
const commandName = this.options.cmd ?? this.args.join(" ");
|
|
|
|
if (!commandName || !commandName.trim()) return "You need to provide a command to reload!";
|
2023-03-17 00:23:01 +00:00
|
|
|
// await this.acknowledge();
|
2023-03-15 14:09:09 +00:00
|
|
|
const path = paths.get(commandName);
|
|
|
|
if (!path) return "I couldn't find that command!";
|
2023-03-15 14:50:25 +00:00
|
|
|
const result = await load(this.client, path, true);
|
2023-03-15 14:09:09 +00:00
|
|
|
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.`;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|