Add preliminary support for buttons

This commit is contained in:
Ske
2021-05-26 22:27:52 +02:00
parent 0b91e71384
commit d7c0592947
11 changed files with 217 additions and 7 deletions

View File

@@ -0,0 +1,34 @@
using System.Threading.Tasks;
using Autofac;
using Myriad.Gateway;
using Myriad.Types;
namespace PluralKit.Bot
{
public class InteractionCreated: IEventHandler<InteractionCreateEvent>
{
private readonly InteractionDispatchService _interactionDispatch;
private readonly ILifetimeScope _services;
public InteractionCreated(InteractionDispatchService interactionDispatch, ILifetimeScope services)
{
_interactionDispatch = interactionDispatch;
_services = services;
}
public async Task Handle(Shard shard, InteractionCreateEvent evt)
{
if (evt.Type == Interaction.InteractionType.MessageComponent)
{
var customId = evt.Data?.CustomId;
if (customId != null)
{
var ctx = new InteractionContext(evt, _services);
await _interactionDispatch.Dispatch(customId, ctx);
}
}
}
}
}