Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Don't crash if a message has no author #125

Merged
merged 1 commit into from
Mar 24, 2021

Conversation

smichel17
Copy link
Contributor

When setting the status message, the bot looks for the prior message, to update it if it is found. To do this, it filters the message list by author id. However, sometimes a message does not have an author (unsure when; maybe when the author has left the server?), and the bot crashes.

This slipped by for a long time because the types don't mark the author as nullable (although the api reference does).

Honestly I'm a bit surprised it didn't happen before now, since #117 didn't change this filter

When setting the status message, the bot looks for the prior message, to
update it if it is found. To do this, it filters the message list by
author id. However, sometimes a message does not have an author (unsure
when; maybe when the author has left the server?), and the bot crashes.

This slipped by for a long time because the types don't mark the author
as nullable (although the api reference does).
@smichel17
Copy link
Contributor Author

After running into a similar error in a different place (:wastebasket: reactions to remove embeds), I believe this is a result of the message being partial, so it could be fixed by if (msg.partial) await msg.fetch(). This might be worth doing at some point, since I think the same issue may result in the bot updating an older status message sometimes. Not going to do that today, though.

@robertt robertt merged commit ba0a6e3 into typescript-community:master Mar 24, 2021
@smichel17 smichel17 deleted the crashfix branch March 24, 2021 18:00
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.

2 participants