Skip to content

Commit

Permalink
Handle clyde in DMs correctly (#2489)
Browse files Browse the repository at this point in the history
  • Loading branch information
MinnDevelopment authored Jun 30, 2023
1 parent b186f57 commit 48dba59
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1619,24 +1619,23 @@ private PrivateChannel createPrivateChannelByMessage(DataObject message)
{
final long channelId = message.getLong("channel_id");
final DataObject author = message.getObject("author");
final long authorId = author.getLong("id");

PrivateChannelImpl channel = (PrivateChannelImpl) getJDA().getPrivateChannelById(channelId);
boolean isAuthorSelfUser = authorId == getJDA().getSelfUser().getIdLong();
boolean isRecipient = !author.getBoolean("bot"); // bots cannot dm other bots
if (channel == null)
{
DataObject channelData = DataObject.empty()
.put("id", channelId);

//if we see an author that isn't us, we can assume that is the other side of this private channel
//if the author is us, we learn no information about the user at the other end
if (!isAuthorSelfUser)
if (isRecipient)
channelData.put("recipient", author);

//even without knowing the user at the other end, we can still construct a minimal channel
channel = (PrivateChannelImpl) createPrivateChannel(channelData);
}
else if (channel.getUser() == null && !isAuthorSelfUser)
else if (channel.getUser() == null && isRecipient)
{
//In this situation, we already know the channel
// but the message provided us with the recipient
Expand Down

0 comments on commit 48dba59

Please sign in to comment.