public static void ProcessDiscordPresence(g_Instance frame) { lastDiscordPresenceTime = DateTime.Now; if (Settings.Default.discordRichPresence) { if (discordClient == null || discordClient.IsDisposed) { //InitializeDiscord(); LogRow(LogType.Error, "Discord RP client disposed while in normal thread."); } RichPresence rp = new RichPresence(); if (frame == null) { discordClient.SetPresence(null); return; } StringBuilder details = new StringBuilder(); if (frame.map_name == "mpl_arena_a") { if (frame.teams[2].players.Find(p => p.name == frame.client_name) != null) { details.Append("Spectating "); } else { details.Append("Playing "); } details.Append("Arena "); if (frame.private_match) { details.Append("pvt."); rp.WithSecrets(new Secrets { JoinSecret = "spark://c/" + frame.sessionid, SpectateSecret = "spark://s/" + frame.sessionid, }); } else { details.Append("pub."); } rp.State = "Score: " + frame.orange_points + " - " + frame.blue_points; rp.Timestamps = new Timestamps { End = frame.game_status == "post_match" ? DateTime.UtcNow : DateTime.UtcNow.AddSeconds(frame.game_clock) }; rp.WithParty(new Party { ID = frame.sessionid, Size = frame.GetAllPlayers().Count, Max = frame.private_match ? 15 : 8 }); } else if (frame.map_name == "mpl_lobby_b2") { details.Append("in EchoVR Lobby"); // how long have we been in the lobby? if (!inLobby) { inLobby = true; lobbyEntryTime = DateTime.UtcNow; } rp.Timestamps = new Timestamps { Start = lobbyEntryTime }; } else // if (frame.map_name == "whatever combat is") { details.Append("Playing Combat"); } rp.Details = details.ToString(); rp.Assets = new Assets { LargeImageKey = "echo_arena_store_icon", LargeImageText = "Rich presence from Spark" }; discordClient.SetPresence(rp); } else { if (discordClient != null && !discordClient.IsDisposed) { discordClient.Dispose(); } } }