Skip to content

Commit

Permalink
skip unrecognized command types with a warning message
Browse files Browse the repository at this point in the history
  • Loading branch information
ssMMiles committed Aug 16, 2024
1 parent 3c63186 commit ce6656c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/core/src/app/managers/CommandManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@ export class CommandManager {
[ApplicationCommandType.Message]: new Map()
};

commands.map((command) => parsed[command.type]?.set(command.name, command));
commands.map((command) => {
if (parsed?.[command.type] === undefined) {
console.warn(`Unrecognized command type: ${command.type}`);
return;
}

parsed[command.type].set(command.name, command);
});

return parsed;
}
Expand All @@ -101,11 +108,11 @@ export class CommandManager {
* @param type Command type
*/
get(name: string, type: ApplicationCommandType = ApplicationCommandType.ChatInput): RegisteredCommand | undefined {
return this[type]?.get(name);
return this[type].get(name);
}

set(name: string, type: ApplicationCommandType = ApplicationCommandType.ChatInput, command: RegisteredCommand): void {
this[type]?.set(name, command as never);
this[type].set(name, command as never);
}

/**
Expand Down

0 comments on commit ce6656c

Please sign in to comment.