private static async void ActivityManager_OnActivityJoin(string secret) { if (Multiplayer.IsActive) { Log.Warn("Cannot join lobby from Discord, we are already in a lobby."); return; } if (string.IsNullOrWhiteSpace(secret)) { Log.Warn("Received Discord invite without IP address."); return; } var ipAddresses = secret.FromBase64().Split(';'); if (ipAddresses.Length != 1 && ipAddresses.Length != 3) { Log.Warn("Received invalid discord invite."); return; } string ipAddress = string.Empty; if (ipAddresses.Length == 1 && ipAddresses[0].Contains("ngrok")) { ipAddress = ipAddresses[0]; } if (string.IsNullOrWhiteSpace(ipAddress) && await IPUtils.IsIPv6Supported()) { if (ipAddresses.Length > 1) { if (IPUtils.IsIPv6(ipAddresses[1])) { ipAddress = $"{ipAddresses[1]}:{ipAddresses[2]}"; } } } if (string.IsNullOrWhiteSpace(ipAddress)) { if (IPUtils.IsIPv4(ipAddresses[0])) { ipAddress = $"{ipAddresses[0]}:{ipAddresses[2]}"; } } if (string.IsNullOrWhiteSpace(ipAddress)) { Log.Warn("Received Discord invite with invalid IP address."); return; } Log.Info("Joining lobby from Discord..."); UIMainMenu_Patch.OnMultiplayerButtonClick(); UIMainMenu_Patch.JoinGame($"{ipAddress}"); DiscordManager.UpdateRichPresence(ip: secret, secretPassthrough: true, updateTimestamp: true); }