Skip to content

Stop an edit of an uncached message from taking the bot down - #12

Merged
Musiker15 merged 1 commit into
mainfrom
fix/partial-message-logging
Nov 5, 2026
Merged

Musiker15 merged 1 commit into
mainfrom
fix/partial-message-logging

Conversation

@Musiker15

Copy link
Copy Markdown
Member

An edit or delete of a message that is not in the cache arrives as a partial with author null. onMessageEdit and onMessageDelete in bots/events/handlers/logging.js read author.id and threw. discord.js turns a rejected handler into an error event on the client, and with no listener Node exits the whole process. The server log shows twelve restarts in the last seven days, the latest at 12:07 today:

TypeError: Cannot read properties of null (reading 'id')
    at Object.onMessageEdit (bots/events/handlers/logging.js:291:70)
  • Both handlers skip a message without an author. There is nothing to log for it anyway, the old content is not known.
  • Every client in main.js gets an Events.Error listener, so a failing handler is logged instead of ending the process.

Tests: section L in the harness sends a partial edit and delete through both handlers and checks for the listener. With the old guard both cases fail. npm test: 180 passed.

An edit or delete of a message that is not in the cache arrives as a partial with author null. The logging handlers read author.id and threw. discord.js turns that into an error event on the client, and with no listener Node exits the process: twelve restarts in the last seven days. Both handlers now skip a message without an author, and every client gets an error listener so a failing handler is logged instead of ending the process.
@Musiker15
Musiker15 merged commit 5f689af into main Nov 5, 2026
6 checks passed
@Musiker15
Musiker15 deleted the fix/partial-message-logging branch November 5, 2026 11:11
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.

1 participant