Port the emojify command to / commands

This commit is contained in:
Daan Boerlage 2021-11-14 01:18:36 +01:00
parent 1b396a529c
commit 699a93200b
Signed by: daan
GPG key ID: FCE070E1E4956606

View file

@ -0,0 +1,37 @@
using Geekbot.Core.Converters;
using Geekbot.Interactions;
using Geekbot.Interactions.ApplicationCommand;
using Geekbot.Interactions.Request;
using Geekbot.Interactions.Response;
namespace Geekbot.Web.Commands;
public class Emojify : InteractionBase
{
private struct Options
{
public const string Text = "text";
}
public override Command GetCommandInfo() => new ()
{
Name = "emojify",
Description = "Transcribe text into emojis",
Type = CommandType.ChatInput,
Options = new List<Option>()
{
new ()
{
Name = Options.Text,
Description = "The text to convert",
Required = true,
Type = OptionType.String,
}
}
};
public override Task<InteractionResponse> Exec(Interaction interaction)
{
var text = interaction.Data.Options.Find(o => o.Name == Options.Text);
return Task.FromResult(SimpleResponse(EmojiConverter.TextToEmoji(text.Value.GetString())));
}
}