adjust discord recovery
This commit is contained in:
parent
a05116c141
commit
62239f48ca
1 changed files with 40 additions and 32 deletions
|
|
@ -82,6 +82,10 @@ namespace SecondBotEvents.Services
|
||||||
LogFormater.Info("Discord service [Ready]");
|
LogFormater.Info("Discord service [Ready]");
|
||||||
DiscordIsReady = true;
|
DiscordIsReady = true;
|
||||||
DoServerChannelSetup();
|
DoServerChannelSetup();
|
||||||
|
if (master.BotClient.IsConnected() == true)
|
||||||
|
{
|
||||||
|
BotLoggedIn(this, new SimConnectedEventArgs(GetClient().Network.CurrentSim));
|
||||||
|
}
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -561,11 +565,6 @@ namespace SecondBotEvents.Services
|
||||||
LogFormater.Info("Discord service [Starting]");
|
LogFormater.Info("Discord service [Starting]");
|
||||||
master.SystemStatusMessagesEvent += SystemStatusEvent;
|
master.SystemStatusMessagesEvent += SystemStatusEvent;
|
||||||
master.BotClientNoticeEvent += BotClientRestart;
|
master.BotClientNoticeEvent += BotClientRestart;
|
||||||
if(master.BotClient.IsConnected() == true)
|
|
||||||
{
|
|
||||||
BotLoggedIn(this, new SimConnectedEventArgs(GetClient().Network.CurrentSim));
|
|
||||||
}
|
|
||||||
|
|
||||||
var config = new DiscordSocketConfig()
|
var config = new DiscordSocketConfig()
|
||||||
{
|
{
|
||||||
GatewayIntents = GatewayIntents.AllUnprivileged | GatewayIntents.GuildIntegrations | GatewayIntents.MessageContent
|
GatewayIntents = GatewayIntents.AllUnprivileged | GatewayIntents.GuildIntegrations | GatewayIntents.MessageContent
|
||||||
|
|
@ -595,20 +594,28 @@ namespace SecondBotEvents.Services
|
||||||
|
|
||||||
public override void Stop()
|
public override void Stop()
|
||||||
{
|
{
|
||||||
if(running == true)
|
if(running == false)
|
||||||
{
|
{
|
||||||
LogFormater.Info("Discord service [Stopping]");
|
return;
|
||||||
}
|
}
|
||||||
|
LogFormater.Info("Discord service [Stopping]");
|
||||||
running = false;
|
running = false;
|
||||||
|
if (master == null)
|
||||||
|
{
|
||||||
|
LogFormater.Info("Discord service [lost connection to master]");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
master.BotClientNoticeEvent -= BotClientRestart;
|
master.BotClientNoticeEvent -= BotClientRestart;
|
||||||
master.SystemStatusMessagesEvent -= SystemStatusEvent;
|
master.SystemStatusMessagesEvent -= SystemStatusEvent;
|
||||||
|
}
|
||||||
AcceptEventsFromSL = false;
|
AcceptEventsFromSL = false;
|
||||||
BotLoggedOut(this, new LoggedOutEventArgs(new List<UUID>()));
|
|
||||||
if (DiscordClient != null)
|
if (DiscordClient != null)
|
||||||
{
|
{
|
||||||
DiscordClient.Dispose();
|
LogFormater.Info("Discord service [Discord client cleanup]");
|
||||||
DiscordClient = null;
|
DiscordClient = null;
|
||||||
}
|
}
|
||||||
|
LogFormater.Info("Discord service [Stop done]");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void GroupCurrent(object o, CurrentGroupsEventArgs e)
|
protected void GroupCurrent(object o, CurrentGroupsEventArgs e)
|
||||||
|
|
@ -711,6 +718,7 @@ namespace SecondBotEvents.Services
|
||||||
{ "commands", "Send a command to the bot as if you are a master" },
|
{ "commands", "Send a command to the bot as if you are a master" },
|
||||||
{ "localchat", LocalChatPrefill() }
|
{ "localchat", LocalChatPrefill() }
|
||||||
};
|
};
|
||||||
|
ChannelMap = new Dictionary<string, ulong>();
|
||||||
|
|
||||||
SocketGuild server = DiscordClient.GetGuild(myConfig.GetServerID());
|
SocketGuild server = DiscordClient.GetGuild(myConfig.GetServerID());
|
||||||
foreach (ITextChannel channel in server.TextChannels)
|
foreach (ITextChannel channel in server.TextChannels)
|
||||||
|
|
@ -727,7 +735,7 @@ namespace SecondBotEvents.Services
|
||||||
if (ChannelMap.ContainsKey(channel.Name) == true)
|
if (ChannelMap.ContainsKey(channel.Name) == true)
|
||||||
{
|
{
|
||||||
ChannelMap[channel.Name] = channel.Id;
|
ChannelMap[channel.Name] = channel.Id;
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
ChannelMap.Add(channel.Name, channel.Id);
|
ChannelMap.Add(channel.Name, channel.Id);
|
||||||
|
|
||||||
|
|
@ -750,7 +758,7 @@ namespace SecondBotEvents.Services
|
||||||
if (CategoryMap.ContainsKey(category.Name) == true)
|
if (CategoryMap.ContainsKey(category.Name) == true)
|
||||||
{
|
{
|
||||||
CategoryMap[category.Name] = category.Id;
|
CategoryMap[category.Name] = category.Id;
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
CategoryMap.Add(category.Name, category.Id);
|
CategoryMap.Add(category.Name, category.Id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue