-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
83 lines (70 loc) · 2.88 KB
/
Program.cs
File metadata and controls
83 lines (70 loc) · 2.88 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Threading.Tasks;
using DSharpPlus;
using DSharpPlus.CommandsNext;
using DSharpPlus.Entities;
using DSharpPlus.Interactivity;
using DSharpPlus.Interactivity.Extensions;
using DSharpPlus.SlashCommands;
using Moderation_Bot.commands;
using Moderation_Bot.config;
namespace Moderation_Bot
{
public static class Program
{
public static DiscordClient Client { get; private set; }
public static CommandsNextExtension Commands { get; private set; }
public static SlashCommandsExtension SlashCommands { get; private set; }
static async Task Main(string[] args)
{
// Load the bot configuration
var jsonReader = new JSONReader();
await jsonReader.ReadJSON();
// Configure the Discord client
var discordConfig = new DiscordConfiguration()
{
Intents = DiscordIntents.All,
Token = jsonReader.token,
TokenType = TokenType.Bot,
AutoReconnect = true
};
Client = new DiscordClient(discordConfig);
// Register Interactivity
Client.UseInteractivity(new InteractivityConfiguration
{
Timeout = TimeSpan.FromMinutes(2)
});
// Set up the CommandsNext module
var commandsConfig = new CommandsNextConfiguration()
{
StringPrefixes = new[] { jsonReader.prefix },
EnableDms = true,
EnableMentionPrefix = true,
EnableDefaultHelp = false
};
Commands = Client.UseCommandsNext(commandsConfig);
Commands.RegisterCommands<KickCommands>();
Commands.RegisterCommands<BanCommands>();
Commands.RegisterCommands<SnipeCommands>();
Commands.RegisterCommands<LogsCommands>();
Commands.RegisterCommands<TimeoutCommands>();
Commands.RegisterCommands<HelpCommands>();
Commands.RegisterCommands<InfoCommands>();
Commands.RegisterCommands<AfkCommands>();
// After creating your DiscordClient (named 'discord'):
Client.MessageCreated += Moderation_Bot.commands.AfkCommands.HandleAfkMentions;
// Set the bot's activity
Client.Ready += Client_Ready;
// Connect the bot
await Client.ConnectAsync();
await Task.Delay(-1);
}
private static Task Client_Ready(DiscordClient sender, DSharpPlus.EventArgs.ReadyEventArgs e)
{
// Set the bot's activity to "Playing... Quantum flux"
var activity = new DiscordActivity("MODERATING!!", ActivityType.Playing);
sender.UpdateStatusAsync(activity);
return Task.CompletedTask;
}
}
}