Updated WebUI

This commit is contained in:
2024-10-31 17:02:28 +02:00
parent 9e8bfbbe16
commit 44d8b4684e
2100 changed files with 14269 additions and 217 deletions

View File

@@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Discord;
using Discord.WebSocket;
using DiscordBotCore.Interfaces;
using DiscordBotCore.Loaders;
using DiscordBotCore.Others;
namespace DiscordBotWebUI.DiscordBot.Commands.SlashCommands;
public class Help: IDbSlashCommand
{
public string Name => "help";
public string Description => "This command allows you to check all loaded commands";
public bool CanUseDm => true;
public bool HasInteraction => false;
public List<SlashCommandOptionBuilder> Options =>
new()
{
new SlashCommandOptionBuilder()
.WithName("command")
.WithDescription("The command you want to get help for")
.WithRequired(false)
.WithType(ApplicationCommandOptionType.String)
};
public async void ExecuteServer(SocketSlashCommand context)
{
EmbedBuilder embedBuilder = new();
embedBuilder.WithTitle("Help Command");
var random = new Random();
Color c = new Color(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255));
embedBuilder.WithColor(c);
var slashCommands = PluginLoader.SlashCommands;
var options = context.Data.Options;
//Console.WriteLine("Options: " + options.Count);
if (options is null || options.Count == 0)
foreach (var slashCommand in slashCommands)
embedBuilder.AddField(slashCommand.Name, slashCommand.Description);
if (options.Count > 0)
{
var commandName = options.First().Value;
var slashCommand = slashCommands.FirstOrDefault(x => x.Name.TrimEnd() == commandName.ToString());
if (slashCommand is null)
{
await context.RespondAsync("Unknown Command " + commandName);
return;
}
embedBuilder.AddField("DM Usable:", slashCommand.CanUseDm, true)
.WithDescription(slashCommand.Description);
}
await context.RespondAsync(embed: embedBuilder.Build());
}
}