feat(bot): add interaction logging info for debugging with Discord

This commit is contained in:
spiral 2022-11-28 17:45:26 -05:00
parent ee0a44f891
commit 580b4dfe7b
No known key found for this signature in database
GPG Key ID: 244A11E4B0BCF40E

View File

@ -1,5 +1,7 @@
using Autofac; using Autofac;
using Serilog;
using Myriad.Gateway; using Myriad.Gateway;
using Myriad.Types; using Myriad.Types;
@ -9,17 +11,20 @@ public class InteractionCreated: IEventHandler<InteractionCreateEvent>
{ {
private readonly InteractionDispatchService _interactionDispatch; private readonly InteractionDispatchService _interactionDispatch;
private readonly ILifetimeScope _services; private readonly ILifetimeScope _services;
private readonly ILogger _logger;
public InteractionCreated(InteractionDispatchService interactionDispatch, ILifetimeScope services) public InteractionCreated(InteractionDispatchService interactionDispatch, ILifetimeScope services, ILogger logger)
{ {
_interactionDispatch = interactionDispatch; _interactionDispatch = interactionDispatch;
_services = services; _services = services;
_logger = logger;
} }
public async Task Handle(int shardId, InteractionCreateEvent evt) public async Task Handle(int shardId, InteractionCreateEvent evt)
{ {
if (evt.Type == Interaction.InteractionType.MessageComponent) if (evt.Type == Interaction.InteractionType.MessageComponent)
{ {
_logger.Information($"Discord debug: got interaction with ID {evt.Id} from custom ID {evt.Data?.CustomId}");
var customId = evt.Data?.CustomId; var customId = evt.Data?.CustomId;
if (customId == null) return; if (customId == null) return;