-
Notifications
You must be signed in to change notification settings - Fork 3
/
Program.cs
49 lines (45 loc) · 1.75 KB
/
Program.cs
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
37
38
39
40
41
42
43
44
45
46
47
48
49
using Discord;
using Discord.Interactions;
using Discord.WebSocket;
using JukeBox;
using Lavalink4NET.Extensions;
using Lavalink4NET.InactivityTracking.Extensions;
using Lavalink4NET.InactivityTracking.Trackers.Idle;
using Lavalink4NET.InactivityTracking.Trackers.Users;
using static Discord.GatewayIntents;
IHost host = Host.CreateDefaultBuilder()
.ConfigureServices(services =>
{
services
.AddHostedService<JukeBoxService>()
.AddLogging(x => x.AddConsole().SetMinimumLevel(LogLevel.Trace))
.AddSingleton(new DiscordSocketClient(new DiscordSocketConfig
{
GatewayIntents = AllUnprivileged & ~GuildInvites & ~GuildScheduledEvents,
AlwaysDownloadUsers = true,
LogLevel = LogSeverity.Debug
}))
.AddSingleton(x => new InteractionService(x.GetRequiredService<DiscordSocketClient>()))
.AddSingleton<InteractionHandler>()
.AddLavalink()
.AddInactivityTracking()
.Configure<IdleInactivityTrackerOptions>(config =>
{
config.Timeout = TimeSpan.FromMinutes(30);
})
.Configure<UsersInactivityTrackerOptions>(config =>
{
config.Timeout = TimeSpan.FromSeconds(1);
});
}).Build();
using (var scope = host.Services.CreateScope())
{
var client = scope.ServiceProvider.GetRequiredService<DiscordSocketClient>();
var slashCommands = scope.ServiceProvider.GetRequiredService<InteractionService>();
await scope.ServiceProvider.GetRequiredService<InteractionHandler>().InitializeAsync();
client.Ready += async () =>
{
await slashCommands.RegisterCommandsGloballyAsync();
};
await host.RunAsync();
}