-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInteractionHandler.cs
More file actions
31 lines (28 loc) · 963 Bytes
/
InteractionHandler.cs
File metadata and controls
31 lines (28 loc) · 963 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System.Reflection;
using Discord.Interactions;
using Discord.WebSocket;
using Serilog;
namespace Portal;
public class InteractionHandler(
DiscordSocketClient discordSocketClient,
IServiceProvider serviceProvider,
InteractionService interactionService)
{
public async Task InitializeAsync()
{
await interactionService.AddModulesAsync(assembly: Assembly.GetEntryAssembly(), serviceProvider);
discordSocketClient.InteractionCreated += DiscordSocketClientOnInteractionCreated;
}
private async Task DiscordSocketClientOnInteractionCreated(SocketInteraction arg)
{
try
{
SocketInteractionContext context = new(discordSocketClient, arg);
await interactionService.ExecuteCommandAsync(context, serviceProvider);
}
catch (Exception ex)
{
Log.Error("Error executing interaction command. Reason: {error}", ex.Message);
}
}
}