-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCore.cs
60 lines (57 loc) · 2.24 KB
/
Core.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
52
53
54
55
56
57
58
59
60
namespace WhatANerd
{
using Discord;
using Discord.WebSocket;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using Qmmands;
using System;
using System.IO;
using System.Threading.Tasks;
using WhatANerd.Models;
using WhatANerd.Services;
public static class Core
{
private static async Task Main()
{
var environment = Environment.GetEnvironmentVariable("NETCORE_ENVIRONMENT");
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{environment}.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables()
.Build();
var services = new ServiceCollection()
.AddSingleton(new DiscordSocketClient(new DiscordSocketConfig
{
AlwaysDownloadUsers = true,
LogLevel = LogSeverity.Verbose,
MessageCacheSize = 50
}))
.AddSingleton(new CommandService(new CommandServiceConfiguration
{
CaseSensitive = false,
DefaultRunMode = RunMode.Sequential,
IgnoreExtraArguments = true
}))
.AddSingleton(configuration.GetSection("Tokens").Get<Tokens>())
.AddSingleton(configuration.GetSection("Support").Get<Support>())
.AddSingleton<MessageHandlerService>()
.AddTransient<LogService>()
.AddLogging(builder =>
{
builder.SetMinimumLevel(LogLevel.Information);
builder.AddNLog(new NLogProviderOptions
{
CaptureMessageTemplates = true,
CaptureMessageProperties = true
});
})
.BuildServiceProvider();
var bot = new Startup(services);
await bot.StartAsync();
}
}
}