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

fix: dont require guild cache to fill member roles in message #945

Merged
merged 1 commit into from
Oct 14, 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
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);
Jaskowicz1 marked this conversation as resolved.
Show resolved Hide resolved
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
Loading