-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathProgram.cs
51 lines (41 loc) · 1.47 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
50
51
using Discord;
using Discord.Addons.Hosting;
using Discord.Interactions;
using Discord.WebSocket;
using Microsoft.EntityFrameworkCore;
using Template;
using Template.Data;
using Template.Services;
Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddNamedOptions<StartupOptions>();
builder.Services.AddNamedOptions<ReferenceOptions>();
builder.Services.AddSqlite<AppDbContext>(builder.Configuration.GetConnectionString("Default"));
builder.Services.AddDiscordHost((config, _) =>
{
config.SocketConfig = new DiscordSocketConfig
{
LogLevel = LogSeverity.Info,
GatewayIntents = GatewayIntents.AllUnprivileged,
LogGatewayIntentWarnings = false,
UseInteractionSnowflakeDate = false,
AlwaysDownloadUsers = false,
};
config.Token = builder.Configuration.GetSection(StartupOptions.GetSectionName()).Get<StartupOptions>()!.Token;
});
builder.Services.AddInteractionService((config, _) =>
{
config.LogLevel = LogSeverity.Debug;
config.DefaultRunMode = RunMode.Async;
config.UseCompiledLambda = true;
});
builder.Services.AddInteractiveService(config =>
{
config.LogLevel = LogSeverity.Warning;
config.DefaultTimeout = TimeSpan.FromMinutes(5);
config.ProcessSinglePagePaginators = true;
});
builder.Services.AddHostedService<InteractionHandler>();
var host = builder.Build();
await host.MigrateAsync<AppDbContext>();
await host.RunAsync();