-
Notifications
You must be signed in to change notification settings - Fork 2
/
Program.cs
executable file
·42 lines (38 loc) · 1.55 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
// ReSharper disable SwitchStatementMissingSomeEnumCasesNoDefault
using Discord.Interactions;
using RRBot;
Credentials.ValidationResult validation = Credentials.Instance.Validate();
switch (validation)
{
case Credentials.ValidationResult.MissingCredentialsFile:
Console.WriteLine("The credentials.json file is missing.");
return;
case Credentials.ValidationResult.NeedMongoConnectionString:
Console.WriteLine("A MongoDB connection string was not supplied in the credentials.json.");
return;
case Credentials.ValidationResult.NeedToken:
Console.WriteLine("A token was not supplied in the credentials.json.");
return;
}
DiscordShardedClient client = new(new DiscordSocketConfig
{
AlwaysDownloadUsers = true,
GatewayIntents = GatewayIntents.All,
LargeThreshold = 250,
MessageCacheSize = 1500
});
HostApplicationBuilder builder = new(args);
builder.Services.AddSingleton(client)
.AddSingleton<CommandService>()
.AddSingleton<InteractionService>()
.AddSingleton<InteractiveService>()
.AddHostedService<DiscordClientHost>()
.AddLavalink()
.AddLogging(x => x.AddConsole().SetMinimumLevel(LogLevel.Warning))
.AddLyrics()
.ConfigureLyrics(options => options.SuppressExceptions = true)
.AddInactivityTracking()
.ConfigureInactivityTracking(options => options.DefaultTimeout = TimeSpan.FromSeconds(Constants.InactivityTimeoutSecs))
.AddSingleton<AudioSystem>()
.AddSingleton<IRestClientProvider>(x => x.GetRequiredService<DiscordShardedClient>());
builder.Build().Run();