feat(bot): add support for Discord message context commands (#513)
This commit is contained in:
17
PluralKit.Bot/ApplicationCommandMeta/ApplicationCommand.cs
Normal file
17
PluralKit.Bot/ApplicationCommandMeta/ApplicationCommand.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using ApplicationCommandType = Myriad.Types.ApplicationCommand.ApplicationCommandType;
|
||||
|
||||
namespace PluralKit.Bot;
|
||||
|
||||
public class ApplicationCommand
|
||||
{
|
||||
public ApplicationCommand(ApplicationCommandType type, string name, string? description = null)
|
||||
{
|
||||
Type = type;
|
||||
Name = name;
|
||||
Description = description;
|
||||
}
|
||||
|
||||
public ApplicationCommandType Type { get; }
|
||||
public string Name { get; }
|
||||
public string Description { get; }
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using ApplicationCommandType = Myriad.Types.ApplicationCommand.ApplicationCommandType;
|
||||
|
||||
namespace PluralKit.Bot;
|
||||
|
||||
public partial class ApplicationCommandTree
|
||||
{
|
||||
public static ApplicationCommand ProxiedMessageQuery = new(ApplicationCommandType.Message, "\U00002753 Message info");
|
||||
public static ApplicationCommand ProxiedMessageDelete = new(ApplicationCommandType.Message, "\U0000274c Delete message");
|
||||
public static ApplicationCommand ProxiedMessagePing = new(ApplicationCommandType.Message, "\U0001f514 Ping author");
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using ApplicationCommandType = Myriad.Types.ApplicationCommand.ApplicationCommandType;
|
||||
using InteractionType = Myriad.Types.Interaction.InteractionType;
|
||||
|
||||
namespace PluralKit.Bot;
|
||||
|
||||
public partial class ApplicationCommandTree
|
||||
{
|
||||
public Task TryHandleCommand(InteractionContext ctx)
|
||||
{
|
||||
if (ctx.Event.Data!.Name == ProxiedMessageQuery.Name)
|
||||
return ctx.Execute<ApplicationCommandProxiedMessage>(ProxiedMessageQuery, m => m.QueryMessage(ctx));
|
||||
else if (ctx.Event.Data!.Name == ProxiedMessageDelete.Name)
|
||||
return ctx.Execute<ApplicationCommandProxiedMessage>(ProxiedMessageDelete, m => m.DeleteMessage(ctx));
|
||||
else if (ctx.Event.Data!.Name == ProxiedMessagePing.Name)
|
||||
return ctx.Execute<ApplicationCommandProxiedMessage>(ProxiedMessageDelete, m => m.PingMessageAuthor(ctx));
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user