From 0a842c836b192352a326efcb99f902ee9f9c2691 Mon Sep 17 00:00:00 2001 From: cydyn <144380768+cydyn@users.noreply.github.com> Date: Wed, 28 Feb 2024 19:57:41 +0100 Subject: [PATCH] Repair Discord button --- .../Interface/Menu/LoginWindow.cs | 44 ++++++++++++++++--- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/Intersect.Client/Interface/Menu/LoginWindow.cs b/Intersect.Client/Interface/Menu/LoginWindow.cs index f1d2ebd544..d200df3a37 100644 --- a/Intersect.Client/Interface/Menu/LoginWindow.cs +++ b/Intersect.Client/Interface/Menu/LoginWindow.cs @@ -1,4 +1,5 @@ using System.Diagnostics; +using System.Runtime.InteropServices; using System.Security.Cryptography; using System.Text; @@ -237,17 +238,46 @@ void DiscordButton_Clicked(Base sender, ClickedEventArgs arguments) { try { - System.Diagnostics.Process.Start(new ProcessStartInfo + // Spróbuj otworzyć link za pomocą odpowiedniego polecenia dla danego systemu operacyjnego + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - FileName = "cmd", - Arguments = $"/c start https://discord.com/", - UseShellExecute = false, - CreateNoWindow = true - }); + System.Diagnostics.Process.Start(new ProcessStartInfo + { + FileName = "cmd", + Arguments = $"/c start https://discord.gg/ztKp93zvzb", + UseShellExecute = false, + CreateNoWindow = true + }); + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + System.Diagnostics.Process.Start(new ProcessStartInfo + { + FileName = "xdg-open", + Arguments = $"\"https://discord.gg/ztKp93zvzb\"", + UseShellExecute = false, + CreateNoWindow = true + }); + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + System.Diagnostics.Process.Start(new ProcessStartInfo + { + FileName = "open", + Arguments = $"\"https://discord.gg/ztKp93zvzb\"", + UseShellExecute = false, + CreateNoWindow = true + }); + } + else + { + // Obsługa błędu dla nieobsługiwanego systemu operacyjnego + Console.WriteLine("Unsupported operating system."); + } } catch (Exception ex) { - // Error if it doesn't open the link + // Obsłużanie błędu, jeśli nie udało się otworzyć linku Console.WriteLine($"Error opening Discord link: {ex.Message}"); } }