public LoginCredentials TryInitializeTwitchClient( IBot bot, IClientOptions clientOptions = null, LoginCredentials credentials = null) { // We need to get all the channel that the old client was connected to, // so we can rejoin those channels on the new client. //var previouslyJoinedChannels = Client == null // ? Array.Empty<JoinedChannel>() // : Client.JoinedChannels.ToArray(); if (clientOptions is not null) { CurrentClientOptions = clientOptions; } if (!CredentialsManager.TryUpdateLoginCredentials(credentials, out credentials)) { Writer.WriteLine("Failed to update login credentials"); return(null); } ConnectionCredentials = credentials.ConnectionCredentials; bot.LoginCredentials = credentials; Name = Name.From(credentials.ConnectionCredentials.TwitchUsername); IsBot = credentials.IsBot; if (PrimaryChannelName is null) { PrimaryChannelName = CredentialsManager.ApplicationCredentials.InitialTwitchPrimaryChannelName; } RefreshTwitchClient(bot); return(credentials); }