-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
38 lines (35 loc) · 1.2 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
using DSharpPlus;
using DSharpPlus.SlashCommands;
namespace CUTSBot
{
internal class Program
{
static async Task Main(string[] args)
{
bool connected = false;
while (!connected)
{
try
{
string Token = File.ReadAllText(Path.Combine(Environment.CurrentDirectory, "Token.txt")).Trim();
DiscordClient discord = new DiscordClient(new DiscordConfiguration()
{
Token = Token,
TokenType = TokenType.Bot,
Intents = DiscordIntents.AllUnprivileged
});
SlashCommandsExtension slash = discord.UseSlashCommands();
slash.RegisterCommands<SlashCommands>();
await discord.ConnectAsync();
connected = true;
}
catch (Exception ex)
{
Console.WriteLine($"Failed to connect: {ex.Message}");
await Task.Delay(5000); // Wait for 5 seconds before retrying
}
}
await Task.Delay(-1);
}
}
}