-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
65 lines (57 loc) · 1.99 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using System.Reflection;
using System.Threading.Tasks;
using DSharpPlus;
using DSharpPlus.CommandsNext;
using DSharpPlus.Entities;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Proty.commands;
using Proty.db;
using Serilog;
namespace Proty
{
class Program
{
private static Db Db { get; } = new Db();
public static ILoggerFactory LoggerFactory { get; } = new LoggerFactory().AddSerilog();
public static IServiceProvider Services = new ServiceCollection().AddSingleton(Db).BuildServiceProvider();
static void Main(string[] args)
{
MainAsync(args).GetAwaiter().GetResult();
}
private static async Task MainAsync(string[] args)
{
Init();
var discord = new DiscordClient(new DiscordConfiguration()
{
Token = args[0],
TokenType = TokenType.Bot,
LoggerFactory = LoggerFactory
});
var commands = discord.UseCommandsNext(new CommandsNextConfiguration()
{
UseDefaultCommandHandler = false,
Services = Services
});
commands.RegisterCommands(Assembly.GetExecutingAssembly());
commands.SetHelpFormatter<HelpCommand>();
commands.CommandErrored += Events.CommandErrored;
discord.Ready += Events.Ready;
discord.MessageCreated += Events.MessageCreated;
discord.GuildCreated += Events.GuildCreated;
discord.GuildDeleted += Events.GuildDeleted;
await discord.ConnectAsync(new DiscordActivity()
{
ActivityType = ActivityType.Playing,
Name = "with a loading bar"
});
await Task.Delay(-1);
}
private static void Init()
{
Log.Logger = new LoggerConfiguration().WriteTo.Console().CreateLogger();
Db.Init();
}
}
}