From a7b73bccf3e0dfcb7ed5f80494c67a39ffb4df84 Mon Sep 17 00:00:00 2001 From: Jaskowicz1 Date: Sat, 9 Sep 2023 09:57:43 +0100 Subject: [PATCH] fix: corrected presence.cpp to work with custom status --- src/dpp/presence.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/dpp/presence.cpp b/src/dpp/presence.cpp index bd27de1fa0..d1b44098ae 100644 --- a/src/dpp/presence.cpp +++ b/src/dpp/presence.cpp @@ -72,7 +72,16 @@ presence::presence() : user_id(0), guild_id(0), flags(0) presence::presence(presence_status status, activity_type type, const std::string& activity_description) { dpp::activity a; + + /* Even if type is custom, a name is still required. + * We'll just set the name as this activity_description as it won't be used if custom either way. */ a.name = activity_description; + + /* If the type is custom, set the state as "activity_description" */ + if(type == activity_type::at_custom) { + a.state = activity_description; + } + a.type = type; activities.clear(); activities.emplace_back(a); @@ -254,7 +263,12 @@ std::string presence::build_json(bool with_id) const { { "type", i.type } }); if (!i.url.empty()) j2["url"] = i.url; - if (!i.state.empty()) j2["details"] = i.state; // bot activity is details, not state + + if(i.type == activity_type::at_custom) { + if (!i.state.empty()) j2["state"] = i.state; /* When type is custom, bot needs to use "state" */ + } else { + if (!i.state.empty()) j2["details"] = i.state; /* Otherwise, the bot needs to use "details" */ + } j["d"]["activities"].push_back(j2); }