Skip to content

Handle non existent commands during development#214

Open
xLuxy wants to merge 1 commit into
TCCPP:mainfrom
xLuxy:features/command-improvement
Open

Handle non existent commands during development#214
xLuxy wants to merge 1 commit into
TCCPP:mainfrom
xLuxy:features/command-improvement

Conversation

@xLuxy

@xLuxy xLuxy commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

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)

@xLuxy xLuxy force-pushed the features/command-improvement branch from 28cb601 to 288d210 Compare March 17, 2026 19:21
@sonarqubecloud

Copy link
Copy Markdown

@xLuxy xLuxy changed the title Fix non existent command handling from crashing the bot Handle non existent commands during development Mar 17, 2026
@Rinzii

Rinzii commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

Iirc #210 partially already handles this, but I'd say this should expand on what I did in that PR well so PR is still valid.

@marquisburg

Copy link
Copy Markdown

PASS YOUR CI BUDDY

@Rinzii

Rinzii commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

PASS YOUR CI BUDDY

This CI failing is related to something else inside of the repo main already not related to this PR.

@marquisburg

Copy link
Copy Markdown

PASS YOUR CI BUDDY

This CI failing is related to something else inside of the repo main already not related to this PR.

LGTM 👍

@marquisburg marquisburg left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the 2 comments that are redundant, logically LGTM.

Comment thread src/command-handler.ts
private async handle_slash_comand(interaction: Discord.ChatInputCommandInteraction) {
if (!(interaction.commandName in this.text_commands)) {
// TODO: Unknown command
// unknown command

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the comment, TODO is done.

Comment thread src/command-handler.ts
@@ -134,6 +134,13 @@ export class CommandHandler {
const command_name = match[1];
if (!(command_name in this.text_commands)) {
// unknown command

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant comment, special case below in diff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants