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

Handle clyde in DMs correctly #2489

Merged
merged 1 commit into from
Jun 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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