This repository was archived by the owner on Jul 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
42 lines (34 loc) · 1.2 KB
/
Program.cs
File metadata and controls
42 lines (34 loc) · 1.2 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
using DSharpPlus;
using DSharpPlus.SlashCommands;
namespace BalabobaDiscordBot
{
class Program
{
static void Main()
{
MainAsync().GetAwaiter().GetResult();
}
static async Task MainAsync()
{
string EnvironmentVar = "BalabobaBotDiscordToken";
var token = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)
? Environment.GetEnvironmentVariable(EnvironmentVar, EnvironmentVariableTarget.User)
: Environment.GetEnvironmentVariable(EnvironmentVar);
if (token == null)
{
Console.WriteLine($"{EnvironmentVar} environment variable is not set");
return;
}
var client = new DiscordClient(new DiscordConfiguration()
{
Token = token,
AutoReconnect = true,
TokenType = TokenType.Bot
});
var commands = client.UseSlashCommands();
commands.RegisterCommands<SlashCommands>();
await client.ConnectAsync();
await Task.Delay(-1);
}
}
}