From 48dba5953788ef8efe459240c01f5c3505489b80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Spie=C3=9F?= Date: Fri, 30 Jun 2023 18:09:02 +0200 Subject: [PATCH] Handle clyde in DMs correctly (#2489) --- .../net/dv8tion/jda/internal/entities/EntityBuilder.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/dv8tion/jda/internal/entities/EntityBuilder.java b/src/main/java/net/dv8tion/jda/internal/entities/EntityBuilder.java index fa44fd0f91..2b4fc0d644 100644 --- a/src/main/java/net/dv8tion/jda/internal/entities/EntityBuilder.java +++ b/src/main/java/net/dv8tion/jda/internal/entities/EntityBuilder.java @@ -1619,10 +1619,9 @@ 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() @@ -1630,13 +1629,13 @@ private PrivateChannel createPrivateChannelByMessage(DataObject message) //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