From fd909d38512043803d8bb4bfd8c29854fba30e85 Mon Sep 17 00:00:00 2001 From: Madpeter <57852827+Madpeterz@users.noreply.github.com> Date: Fri, 8 Dec 2023 09:14:56 +0000 Subject: [PATCH] Update DiscordService.cs adding some extra triggers to connect discord --- SecondBotEvents/Services/DiscordService.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/SecondBotEvents/Services/DiscordService.cs b/SecondBotEvents/Services/DiscordService.cs index a62eb57..680ebe1 100644 --- a/SecondBotEvents/Services/DiscordService.cs +++ b/SecondBotEvents/Services/DiscordService.cs @@ -516,6 +516,7 @@ namespace SecondBotEvents.Services { LogFormater.Info("Discord service [Avi link]"); AcceptEventsFromSL = false; + LoginEventsAttached = false; GetClient().Network.LoggedOut += BotLoggedOut; GetClient().Self.ChatFromSimulator -= LocalChat; GetClient().Self.IM -= BotImMessage; @@ -527,6 +528,7 @@ namespace SecondBotEvents.Services protected void BotLoggedOut(object o, LoggedOutEventArgs e) { + LoginEventsAttached = false; GetClient().Network.SimConnected += BotLoggedIn; GetClient().Self.ChatFromSimulator -= LocalChat; GetClient().Self.IM -= BotImMessage; @@ -916,13 +918,19 @@ namespace SecondBotEvents.Services if (DiscordIsReady == true) { DiscordClient.SetGameAsync(e.Simulator.Name, null, ActivityType.Playing); + if(LoginEventsAttached == false) + { + LoginEvents(); + } } } + protected bool LoginEventsAttached = false; protected void LoginEvents() { - if((AcceptEventsFromSL == true) && (DiscordIsReady == true)) + if((AcceptEventsFromSL == true) && (DiscordIsReady == true) && (LoginEventsAttached == false)) { + LoginEventsAttached = true; GetClient().Self.IM += BotImMessage; GetClient().Network.SimConnected -= BotCurrentSim; GetClient().Self.ChatFromSimulator += LocalChat;