Redesigned the DiscordBotCore by splitting it into multiple projects. Created a WebUI and preparing to remove the DiscordBot application
This commit is contained in:
21
DiscordBotCore.PluginCore/DiscordBotCore.PluginCore.csproj
Normal file
21
DiscordBotCore.PluginCore/DiscordBotCore.PluginCore.csproj
Normal file
@@ -0,0 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Discord.Net" Version="3.17.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DiscordBotCore.Logging\DiscordBotCore.Logging.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Helpers\Execution\DbSlashCommand\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,26 @@
|
||||
using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
using DiscordBotCore.Logging;
|
||||
|
||||
namespace DiscordBotCore.PluginCore.Helpers.Execution.DbCommand;
|
||||
|
||||
public class DbCommandExecutingArgument : IDbCommandExecutingArgument
|
||||
{
|
||||
public SocketCommandContext Context { get; init; }
|
||||
public string CleanContent { get; init; }
|
||||
public string CommandUsed { get; init; }
|
||||
public string[]? Arguments { get; init; }
|
||||
public ILogger Logger { get; init; }
|
||||
public DirectoryInfo PluginBaseDirectory { get; init; }
|
||||
|
||||
public DbCommandExecutingArgument(ILogger logger, SocketCommandContext context, string cleanContent, string commandUsed, string[]? arguments, DirectoryInfo pluginBaseDirectory)
|
||||
{
|
||||
this.Logger = logger;
|
||||
this.Context = context;
|
||||
this.CleanContent = cleanContent;
|
||||
this.CommandUsed = commandUsed;
|
||||
this.Arguments = arguments;
|
||||
this.PluginBaseDirectory = pluginBaseDirectory;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
using DiscordBotCore.Logging;
|
||||
|
||||
namespace DiscordBotCore.PluginCore.Helpers.Execution.DbCommand;
|
||||
|
||||
public interface IDbCommandExecutingArgument
|
||||
{
|
||||
ILogger Logger { get; init; }
|
||||
string CleanContent { get; init; }
|
||||
string CommandUsed { get; init; }
|
||||
string[]? Arguments { get; init; }
|
||||
|
||||
SocketCommandContext Context { get; init; }
|
||||
public DirectoryInfo PluginBaseDirectory { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Discord.WebSocket;
|
||||
using DiscordBotCore.Logging;
|
||||
|
||||
namespace DiscordBotCore.PluginCore.Helpers.Execution.DbEvent;
|
||||
|
||||
public class DbEventExecutingArgument : IDbEventExecutingArgument
|
||||
{
|
||||
public ILogger Logger { get; }
|
||||
public DiscordSocketClient Client { get; }
|
||||
public string BotPrefix { get; }
|
||||
public DirectoryInfo PluginBaseDirectory { get; }
|
||||
|
||||
public DbEventExecutingArgument(ILogger logger, DiscordSocketClient client, string botPrefix, DirectoryInfo pluginBaseDirectory)
|
||||
{
|
||||
Logger = logger;
|
||||
Client = client;
|
||||
BotPrefix = botPrefix;
|
||||
PluginBaseDirectory = pluginBaseDirectory;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using Discord.WebSocket;
|
||||
using DiscordBotCore.Logging;
|
||||
|
||||
namespace DiscordBotCore.PluginCore.Helpers.Execution.DbEvent;
|
||||
|
||||
public interface IDbEventExecutingArgument
|
||||
{
|
||||
public ILogger Logger { get; }
|
||||
public DiscordSocketClient Client { get; }
|
||||
public string BotPrefix { get; }
|
||||
public DirectoryInfo PluginBaseDirectory { get; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace DiscordBotCore.PluginCore.Helpers;
|
||||
|
||||
public interface IInternalActionOption
|
||||
{
|
||||
string OptionName { get; set; }
|
||||
string OptionDescription { get; set; }
|
||||
List<InternalActionOption> SubOptions { get; set; }
|
||||
}
|
||||
23
DiscordBotCore.PluginCore/Helpers/InternalActionOption.cs
Normal file
23
DiscordBotCore.PluginCore/Helpers/InternalActionOption.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
namespace DiscordBotCore.PluginCore.Helpers;
|
||||
|
||||
public class InternalActionOption : IInternalActionOption
|
||||
{
|
||||
public string OptionName { get; set; }
|
||||
public string OptionDescription { get; set; }
|
||||
|
||||
public List<InternalActionOption> SubOptions { get; set; }
|
||||
|
||||
public InternalActionOption(string optionName, string optionDescription, List<InternalActionOption> subOptions)
|
||||
{
|
||||
OptionName = optionName;
|
||||
OptionDescription = optionDescription;
|
||||
SubOptions = subOptions;
|
||||
}
|
||||
|
||||
public InternalActionOption(string optionName, string optionDescription)
|
||||
{
|
||||
OptionName = optionName;
|
||||
OptionDescription = optionDescription;
|
||||
SubOptions = new List<InternalActionOption>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace DiscordBotCore.PluginCore.Helpers;
|
||||
|
||||
public enum InternalActionRunType
|
||||
{
|
||||
OnStartup,
|
||||
OnCall,
|
||||
OnStartupAndCall
|
||||
}
|
||||
47
DiscordBotCore.PluginCore/Interfaces/IDbCommand.cs
Normal file
47
DiscordBotCore.PluginCore/Interfaces/IDbCommand.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using DiscordBotCore.Logging;
|
||||
using DiscordBotCore.PluginCore.Helpers;
|
||||
using DiscordBotCore.PluginCore.Helpers.Execution.DbCommand;
|
||||
|
||||
namespace DiscordBotCore.PluginCore.Interfaces;
|
||||
|
||||
public interface IDbCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// Command to be executed
|
||||
/// It's CaSe SeNsItIvE
|
||||
/// </summary>
|
||||
string Command { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Command aliases. Users may use this to execute the command
|
||||
/// </summary>
|
||||
List<string>? Aliases { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Command description
|
||||
/// </summary>
|
||||
string Description { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The usage for your command.
|
||||
/// It will be displayed when users type help
|
||||
/// </summary>
|
||||
string Usage { get; }
|
||||
|
||||
/// <summary>
|
||||
/// true if the command requre admin, otherwise false
|
||||
/// </summary>
|
||||
bool RequireAdmin { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The main body of the command. This is what is executed when user calls the command in Server
|
||||
/// </summary>
|
||||
/// <param name="args">The Discord Context</param>
|
||||
Task ExecuteServer(IDbCommandExecutingArgument args) => Task.CompletedTask;
|
||||
|
||||
/// <summary>
|
||||
/// The main body of the command. This is what is executed when user calls the command in DM
|
||||
/// </summary>
|
||||
/// <param name="args">The Discord Context</param>
|
||||
Task ExecuteDm(IDbCommandExecutingArgument args) => Task.CompletedTask;
|
||||
}
|
||||
23
DiscordBotCore.PluginCore/Interfaces/IDbEvent.cs
Normal file
23
DiscordBotCore.PluginCore/Interfaces/IDbEvent.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using DiscordBotCore.PluginCore.Helpers;
|
||||
using DiscordBotCore.PluginCore.Helpers.Execution.DbEvent;
|
||||
|
||||
namespace DiscordBotCore.PluginCore.Interfaces;
|
||||
|
||||
public interface IDbEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the event
|
||||
/// </summary>
|
||||
string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The description of the event
|
||||
/// </summary>
|
||||
string Description { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The method that is invoked when the event is loaded into memory
|
||||
/// </summary>
|
||||
/// <param name="args">The arguments for the start method</param>
|
||||
Task Start(IDbEventExecutingArgument args);
|
||||
}
|
||||
22
DiscordBotCore.PluginCore/Interfaces/IDbSlashCommand.cs
Normal file
22
DiscordBotCore.PluginCore/Interfaces/IDbSlashCommand.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
using DiscordBotCore.Logging;
|
||||
|
||||
namespace DiscordBotCore.PluginCore.Interfaces;
|
||||
|
||||
public interface IDbSlashCommand
|
||||
{
|
||||
string Name { get; }
|
||||
string Description { get; }
|
||||
bool CanUseDm { get; }
|
||||
bool HasInteraction { get; }
|
||||
|
||||
List<SlashCommandOptionBuilder> Options { get; }
|
||||
|
||||
void ExecuteServer(ILogger logger, SocketSlashCommand context)
|
||||
{ }
|
||||
|
||||
void ExecuteDm(ILogger logger, SocketSlashCommand context) { }
|
||||
|
||||
Task ExecuteInteraction(ILogger logger, SocketInteraction interaction) => Task.CompletedTask;
|
||||
}
|
||||
Reference in New Issue
Block a user