-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
49 lines (37 loc) · 1.54 KB
/
Program.cs
File metadata and controls
49 lines (37 loc) · 1.54 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
45
46
47
48
49
using DSharpPlus.CommandsNext;
using DSharpPlus.VoiceNext;
using DSharpPlus.SlashCommands;
async Task Main()
{
await VoidBot.Config.Initialize();
await VoidBot.Localization.Initialize();
var token = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)
? Environment.GetEnvironmentVariable(VoidBot.Config.Current!.TokenEnvermomentName!, EnvironmentVariableTarget.User)
: Environment.GetEnvironmentVariable(VoidBot.Config.Current!.TokenEnvermomentName!);
if (token == null)
{
Console.WriteLine($"{VoidBot.Config.Current!.TokenEnvermomentName!} environment variable is not set");
return;
}
var client = new DSharpPlus.DiscordClient(new DSharpPlus.DiscordConfiguration
{
Token = token,
TokenType = DSharpPlus.TokenType.Bot,
AutoReconnect = true
});
client.UseVoiceNext();
var commands = client.UseSlashCommands();
commands.RegisterCommands<VoidBot.Modules.AnimeModule>();
// TODO: FIX THIS
//commands.RegisterCommands<VoidBot.Modules.MusicModule>();
commands.SlashCommandErrored += async (cmd, e) =>
{
if (cmd == null)
await VoidBot.Utils.ChatUtils.SendError(e.Context, e.Exception.Message);
else
await VoidBot.Utils.ChatUtils.SendError(e.Context, $"{e.Context.CommandName} - {e.Exception.Message}\n{e.Exception.StackTrace}");
};
await client.ConnectAsync();
await Task.Delay(Timeout.Infinite);
}
Main().GetAwaiter().GetResult();