Archived
changed folder structure
This commit is contained in:
1 parent
d12657e075
commit
3ff3086e3e
14 files changed
+32
-32
No files matched your search
@@ -0,0 +1,78 @@
|
||||
import { MessageEmbed } from "discord.js";
|
||||
import { Command } from "./Command.js";
|
||||
import { CommandManager } from "../managers/CommandManager.js";
|
||||
import { HelpMessageParams } from "../types/HelpMessage.js";
|
||||
|
||||
export class HelpMessage extends Command {
|
||||
constructor(cmdManager: CommandManager, params: HelpMessageParams, botName?: string) {
|
||||
super({
|
||||
name: "help",
|
||||
usage: params.usage,
|
||||
permissions: undefined,
|
||||
description: params.description,
|
||||
visible: params.visible,
|
||||
parameters: [
|
||||
{
|
||||
name: "command_name",
|
||||
description: "Name of the command that you want to get details about",
|
||||
optional: true,
|
||||
type: "string",
|
||||
},
|
||||
],
|
||||
function: (p, i) => {
|
||||
const helpMsg = new MessageEmbed();
|
||||
helpMsg.setColor(params.color);
|
||||
helpMsg.setTimestamp();
|
||||
helpMsg.setFooter(botName || "");
|
||||
if (helpMsg != null) {
|
||||
if (p("command_name")) {
|
||||
const cmd: Command | null = cmdManager.get(p("command_name")?.toString() || "");
|
||||
if (cmd) {
|
||||
if (Array.isArray(cmd.guilds) && cmd.guilds.length > 0 && !cmd.guilds.find((g) => i?.guild?.id === g)) {
|
||||
throw new ReferenceError(`Command "${cmd.name}" is not available`);
|
||||
}
|
||||
helpMsg.setTitle(`${cmd.name} ${cmd.visible ? "" : "[HIDDEN]"}`);
|
||||
helpMsg.setDescription(cmd.description);
|
||||
if (cmd.usage) helpMsg.addField("Usage:", `${cmdManager.prefix || "/"}${cmd.name} ${cmd.usage}`, false);
|
||||
if (cmd.permissions) {
|
||||
if (cmd.permissions instanceof Function) {
|
||||
helpMsg.addField("Permissions:", "Custom", false);
|
||||
} else if (cmd.permissions.toArray(false).length > 0) {
|
||||
let permList: string = "";
|
||||
cmd.permissions.toArray(false).map((p) => {
|
||||
permList += p + "\n";
|
||||
});
|
||||
helpMsg.addField("Permissions:", permList, false);
|
||||
}
|
||||
}
|
||||
if (cmd.aliases && cmd.aliases.length > 0) {
|
||||
let aList: string = "";
|
||||
cmd.aliases.map((a) => {
|
||||
aList += a + "\n";
|
||||
});
|
||||
helpMsg.addField("Aliases:", aList, false);
|
||||
}
|
||||
helpMsg.addField("Slash command:", cmd.slash ? "ENABLED" : "DISABLED", false);
|
||||
helpMsg.addField("Command scope:", Array.isArray(cmd.guilds) && cmd.guilds.length > 0 ? "CUSTOM" : "GLOBAL", false);
|
||||
} else {
|
||||
throw new ReferenceError(`Command "${p("command_name")}" does not exist`);
|
||||
}
|
||||
} else {
|
||||
helpMsg.setTitle(params.title);
|
||||
helpMsg.setDescription(params.bottomText);
|
||||
|
||||
cmdManager.list.map((c) => {
|
||||
if (
|
||||
c.visible &&
|
||||
((Array.isArray(c.guilds) && c.guilds.length > 0 && c.guilds.find((g) => i?.guild?.id === g)) || !Array.isArray(c.guilds) || c.guilds.length === 0)
|
||||
) {
|
||||
helpMsg.addField(`${cmdManager.prefix || "/"}${c.name} ${c.usage}`, c.description, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return helpMsg;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user