MCPcopy Create free account
hub / github.com/brainboxdotcc/DPP / from_json

Function from_json

src/dpp/guild.cpp:184–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182}
183
184void from_json(const nlohmann::json& j, guild_member& gm) {
185 set_string_not_null(&j, "nick", gm.nickname);
186 set_ts_not_null(&j, "joined_at", gm.joined_at);
187 set_ts_not_null(&j, "premium_since", gm.premium_since);
188 set_ts_not_null(&j, "communication_disabled_until", gm.communication_disabled_until);
189 /* Note: The permissions of the guild member are stored in the resolved set in the interaction event to
190 * reduce storage as they would be mostly empty anyway and only retrieved from interaction events
191 */
192
193 uint16_t flags = int16_not_null(&j, "flags");
194 for (auto & flag : membermap) {
195 if (flags & flag.first) {
196 gm.flags |= flag.second;
197 }
198 }
199
200 set_snowflake_array_not_null(&j, "roles", gm.roles);
201
202 if (j.contains("avatar") && !j.at("avatar").is_null()) {
203 std::string av = string_not_null(&j, "avatar");
204 if (av.substr(0, 2) == "a_") {
205 gm.flags |= gm_animated_avatar;
206 }
207 gm.avatar = av;
208 }
209
210 gm.flags |= bool_not_null(&j, "deaf") ? gm_deaf : 0;
211 gm.flags |= bool_not_null(&j, "mute") ? gm_mute : 0;
212 gm.flags |= bool_not_null(&j, "pending") ? gm_pending : 0;
213}
214
215std::string guild_member::get_avatar_url(uint16_t size, const image_type format, bool prefer_animated) const {
216 if (this->guild_id && this->user_id && !this->avatar.to_string().empty()) {

Callers

nothing calls this directly

Calls 7

set_string_not_nullFunction · 0.85
set_ts_not_nullFunction · 0.85
int16_not_nullFunction · 0.85
string_not_nullFunction · 0.85
bool_not_nullFunction · 0.85
containsMethod · 0.80

Tested by

no test coverage detected