-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBot.cs
49 lines (38 loc) · 1.34 KB
/
Bot.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
using Discord;
using Discord.Commands;
using Discord.WebSocket;
using System;
using System.IO;
using System.Threading.Tasks;
using bot.Handlers;
namespace bot.Handlers
{
public class Bot
{
public static async Task MainAsync()
{
var client = new DiscordSocketClient();
var commandService = new CommandService();
// Log information to the console
client.Log += Log;
client.ReactionAdded += ReactionAdded.ReactionAddedAsync;
// Read the token for your bot from file
var token = File.ReadAllText("token.txt");
// Log in to Discord
await client.LoginAsync(TokenType.Bot, token);
// Start connection logic
await client.StartAsync();
//Create banlist.txt
if (!File.Exists("banlist.txt")) File.Create("banlist.txt");
// Here you can set up your event handlers
await new CommandHandler(client, commandService).SetupAsync();
// Block this task until the program is closed
await Task.Delay(-1);
}
private static Task Log(LogMessage message)
{
Console.WriteLine(message.ToString());
return Task.CompletedTask;
}
}
}