mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
Added Discord Bot Status and a button to Stop/Start the discord bot
This commit is contained in:
parent
a2b811972f
commit
13713b7092
18 changed files with 439 additions and 16 deletions
10
src/ServerManager.Discord/Enums/BotStatus.cs
Normal file
10
src/ServerManager.Discord/Enums/BotStatus.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
namespace ServerManagerTool.DiscordBot.Enums
|
||||
{
|
||||
public enum BotState
|
||||
{
|
||||
Unknown,
|
||||
Disabled,
|
||||
Stopped,
|
||||
Running,
|
||||
}
|
||||
}
|
||||
|
|
@ -30,17 +30,17 @@ namespace ServerManagerTool.DiscordBot
|
|||
|
||||
public async Task StartAsync(LogLevel logLevel, string discordToken, string commandPrefix, string dataDirectory, IEnumerable<string> botWhitelist, HandleCommandDelegate handleCommandCallback, HandleTranslationDelegate handleTranslationCallback, CancellationToken token)
|
||||
{
|
||||
if (Started)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Started = true;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(commandPrefix) || string.IsNullOrWhiteSpace(discordToken) || handleTranslationCallback is null || handleCommandCallback is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Started)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Started = true;
|
||||
Token = token;
|
||||
|
||||
var settings = new Dictionary<string, string>
|
||||
|
|
@ -121,6 +121,7 @@ namespace ServerManagerTool.DiscordBot
|
|||
}
|
||||
|
||||
await provider?.GetRequiredService<ShutdownService>().StopAsync();
|
||||
Started = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue