mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
Add Discord RPC from TOHE (#20)
* Add Discord RPC from TOHE * Add Modded SA (MSA) Server
This commit is contained in:
1 parent
1cd7442b17
commit
644507aa3d
2 files changed
+67
-3
No files matched your search
@@ -0,0 +1,63 @@
|
||||
using AmongUs.Data;
|
||||
using Discord;
|
||||
using HarmonyLib;
|
||||
using System;
|
||||
|
||||
namespace TOHE.Patches
|
||||
{
|
||||
// Originally from Town of Us Rewritten, by Det
|
||||
[HarmonyPatch(typeof(ActivityManager), nameof(ActivityManager.UpdateActivity))]
|
||||
public class DiscordRPC
|
||||
{
|
||||
private static string lobbycode = "";
|
||||
private static string region = "";
|
||||
public static void Prefix([HarmonyArgument(0)] Activity activity)
|
||||
{
|
||||
var details = $"TOHE+ v{Main.PluginDisplayVersion}";
|
||||
activity.Details = details;
|
||||
|
||||
try
|
||||
{
|
||||
if (activity.State != "In Menus")
|
||||
{
|
||||
if (!DataManager.Settings.Gameplay.StreamerMode)
|
||||
{
|
||||
int maxSize = GameOptionsManager.Instance.currentNormalGameOptions.MaxPlayers;
|
||||
if (GameStates.IsLobby)
|
||||
{
|
||||
lobbycode = GameStartManager.Instance.GameRoomNameCode.text;
|
||||
region = ServerManager.Instance.CurrentRegion.Name;
|
||||
if (region == "North America") region = "NA";
|
||||
else if (region == "Europe") region = "EU";
|
||||
else if (region == "Asia") region = "AS";
|
||||
else if (region.Contains("MNA")) region = "MNA";
|
||||
else if (region.Contains("MEU")) region = "MEU";
|
||||
else if (region.Contains("MAS")) region = "MAS";
|
||||
}
|
||||
|
||||
if (lobbycode != "" && region != "")
|
||||
{
|
||||
details = $"TOHE+ - {lobbycode} ({region})";
|
||||
}
|
||||
|
||||
activity.Details = details;
|
||||
}
|
||||
else
|
||||
{
|
||||
details = $"TOHE+ v{Main.PluginDisplayVersion}";
|
||||
|
||||
activity.Details = details;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
Logger.Error("Error in updating discord rpc", "DiscordPatch");
|
||||
Logger.Exception(ex, "DiscordPatch");
|
||||
details = $"TOHE+ v{Main.PluginDisplayVersion}";
|
||||
activity.Details = details;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user