Skip to content

Commit

Permalink
read guilds from merged presences (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
ouwou committed May 15, 2023
1 parent 7dba382 commit 38c3b0c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/discord/discord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2124,7 +2124,8 @@ void DiscordClient::HandleGatewayGuildMembersChunk(const GatewayMessage &msg) {

void DiscordClient::HandleGatewayReadySupplemental(const GatewayMessage &msg) {
ReadySupplementalData data = msg.Data;
for (const auto &p : data.MergedPresences.Friends) {

const auto handle_presence = [this](const MergedPresence &p) {
const auto user = GetUser(p.UserID);
if (!user.has_value()) return; // should be sent in READY's `users`
const auto s = p.Presence.Status;
Expand All @@ -2137,6 +2138,15 @@ void DiscordClient::HandleGatewayReadySupplemental(const GatewayMessage &msg) {
else if (s == "dnd")
m_user_to_status[p.UserID] = PresenceStatus::DND;
m_signal_presence_update.emit(*user, m_user_to_status.at(p.UserID));
};

for (const auto &p : data.MergedPresences.Friends) {
handle_presence(p);
}
for (const auto &g : data.MergedPresences.Guilds) {
for (const auto &p : g) {
handle_presence(p);
}
}
}

Expand Down

0 comments on commit 38c3b0c

Please sign in to comment.