-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
51 lines (44 loc) · 1.89 KB
/
Program.cs
File metadata and controls
51 lines (44 loc) · 1.89 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
50
51
using System;
using System.Reflection;
using System.Threading.Tasks;
using DSharpPlus;
using DSharpPlus.CommandsNext;
using DSharpPlus.Interactivity;
using DSharpPlus.Interactivity.Extensions;
using DucksBot.Commands;
using DucksBot.Services;
namespace DucksBot
{
internal static class Program
{
private static void Main(string[] args)
{
MainAsync(args[0], (args.Length > 1 && args[1].Length > 0) ? args[1] : "!").GetAwaiter().GetResult();
}
private static async Task MainAsync(string token, string prefix)
{
var discord = new DiscordClient(new DiscordConfiguration()
{
Token = token,
TokenType = TokenType.Bot,
Intents = DiscordIntents.AllUnprivileged | DiscordIntents.GuildMembers
});
discord.UseInteractivity(new InteractivityConfiguration() {
Timeout = TimeSpan.FromHours(2)
});
discord.GuildMemberAdded += LogService.DiscordMemberAdded;
discord.GuildMemberAdded += InfractionService.CheckUserMutedAsync;
discord.GuildMemberRemoved += LogService.DiscordMemberRemoved;
CustomCommandsService.DiscordClient = discord;
var commands = discord.UseCommandsNext(new CommandsNextConfiguration() {
StringPrefixes = new[] { prefix[0].ToString() } // ! will be the default command prefix if nothing else is specified in the parameters
});
commands.CommandErrored += CommandHandlerService.CommandErrorAsync;
commands.RegisterCommands(Assembly.GetExecutingAssembly()); // Registers all defined commands
InfractionService.Initialize();
await CustomCommandsService.LoadCustomCommandsAsync();
await discord.ConnectAsync();
await Task.Delay(-1);
}
}
}