Skip to content

Commit

Permalink
fix: corrected presence.cpp to allow custom statuses. (brainboxdotcc#848
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Jaskowicz1 authored and Mishura4 committed Sep 17, 2023
1 parent 66f00a4 commit bf05ca2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ docs/doxygen_sqlite3.db
build
buildtools/composer.phar
src/build
cmake-build-debug

# tests
test
Expand Down
16 changes: 15 additions & 1 deletion src/dpp/presence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit bf05ca2

Please sign in to comment.