Skip to content

Commit

Permalink
fix: dont require guild cache to fill member roles in message (#945)
Browse files Browse the repository at this point in the history
  • Loading branch information
braindigitalis authored Oct 14, 2023
1 parent 46ae967 commit 123e380
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/dpp/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1053,30 +1053,30 @@ 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) {
uid = author.id;
}
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;
}
} else {
/* 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;
}
}
Expand Down

0 comments on commit 123e380

Please sign in to comment.