-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
59 lines (45 loc) · 1.52 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
using Discord;
using Discord.WebSocket;
namespace Sharpvin
{
public class Program
{
private const String Token = "MTA2NDkwNjA1ODkwNjIyMjY5Mg.GPMKpN.SxFtmuTLezn4pVVEqnqhHlRyaRPot-QOjJLfec";
private DiscordSocketClient client;
private MessageHandler Handler;
public Program()
{
//create client with config
DiscordSocketConfig config = new DiscordSocketConfig();
config.GatewayIntents = GatewayIntents.All;
client = new DiscordSocketClient(config);
Handler = MessageHandler.GetInstance();
}
public static Task Main(string[] args) => new Program().MainAsync();
public async Task MainAsync()
{
//event handlers
client.Log += Log;
client.MessageReceived += Handler.OnMessageReceived;
client.Ready += OnReady;
//connect to discord
await client.LoginAsync(TokenType.Bot, Token);
await client.StartAsync();
// Block this task until the program is closed.
await Task.Delay(-1);
}
private Task Log(LogMessage msg)
{
Console.WriteLine(msg.ToString());
return Task.CompletedTask;
}
private Task OnReady()
{
if (client.CurrentUser != null)
Handler.SetID(client.CurrentUser.Id);
if (Handler != null)
Handler.OnReady();
return Task.CompletedTask;
}
}
}