private static void assignStrings() { LoginCredentials loginCredentials = new LoginCredentials(); try { loginCredentials = LoginCredentials.GetCredentials(@"C:\602counting\credentials.json"); } catch { Console.Write("Insert bot username "); loginCredentials.user = Console.ReadLine(); Console.Write("Insert bot oauth ID "); loginCredentials.oauth = Console.ReadLine(); Console.Write("Insert channel to autocount in "); loginCredentials.channel = Console.ReadLine(); Console.Write("Insert your twitch username "); loginCredentials.username = Console.ReadLine(); Console.Write("Insert IP from LiveSplit Server "); loginCredentials.ip = Console.ReadLine(); LoginCredentials.SaveCredentials(loginCredentials, @"C:\602counting\credentials.json"); } _ip = IPAddress.Parse(loginCredentials.ip); _user = loginCredentials.user; _oauth = loginCredentials.oauth; _channel = loginCredentials.channel; _username = loginCredentials.username; }
public static void SaveCredentials(LoginCredentials credentials, string fileName) { string jsonstring = JsonSerializer.Serialize(credentials); File.WriteAllText(fileName, jsonstring); }