Skip to content

Commit a652dce

Browse files
xLuxyjeremy-rifkin
andauthored
Handle non existent commands during development (#214)
Currently, when `freestanding` is set to `true` and you try to use a command which is not registered the bot will throw an exception. (I've used the `modlogs` command for testing) This PR fixes that by adding a missing return statement. As a small improvement to this, i've also added a response to whenever a command has not been registered which can help during development. ### Context: ``` 🛑 [2026.03.17 20:18:25.763] [error] TypeError: Cannot read properties of undefined (reading 'options') at CommandHandler.handle_slash_comand (file:///D:/dev/wheatley/build/src/command-handler.js:157:28) at process.processTicksAndRejections (node:internal/process/task_queues:104:5) at async CommandHandler.on_interaction (file:///D:/dev/wheatley/build/src/command-handler.js:331:17) Error TypeError: Cannot read properties of undefined (reading 'options') at CommandHandler.handle_slash_comand (file:///D:/dev/wheatley/build/src/command-handler.js:157:28) at process.processTicksAndRejections (node:internal/process/task_queues:104:5) at async CommandHandler.on_interaction (file:///D:/dev/wheatley/build/src/command-handler.js:331:17) Trace at M.error (file:///D:/dev/wheatley/build/src/utils/debugging-and-logging.js:61:17) at Wheatley.critical_error (file:///D:/dev/wheatley/build/src/wheatley.js:229:15) at CommandHandler.on_interaction (file:///D:/dev/wheatley/build/src/command-handler.js:405:31) at process.processTicksAndRejections (node:internal/process/task_queues:104:5) ``` Co-authored-by: Jeremy Rifkin <51220084+jeremy-rifkin@users.noreply.github.com>
1 parent 01261cb commit a652dce

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/command-handler.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ export class CommandHandler {
134134
const command_name = match[1];
135135
if (!(command_name in this.text_commands)) {
136136
// unknown command
137+
138+
if (this.wheatley.devmode_enabled) {
139+
await message.reply({
140+
content: `Unknown text command: ${command_name}`,
141+
});
142+
}
143+
137144
return false;
138145
}
139146
let command_body = message.content.substring(match[0].length).trim();
@@ -186,7 +193,16 @@ export class CommandHandler {
186193

187194
private async handle_slash_comand(interaction: Discord.ChatInputCommandInteraction) {
188195
if (!(interaction.commandName in this.text_commands)) {
189-
// TODO: Unknown command
196+
// unknown command
197+
198+
if (this.wheatley.devmode_enabled) {
199+
await interaction.reply({
200+
content: `Unknown slash command: ${interaction.commandName}`,
201+
flags: Discord.MessageFlags.Ephemeral,
202+
});
203+
}
204+
205+
return;
190206
}
191207
let command = this.text_commands[interaction.commandName];
192208
let command_log_name = interaction.commandName;

0 commit comments

Comments
 (0)