diff --git a/src/client/component/discord.cpp b/src/client/component/discord.cpp index dff5d22e..9dc203b5 100644 --- a/src/client/component/discord.cpp +++ b/src/client/component/discord.cpp @@ -16,6 +16,7 @@ namespace discord { DiscordRichPresence discord_presence; std::string state; + std::optional details{}; void update_discord() { @@ -23,6 +24,9 @@ namespace discord if (!game::CL_IsCgameInitialized()) { + state = {}; + details.reset(); + discord_presence.details = "Main Menu"; discord_presence.state = ""; @@ -37,7 +41,16 @@ namespace discord const auto mapname = game::UI_SafeTranslateString(utils::string::va("PRESENCE_SP_%s", map)); discord_presence.largeImageKey = map; - discord_presence.details = mapname; + + if (details.has_value()) + { + discord_presence.details = utils::string::va("%s", details.value().data()); + } + else + { + discord_presence.details = mapname; + } + discord_presence.state = state.data(); if (!discord_presence.startTimestamp) @@ -81,6 +94,16 @@ namespace discord update_discord(); }, scheduler::pipeline::async); }); + + command::add("setdiscorddetails", [](const command::params& params) + { + const std::string details_ = params.join(1); + scheduler::once([=]() + { + details = details_; + update_discord(); + }, scheduler::pipeline::async); + }); } private: diff --git a/src/client/game/scripting/lua/context.cpp b/src/client/game/scripting/lua/context.cpp index f35bf522..6bc8ed83 100644 --- a/src/client/game/scripting/lua/context.cpp +++ b/src/client/game/scripting/lua/context.cpp @@ -376,6 +376,11 @@ namespace scripting::lua command::execute(utils::string::va("setdiscordstate %s", state.data()), false); }; + game_type["setdiscorddetails"] = [](const game&, const std::string& state) + { + command::execute(utils::string::va("setdiscorddetails %s", state.data()), false); + }; + game_type["say"] = [](const game&) { };