-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInteractionHandler.cs
More file actions
36 lines (32 loc) · 1.06 KB
/
InteractionHandler.cs
File metadata and controls
36 lines (32 loc) · 1.06 KB
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
32
33
34
35
36
namespace MusicPlayer
{
public class InteractionHandler
{
private readonly DiscordSocketClient _client;
private readonly InteractionService _commands;
private readonly IServiceProvider _services;
public InteractionHandler(DiscordSocketClient client, InteractionService commands, IServiceProvider services)
{
_client = client;
_commands = commands;
_services = services;
}
public async Task InitializeAsync()
{
await _commands.AddModulesAsync(Assembly.GetEntryAssembly(), _services);
_client.InteractionCreated += HandleInteraction;
}
private async Task HandleInteraction(SocketInteraction arg)
{
try
{
var ctx = new SocketInteractionContext(_client, arg);
await _commands.ExecuteCommandAsync(ctx, _services);
}
catch (Exception exception)
{
Console.WriteLine(exception.ToString());
}
}
}
}