From 123e3801318812dfb1f96f76ca2129453d923fe6 Mon Sep 17 00:00:00 2001 From: "Craig Edwards (Brain)" Date: Sat, 14 Oct 2023 14:05:29 +0100 Subject: [PATCH] fix: dont require guild cache to fill member roles in message (#945) --- src/dpp/message.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dpp/message.cpp b/src/dpp/message.cpp index fba25b7ae4..04f8e30675 100644 --- a/src/dpp/message.cpp +++ b/src/dpp/message.cpp @@ -1053,7 +1053,7 @@ message& message::fill_from_json(json* d, cache_policy_t cp) { /* Fill in member record, cache uncached ones */ guild* g = find_guild(this->guild_id); this->member = {}; - if (g && d->find("member") != d->end()) { + if (guild_id && d->find("member") != d->end()) { json& mi = (*d)["member"]; snowflake uid = snowflake_not_null(&(mi["user"]), "id"); if (!uid && author.id) { @@ -1061,14 +1061,14 @@ message& message::fill_from_json(json* d, cache_policy_t cp) { } if (cp.user_policy == dpp::cp_none) { /* User caching off! Just fill in directly but dont store member to guild */ - this->member.fill_from_json(&mi, g->id, uid); - } else { + this->member.fill_from_json(&mi, this->guild_id, uid); + } else if (g) { /* User caching on, lazy or aggressive - cache the member information */ auto thismember = g->members.find(uid); if (thismember == g->members.end()) { if (!uid.empty() && author.id) { guild_member gm; - gm.fill_from_json(&mi, g->id, uid); + gm.fill_from_json(&mi, this->guild_id, uid); g->members[author.id] = gm; this->member = gm; } @@ -1076,7 +1076,7 @@ message& message::fill_from_json(json* d, cache_policy_t cp) { /* Update roles etc */ this->member = thismember->second; if (author.id) { - this->member.fill_from_json(&mi, g->id, author.id); + this->member.fill_from_json(&mi, this->guild_id, author.id); g->members[author.id] = this->member; } }