diff --git a/src/commands/BaseCommand.ts b/src/commands/BaseCommand.ts index 9bfc466..e448aa0 100644 --- a/src/commands/BaseCommand.ts +++ b/src/commands/BaseCommand.ts @@ -117,7 +117,7 @@ export class BaseCommand { public toObject(): BaseCommandObject { const obj: BaseCommandObject = { name: this.name, - type: this.type === "MESSAGE" ? 3 : this.type === "USER" ? 2 : 1, + type: this.type === "CONTEXT" ? 0 : 1, default_permissions: true, }; return obj; diff --git a/src/commands/CommandManager.ts b/src/commands/CommandManager.ts index b701759..008f44c 100644 --- a/src/commands/CommandManager.ts +++ b/src/commands/CommandManager.ts @@ -42,7 +42,7 @@ export class CommandManager { this._commands.push(command); return; } else if (command.isContextMenuCommand()) { - if (this.list("MESSAGE").find((c) => c.name === command.name)) { + if (this.list("CONTEXT").find((c) => c.name === command.name)) { console.error(`[❌ ERROR] Cannot add command "${command.name}" because this name has already been registered as a ContextMenuCommand in this manager.`); return; } @@ -53,7 +53,7 @@ export class CommandManager { public get(q: string, t?: undefined): BaseCommand | null; public get(q: string, t: "CHAT"): ChatCommand | null; - public get(q: string, t: "MESSAGE"): ContextMenuCommand | null; + public get(q: string, t: "CONTEXT"): ContextMenuCommand | null; public get(q: string, t?: CommandType): BaseCommand | null { if (t) { switch (t) { @@ -70,7 +70,7 @@ export class CommandManager { } }) || null ); - case "MESSAGE": + case "CONTEXT": return this.list(t).find((c) => c.name === q) || null; } } else { @@ -81,14 +81,13 @@ export class CommandManager { public list(): readonly BaseCommand[]; public list(f: "CHAT"): readonly ChatCommand[]; - public list(f: "MESSAGE"): readonly ContextMenuCommand[]; + public list(f: "CONTEXT"): readonly ContextMenuCommand[]; public list(f?: CommandType): readonly BaseCommand[] { switch (f) { case "CHAT": return Object.freeze([...this._commands.filter((c) => c.type === "CHAT")]); - case "USER": - case "MESSAGE": - return Object.freeze([...this._commands.filter((c) => c.type === "MESSAGE" || c.type === "USER")]); + case "CONTEXT": + return Object.freeze([...this._commands.filter((c) => c.type === "CONTEXT")]); default: return Object.freeze([...this._commands]); } @@ -108,7 +107,7 @@ export class CommandManager { throw new CommandNotFound(i.commandName); } } else if (i.isContextMenu()) { - const cmd = this.get(i.commandName, "MESSAGE"); + const cmd = this.get(i.commandName, "CONTEXT"); if (cmd) { const target = new TargetID(i.targetId, i.targetType); return { diff --git a/src/commands/ContextMenuCommand.ts b/src/commands/ContextMenuCommand.ts index c36194a..5e4027b 100644 --- a/src/commands/ContextMenuCommand.ts +++ b/src/commands/ContextMenuCommand.ts @@ -10,7 +10,7 @@ export class ContextMenuCommand extends BaseCommand { if (!ContextMenuCommand.nameRegExp.test(o.name)) { throw new Error("Incorrect command name. Command names must have 1-32 characters"); } - super("MESSAGE", { + super("CONTEXT", { name: o.name, function: o.function, announceSuccess: o.announceSuccess, diff --git a/src/commands/types/commands.ts b/src/commands/types/commands.ts index 96bae1c..0771d14 100644 --- a/src/commands/types/commands.ts +++ b/src/commands/types/commands.ts @@ -7,7 +7,7 @@ import { CommandInteraction, Message, MessageEmbed, ReplyMessageOptions } from " export type CommandResolvable = BaseCommand | ChatCommand | ContextMenuCommand; -export type CommandType = "CHAT" | "MESSAGE" | "USER"; +export type CommandType = "CHAT" | "CONTEXT"; export type CommandFunctionReturnTypes = void | string | MessageEmbed | ReplyMessageOptions | Promise;