Slash command test.

This commit is contained in:
clienthax 2022-06-02 17:44:49 +01:00
parent c7a61fb0c0
commit 81c0e0d364
2 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,37 @@
using CompatBot.Utils;
using DSharpPlus;
using DSharpPlus.Entities;
using DSharpPlus.SlashCommands;
using System.Threading.Tasks;
namespace CompatBot.Commands
{
internal sealed class SlashTest: ApplicationCommandModule
{
[SlashCommand("credits", "Author Credit")]
// TODO [Aliases("about")]
public async Task About(InteractionContext ctx)
{
var hcorion = ctx.Client.GetEmoji(":hcorion:", DiscordEmoji.FromUnicode("🍁"));
var clienthax = ctx.Client.GetEmoji(":gooseknife:", DiscordEmoji.FromUnicode("🐱"));
var embed = new DiscordEmbedBuilder
{
Title = "RPCS3 Compatibility Bot",
Url = "https://github.com/RPCS3/discord-bot",
Color = DiscordColor.Purple,
}.AddField("Made by",
"💮 13xforever\n" +
"🇭🇷 Roberto Anić Banić aka nicba1010\n" +
$"{clienthax} clienthax\n"
)
.AddField("People who ~~broke~~ helped test the bot",
"🐱 Juhn\n" +
$"{hcorion} hcorion\n" +
"🙃 TGE\n" +
"🍒 Maru\n" +
"♋ Tourghool");
await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().AddEmbed(embed.Build()));
}
}
}

View File

@ -19,6 +19,7 @@ using DSharpPlus.CommandsNext;
using DSharpPlus.Entities;
using DSharpPlus.Interactivity;
using DSharpPlus.Interactivity.Extensions;
using DSharpPlus.SlashCommands;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration.UserSecrets;
using Microsoft.Extensions.DependencyInjection;
@ -142,6 +143,9 @@ namespace CompatBot
Intents = DiscordIntents.All,
};
using var client = new DiscordClient(config);
var slashCommands = client.UseSlashCommands();
slashCommands.RegisterCommands<SlashTest>();
var commands = client.UseCommandsNext(new()
{
StringPrefixes = new[] {Config.CommandPrefix, Config.AutoRemoveCommandPrefix},