-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
44 lines (39 loc) · 1.47 KB
/
Program.cs
File metadata and controls
44 lines (39 loc) · 1.47 KB
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
using System;
using Discord;
using Discord.WebSocket;
using System.Threading.Tasks;
using System.IO;
using System.Text;
namespace Slothu
{
class Program
{
static void Main(string[] args)
=> new Program().StartAsync().GetAwaiter().GetResult();
private DiscordSocketClient _client;
private CommandHandler _handler;
public DateTime _startTime = DateTime.Now;
public async Task StartAsync()
{
string _token;
FileStream token = File.Open(@"D:\DiscordBotFiles\token.txt", FileMode.Open, FileAccess.Read);
byte[] result = new byte[token.Length];
await token.ReadAsync(result, 0, (int)token.Length);
_token = Encoding.ASCII.GetString(result);
_client = new DiscordSocketClient();
long ticks = DateTime.Now.Ticks;
await _client.LoginAsync(
tokenType: TokenType.Bot,
token: _token
);
Console.WriteLine("-----------------------------------------------------" +
"\nTime taken to login: {0:n3}s ({1}ms)" +
"\n-----------------------------------------------------",
(DateTime.Now.Ticks - ticks) / 10 / 1000 / 1000,
(DateTime.Now.Ticks - ticks) / 10 / 1000);
await _client.StartAsync();
_handler = new CommandHandler(_client);
await Task.Delay(-1);
}
}
}