Renamed PluginManager to DiscordBotCore.
Revamped the Logger
This commit is contained in:
@@ -79,7 +79,7 @@ internal class Help: DBCommand
|
||||
);
|
||||
if (cmd == null) return null;
|
||||
|
||||
embedBuilder.AddField("Usage", Config.AppSettings["prefix"] + cmd.Usage);
|
||||
embedBuilder.AddField("Usage", Config.Application.CurrentApplication.ApplicationEnvironmentVariables["prefix"] + cmd.Usage);
|
||||
embedBuilder.AddField("Description", cmd.Description);
|
||||
if (cmd.Aliases is null)
|
||||
return embedBuilder;
|
||||
|
||||
@@ -18,8 +18,8 @@ namespace DiscordBotUI.Bot
|
||||
|
||||
public async Task InitializeBot()
|
||||
{
|
||||
string token = Config.AppSettings["token"];
|
||||
string prefix = Config.AppSettings["prefix"];
|
||||
string token = Config.Application.CurrentApplication.ApplicationEnvironmentVariables["token"];
|
||||
string prefix = Config.Application.CurrentApplication.ApplicationEnvironmentVariables["prefix"];
|
||||
PluginManager.Bot.Boot discordBooter = new PluginManager.Bot.Boot(token, prefix);
|
||||
await discordBooter.Awake();
|
||||
}
|
||||
@@ -32,14 +32,14 @@ namespace DiscordBotUI.Bot
|
||||
{
|
||||
if (data.IsSuccess)
|
||||
{
|
||||
Config.Logger.Log("Successfully loaded command : " + data.PluginName, typeof(ICommandAction),
|
||||
Application.CurrentApplication.Logger.Log("Successfully loaded command : " + data.PluginName, typeof(ICommandAction),
|
||||
LogType.INFO
|
||||
);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Config.Logger.Log("Failed to load command : " + data.PluginName + " because " + data.ErrorMessage,
|
||||
Application.CurrentApplication.Logger.Log("Failed to load command : " + data.PluginName + " because " + data.ErrorMessage,
|
||||
typeof(ICommandAction), LogType.ERROR
|
||||
);
|
||||
}
|
||||
@@ -48,13 +48,13 @@ namespace DiscordBotUI.Bot
|
||||
{
|
||||
if (data.IsSuccess)
|
||||
{
|
||||
Config.Logger.Log("Successfully loaded event : " + data.PluginName, typeof(ICommandAction),
|
||||
Application.CurrentApplication.Logger.Log("Successfully loaded event : " + data.PluginName, typeof(ICommandAction),
|
||||
LogType.INFO
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
Config.Logger.Log("Failed to load event : " + data.PluginName + " because " + data.ErrorMessage,
|
||||
Application.CurrentApplication.Logger.Log("Failed to load event : " + data.PluginName + " because " + data.ErrorMessage,
|
||||
typeof(ICommandAction), LogType.ERROR
|
||||
);
|
||||
}
|
||||
@@ -64,13 +64,13 @@ namespace DiscordBotUI.Bot
|
||||
{
|
||||
if (data.IsSuccess)
|
||||
{
|
||||
Config.Logger.Log("Successfully loaded slash command : " + data.PluginName, typeof(ICommandAction),
|
||||
Application.CurrentApplication.Logger.Log("Successfully loaded slash command : " + data.PluginName, typeof(ICommandAction),
|
||||
LogType.INFO
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
Config.Logger.Log("Failed to load slash command : " + data.PluginName + " because " + data.ErrorMessage,
|
||||
Application.CurrentApplication.Logger.Log("Failed to load slash command : " + data.PluginName + " because " + data.ErrorMessage,
|
||||
typeof(ICommandAction), LogType.ERROR
|
||||
);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\PluginManager\PluginManager.csproj" />
|
||||
<ProjectReference Include="..\..\PluginManager\DiscordBotCore.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -28,18 +28,18 @@ public partial class HomePage : Window
|
||||
{
|
||||
await Config.Initialize();
|
||||
|
||||
if(!Config.AppSettings.ContainsAllKeys("token", "prefix"))
|
||||
if(!Config.Application.CurrentApplication.ApplicationEnvironmentVariables.ContainsAllKeys("token", "prefix"))
|
||||
{
|
||||
await new SettingsPage().ShowDialog(this);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(Config.AppSettings["token"]) || string.IsNullOrWhiteSpace(Config.AppSettings["prefix"]))
|
||||
if (string.IsNullOrWhiteSpace(Config.Application.CurrentApplication.ApplicationEnvironmentVariables["token"]) || string.IsNullOrWhiteSpace(Config.Application.CurrentApplication.ApplicationEnvironmentVariables["prefix"]))
|
||||
Environment.Exit(-1);
|
||||
}
|
||||
|
||||
|
||||
textBoxToken.Text = Config.AppSettings["token"];
|
||||
textBoxPrefix.Text = Config.AppSettings["prefix"];
|
||||
textBoxServerId.Text = Config.AppSettings["ServerID"];
|
||||
textBoxToken.Text = Config.Application.CurrentApplication.ApplicationEnvironmentVariables["token"];
|
||||
textBoxPrefix.Text = Config.Application.CurrentApplication.ApplicationEnvironmentVariables["prefix"];
|
||||
textBoxServerId.Text = Config.Application.CurrentApplication.ApplicationEnvironmentVariables["ServerID"];
|
||||
}
|
||||
|
||||
private void SetTextToTB(Log logMessage)
|
||||
@@ -50,7 +50,7 @@ public partial class HomePage : Window
|
||||
private async void ButtonStartBotClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
|
||||
Config.Logger.OnLog += async (sender, logMessage) =>
|
||||
Application.CurrentApplication.Logger.OnLog += async (sender, logMessage) =>
|
||||
{
|
||||
await Dispatcher.UIThread.InvokeAsync(() => SetTextToTB(logMessage), DispatcherPriority.Background);
|
||||
};
|
||||
|
||||
@@ -30,13 +30,13 @@ public partial class SettingsPage : Window
|
||||
return;
|
||||
}
|
||||
|
||||
Config.AppSettings.Add("token", token);
|
||||
Config.AppSettings.Add("prefix", botPrefix);
|
||||
Config.AppSettings.Add("ServerID", serverId);
|
||||
Config.Application.CurrentApplication.ApplicationEnvironmentVariables.Add("token", token);
|
||||
Config.Application.CurrentApplication.ApplicationEnvironmentVariables.Add("prefix", botPrefix);
|
||||
Config.Application.CurrentApplication.ApplicationEnvironmentVariables.Add("ServerID", serverId);
|
||||
|
||||
await Config.AppSettings.SaveToFile();
|
||||
await Config.Application.CurrentApplication.ApplicationEnvironmentVariables.SaveToFile();
|
||||
|
||||
Config.Logger.Log("Config Saved");
|
||||
Application.CurrentApplication.Logger.Log("Config Saved");
|
||||
|
||||
Close();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user