|
1 |
| -using DSharpPlus.Clients; |
2 | 1 | using DSharpPlus.Extensions;
|
3 | 2 | using DSharpPlus.Net.Gateway;
|
4 | 3 | using System.Reflection;
|
@@ -187,26 +186,33 @@ static async Task Main(string[] _)
|
187 | 186 | .HandleChannelDeleted(ChannelEvents.ChannelDeleted)
|
188 | 187 | );
|
189 | 188 |
|
190 |
| - discord = discordBuilder.Build(); |
| 189 | +#pragma warning disable CS0618 // Type or member is obsolete |
| 190 | + discordBuilder.UseSlashCommands(slash => |
| 191 | + { |
| 192 | + slash.SlashCommandErrored += InteractionEvents.SlashCommandErrorEvent; |
| 193 | + slash.ContextMenuErrored += InteractionEvents.ContextCommandErrorEvent; |
| 194 | + |
| 195 | + var slashCommandClasses = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsClass && t.Namespace == "Cliptok.Commands.InteractionCommands" && !t.IsNested); |
| 196 | + foreach (var type in slashCommandClasses) |
| 197 | + slash.RegisterCommands(type, cfgjson.ServerID); ; |
| 198 | + }); |
| 199 | +#pragma warning restore CS0618 // Type or member is obsolete |
191 | 200 |
|
192 |
| - var slash = discord.UseSlashCommands(); |
193 |
| - slash.SlashCommandErrored += InteractionEvents.SlashCommandErrorEvent; |
194 |
| - slash.ContextMenuErrored += InteractionEvents.ContextCommandErrorEvent; |
195 |
| - var slashCommandClasses = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsClass && t.Namespace == "Cliptok.Commands.InteractionCommands" && !t.IsNested); |
196 |
| - foreach (var type in slashCommandClasses) |
197 |
| - slash.RegisterCommands(type, cfgjson.ServerID); ; |
| 201 | + discordBuilder.UseCommandsNext(commands => |
| 202 | + { |
| 203 | + var commandClasses = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsClass && t.Namespace == "Cliptok.Commands" && !t.IsNested); |
| 204 | + foreach (var type in commandClasses) |
| 205 | + commands.RegisterCommands(type); |
198 | 206 |
|
199 |
| - commands = discord.UseCommandsNext(new CommandsNextConfiguration |
| 207 | + commands.CommandErrored += ErrorEvents.CommandsNextService_CommandErrored; |
| 208 | + }, new CommandsNextConfiguration |
200 | 209 | {
|
201 | 210 | StringPrefixes = cfgjson.Core.Prefixes
|
202 | 211 | });
|
203 | 212 |
|
204 |
| - var commandClasses = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsClass && t.Namespace == "Cliptok.Commands" && !t.IsNested); |
205 |
| - foreach (var type in commandClasses) |
206 |
| - commands.RegisterCommands(type); |
207 |
| - |
208 |
| - commands.CommandErrored += ErrorEvents.CommandsNextService_CommandErrored; |
209 |
| - |
| 213 | + // TODO(erisa): At some point we might be forced to ConnectAsync() the builder directly |
| 214 | + // and then we will need to rework some other pieces that rely on Program.discord |
| 215 | + discord = discordBuilder.Build(); |
210 | 216 | await discord.ConnectAsync();
|
211 | 217 |
|
212 | 218 | await ReadyEvent.OnStartup(discord);
|
|
0 commit comments