Skip to content

Commit

Permalink
Fix null author on DMs received from other bots
Browse files Browse the repository at this point in the history
  • Loading branch information
freya022 committed May 18, 2024
1 parent 244cce2 commit 5488620
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public interface PrivateChannel extends MessageChannel
* <li>A reaction is added</li>
* <li>A message is deleted</li>
* <li>This account sends a message to a user from another shard (not shard 0)</li>
* <li>This account receives an interaction response, happens when using an user-installed interaction</li>
* </ul>
* The consequence of this is that for any message this bot receives from a guild or from other users, the user will not be null.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1630,11 +1630,10 @@ else if (channel instanceof PrivateChannel)
}
else
{
//Note, while PrivateChannel.getUser() can produce null, this invocation of it WILL NOT produce null
// because when the bot receives a message in a private channel that was _not authored by the bot_ then
// the message had to have come from the user, so that means that we had all the information to build
// the channel properly (or fill-in the missing user info of an existing partial channel)
//PrivateChannel.getUser() can produce null, see docs
user = ((PrivateChannel) channel).getUser();
if (user == null)
user = createUser(author);
}
}
else
Expand Down

0 comments on commit 5488620

Please sign in to comment.