discord-v status fixs

This commit is contained in:
Madpeterz 2021-01-31 02:45:30 +00:00
parent 3f85d1bae8
commit 108578656b
5 changed files with 64 additions and 53 deletions

View file

@ -209,6 +209,8 @@ namespace BetterSecondBot.DiscordSupervisor
} }
protected async Task DiscordRebuildChannels() protected async Task DiscordRebuildChannels()
{
if (DiscordServer != null)
{ {
List<string> required_cats = new List<string>() { "bot", "group", "im" }; List<string> required_cats = new List<string>() { "bot", "group", "im" };
IReadOnlyCollection<ICategoryChannel> found_cats = await DiscordServer.GetCategoriesAsync(CacheMode.AllowDownload); IReadOnlyCollection<ICategoryChannel> found_cats = await DiscordServer.GetCategoriesAsync(CacheMode.AllowDownload);
@ -232,7 +234,7 @@ namespace BetterSecondBot.DiscordSupervisor
ICategoryChannel newcat = await DiscordServer.CreateCategoryAsync(A).ConfigureAwait(true); ICategoryChannel newcat = await DiscordServer.CreateCategoryAsync(A).ConfigureAwait(true);
catmap.Add(A, newcat); catmap.Add(A, newcat);
} }
List<string> required_channels = new List<string>() { "status", "interface","localchat" }; List<string> required_channels = new List<string>() { "status", "interface", "localchat" };
IReadOnlyCollection<ITextChannel> found_chans = await DiscordServer.GetTextChannelsAsync(CacheMode.AllowDownload); IReadOnlyCollection<ITextChannel> found_chans = await DiscordServer.GetTextChannelsAsync(CacheMode.AllowDownload);
List<string> GroupChannels = new List<string>(); List<string> GroupChannels = new List<string>();
foreach (ITextChannel chan in found_chans) foreach (ITextChannel chan in found_chans)
@ -271,4 +273,5 @@ namespace BetterSecondBot.DiscordSupervisor
} }
} }
} }
}
} }

View file

@ -57,7 +57,6 @@ namespace BetterSecondBot.DiscordSupervisor
if (myconfig.DiscordFull_Enable == true) if (myconfig.DiscordFull_Enable == true)
{ {
_ = StartDiscordClientService(); _ = StartDiscordClientService();
login_bot(false);
keep_alive(); keep_alive();
} }
else else
@ -67,11 +66,14 @@ namespace BetterSecondBot.DiscordSupervisor
} }
protected override void login_bot(bool self_keep_alive) protected override void login_bot(bool self_keep_alive)
{
if (controler != null)
{ {
controler = new CliExitOnLogout(myconfig, running_as_docker, self_keep_alive); controler = new CliExitOnLogout(myconfig, running_as_docker, self_keep_alive);
controler.Bot.setDiscordClient(DiscordClient); controler.Bot.setDiscordClient(DiscordClient);
attach_events(); attach_events();
} }
}
} }
} }

View file

@ -28,6 +28,10 @@ namespace BetterSecondBot.DiscordSupervisor
DiscordServer = DiscordClient.GetGuild(myconfig.DiscordFull_ServerID); DiscordServer = DiscordClient.GetGuild(myconfig.DiscordFull_ServerID);
if (DiscordServer != null) if (DiscordServer != null)
{ {
if (myconfig.DiscordFull_Enable == true)
{
login_bot(false);
}
DiscordUnixTimeOnine = helpers.UnixTimeNow(); DiscordUnixTimeOnine = helpers.UnixTimeNow();
DiscordClientConnected = true; DiscordClientConnected = true;
await DiscordRebuildChannels(); await DiscordRebuildChannels();

View file

@ -39,6 +39,7 @@ namespace BetterSecondBot.DiscordSupervisor
return await MarkMessage(message, "❌"); return await MarkMessage(message, "❌");
} }
controler.Bot.KillMePlease(); controler.Bot.KillMePlease();
controler = null;
return await MarkMessage(message, "✅").ConfigureAwait(false); return await MarkMessage(message, "✅").ConfigureAwait(false);
} }
else if(message.Content == "exit") else if(message.Content == "exit")

View file

@ -15,6 +15,7 @@ namespace BetterSecondBot.DiscordSupervisor
protected bool discord_group_relay; protected bool discord_group_relay;
protected DiscordSocketClient DiscordClient; protected DiscordSocketClient DiscordClient;
protected bool DiscordClientConnected; protected bool DiscordClientConnected;
protected IGuild DiscordServer; protected IGuild DiscordServer;
protected string LastSendDiscordStatus = ""; protected string LastSendDiscordStatus = "";
protected long DiscordUnixTimeOnine; protected long DiscordUnixTimeOnine;