From 81905460da0d6d3bcc0122761bdc3d83e798615b Mon Sep 17 00:00:00 2001 From: Andrei Tudor Date: Fri, 30 May 2025 12:09:48 +0300 Subject: [PATCH] Updated code formatting --- .../Interfaces/IDbCommand.cs | 4 +--- .../Interfaces/IDbEvent.cs | 3 +-- DiscordBotCore/Bot/CommandHandler.cs | 14 ++++++++++++-- DiscordBotCore/Bot/DiscordBotApplication.cs | 10 +++++----- WebUI/Components/App.razor | 2 ++ WebUI/Components/Layout/NavMenu.razor | 2 +- WebUI/Components/Pages/Home.razor | 2 -- WebUI/Components/Pages/Plugins/Local.razor | 19 +++++++++++-------- WebUI/Program.cs | 4 ++-- WebUI/WebUI.csproj | 2 +- 10 files changed, 36 insertions(+), 26 deletions(-) diff --git a/DiscordBotCore.PluginCore/Interfaces/IDbCommand.cs b/DiscordBotCore.PluginCore/Interfaces/IDbCommand.cs index b0f3c93..f430f45 100644 --- a/DiscordBotCore.PluginCore/Interfaces/IDbCommand.cs +++ b/DiscordBotCore.PluginCore/Interfaces/IDbCommand.cs @@ -1,6 +1,4 @@ -using DiscordBotCore.Logging; -using DiscordBotCore.PluginCore.Helpers; -using DiscordBotCore.PluginCore.Helpers.Execution.DbCommand; +using DiscordBotCore.PluginCore.Helpers.Execution.DbCommand; namespace DiscordBotCore.PluginCore.Interfaces; diff --git a/DiscordBotCore.PluginCore/Interfaces/IDbEvent.cs b/DiscordBotCore.PluginCore/Interfaces/IDbEvent.cs index d6d9703..bbe03ee 100644 --- a/DiscordBotCore.PluginCore/Interfaces/IDbEvent.cs +++ b/DiscordBotCore.PluginCore/Interfaces/IDbEvent.cs @@ -1,5 +1,4 @@ -using DiscordBotCore.PluginCore.Helpers; -using DiscordBotCore.PluginCore.Helpers.Execution.DbEvent; +using DiscordBotCore.PluginCore.Helpers.Execution.DbEvent; namespace DiscordBotCore.PluginCore.Interfaces; diff --git a/DiscordBotCore/Bot/CommandHandler.cs b/DiscordBotCore/Bot/CommandHandler.cs index d6e1add..bde2ca4 100644 --- a/DiscordBotCore/Bot/CommandHandler.cs +++ b/DiscordBotCore/Bot/CommandHandler.cs @@ -122,7 +122,6 @@ internal class CommandHandler : ICommandHandler cleanMessage = message.Content.Substring(mentionPrefix.Length + 1); } - else { plugin = _pluginLoader.Commands! @@ -137,16 +136,22 @@ internal class CommandHandler : ICommandHandler } if (plugin is null) + { return; + } if (plugin.RequireAdmin && !context.Message.Author.IsAdmin()) + { return; + } var split = cleanMessage.Split(' '); string[]? argsClean = null; if (split.Length > 1) + { argsClean = string.Join(' ', split, 1, split.Length - 1).Split(' '); + } DbCommandExecutingArgument cmd = new(_logger, context, @@ -162,8 +167,13 @@ internal class CommandHandler : ICommandHandler ); if (context.Channel is SocketDMChannel) + { await plugin.ExecuteDm(cmd); - else await plugin.ExecuteServer(cmd); + } + else + { + await plugin.ExecuteServer(cmd); + } } catch (Exception ex) { diff --git a/DiscordBotCore/Bot/DiscordBotApplication.cs b/DiscordBotCore/Bot/DiscordBotApplication.cs index 125dc93..d7edd8d 100644 --- a/DiscordBotCore/Bot/DiscordBotApplication.cs +++ b/DiscordBotCore/Bot/DiscordBotApplication.cs @@ -18,7 +18,7 @@ public class DiscordBotApplication : IDiscordBotApplication private CommandService _Service; private readonly ILogger _Logger; private readonly IConfiguration _Configuration; - private readonly IPluginLoader _pluginLoader; + private readonly IPluginLoader _PluginLoader; public bool IsReady { get; private set; } @@ -29,9 +29,9 @@ public class DiscordBotApplication : IDiscordBotApplication /// public DiscordBotApplication(ILogger logger, IConfiguration configuration, IPluginLoader pluginLoader) { - this._Logger = logger; + this._Logger = logger; this._Configuration = configuration; - this._pluginLoader = pluginLoader; + this._PluginLoader = pluginLoader; _InternalPluginLoader = pluginLoader; } @@ -86,7 +86,7 @@ public class DiscordBotApplication : IDiscordBotApplication await client.StartAsync(); - _CommandServiceHandler = new CommandHandler(_Logger, _pluginLoader, _Configuration, _Service); + _CommandServiceHandler = new CommandHandler(_Logger, _PluginLoader, _Configuration, _Service); await _CommandServiceHandler.InstallCommandsAsync(client); @@ -115,7 +115,7 @@ public class DiscordBotApplication : IDiscordBotApplication private Task LoggedIn() { _Logger.Log("Successfully Logged In", this); - _pluginLoader.SetDiscordClient(Client); + _PluginLoader.SetDiscordClient(Client); return Task.CompletedTask; } diff --git a/WebUI/Components/App.razor b/WebUI/Components/App.razor index f8e7e61..09e40f6 100644 --- a/WebUI/Components/App.razor +++ b/WebUI/Components/App.razor @@ -5,6 +5,8 @@ + diff --git a/WebUI/Components/Layout/NavMenu.razor b/WebUI/Components/Layout/NavMenu.razor index bc28c75..1ba9862 100644 --- a/WebUI/Components/Layout/NavMenu.razor +++ b/WebUI/Components/Layout/NavMenu.razor @@ -22,7 +22,7 @@ diff --git a/WebUI/Components/Pages/Home.razor b/WebUI/Components/Pages/Home.razor index 48d89cb..50966d7 100644 --- a/WebUI/Components/Pages/Home.razor +++ b/WebUI/Components/Pages/Home.razor @@ -13,8 +13,6 @@ @rendermode InteractiveServer -
diff --git a/WebUI/Components/Pages/Plugins/Local.razor b/WebUI/Components/Pages/Plugins/Local.razor index 5a10fe4..10e7b28 100644 --- a/WebUI/Components/Pages/Plugins/Local.razor +++ b/WebUI/Components/Pages/Plugins/Local.razor @@ -13,18 +13,21 @@ @inject NavigationManager Navigation

Installed Plugins

- + +
- + @* *@ @@ -34,14 +37,14 @@ - - + @* *@ } diff --git a/WebUI/Program.cs b/WebUI/Program.cs index 1df343f..34b9434 100644 --- a/WebUI/Program.cs +++ b/WebUI/Program.cs @@ -1,10 +1,10 @@ using WebUI; -using WebUI.Components; using WebUI.Services; +using WebUI.Components; var builder = WebApplication.CreateBuilder(args); -// Add services to the container. +// Add services to the container. builder.Services.AddRazorComponents() .AddInteractiveServerComponents(); builder.AddDiscordBotComponents(); diff --git a/WebUI/WebUI.csproj b/WebUI/WebUI.csproj index fb8d5f9..7bdbea9 100644 --- a/WebUI/WebUI.csproj +++ b/WebUI/WebUI.csproj @@ -4,7 +4,6 @@ net8.0enableenable - AnyCPU;x64;ARM64 @@ -13,6 +12,7 @@ +
Name Version Offline Added Actions - - *@ + @* *@ + @*
@plugin.Name @plugin.Version @(plugin.IsOfflineAdded ? "Yes" : "No") + @if (!plugin.IsOfflineAdded) { }