public void BotStart() { try { ConnectionCredentials credentials = new ConnectionCredentials("JustAnyBot", Settings.AuthToken); client = new TwitchClient(); client.Initialize(credentials); client.OnConnected += Client_OnConnected; client.AddChatCommandIdentifier(char.Parse("#")); client.OnConnectionError += Client_ConnectionError; client.OnUserTimedout += Client_TimedOut; if (Settings.AnnounceJoin) { client.OnUserJoined += Client_UserJoined; } client.OnChatCommandReceived += Client_ChatCommandReceived; if (Settings.AnnounceLeave) { client.OnUserLeft += Client_UserLeft; } if (Settings.ThankSubscribers) { client.OnNewSubscriber += Client_Subscribed; } api = new TwitchAPI(); api.Settings.ClientId = Settings.ClientId; api.Settings.AccessToken = Settings.AuthToken; GetInfo(); if (Settings.ThankFollowers) { follower = new FollowerService(api, 5); follower.SetChannelByChannelId(Settings.ChannelId); follower.OnNewFollowersDetected += Client_Followed; follower.StartService(); } if (Settings.AnnounceBan) { client.OnUserBanned += Client_Banned; } if (Settings.AnnounceNowHosting) { client.OnNowHosting += Client_Hosting; } UserApi = new TwitchLib.Api.Sections.Users.V5Api(api); client.Connect(); window.Dispatcher.Invoke((Action)(() => { window.BotStarting(); })); } catch (ThreadAbortException e) { MessageBox.Show("Erro: A Janela fechou antes de obter o AuthToken"); } catch (Exception e) { MessageBox.Show($"An exception has occurred: \n\n{e.Message}"); } }