Improved UI experience for the Main page

This commit is contained in:
2025-04-06 18:36:20 +03:00
parent 8aaefac706
commit 87c889266b
8 changed files with 176 additions and 48 deletions

View File

@@ -20,7 +20,7 @@ public class DiscordBotApplication : IDiscordBotApplication
private readonly IConfiguration _Configuration;
private readonly IPluginLoader _PluginLoader;
private bool IsReady { get; set; }
public bool IsReady { get; private set; }
public DiscordSocketClient Client { get; private set; }
@@ -34,6 +34,28 @@ public class DiscordBotApplication : IDiscordBotApplication
this._PluginLoader = pluginLoader;
}
public async Task StopAsync()
{
if (!IsReady)
{
_Logger.Log("Can not stop the bot. It is not yet initialized.", this, LogType.Error);
return;
}
await Client.LogoutAsync();
await Client.StopAsync();
Client.Log -= Log;
Client.LoggedIn -= LoggedIn;
Client.Ready -= Ready;
Client.Disconnected -= Client_Disconnected;
await Client.DisposeAsync();
IsReady = false;
}
/// <summary>
/// The start method for the bot. This method is used to load the bot
/// </summary>
@@ -91,6 +113,7 @@ public class DiscordBotApplication : IDiscordBotApplication
private Task LoggedIn()
{
_Logger.Log("Successfully Logged In", this);
_PluginLoader.SetClient(Client);
return Task.CompletedTask;
}