Improved UI experience for the Main page
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,16 @@ namespace DiscordBotCore.Bot;
|
||||
|
||||
public interface IDiscordBotApplication
|
||||
{
|
||||
public bool IsReady { get; }
|
||||
public DiscordSocketClient Client { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The start method for the bot. This method is used to load the bot
|
||||
/// </summary>
|
||||
Task StartAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Stops the bot and cleans up resources.
|
||||
/// </summary>
|
||||
Task StopAsync();
|
||||
}
|
||||
Reference in New Issue
Block a user