Skip to content

Commit 6d8db2a

Browse files
committed
Upgrade DSharpPlus to 5.0.0-nightly-02351
1 parent feabdc2 commit 6d8db2a

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

Cliptok.csproj

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313

1414
<ItemGroup>
1515
<PackageReference Include="Abyssal.HumanDateParser" Version="2.0.0-20191113.1" />
16-
<PackageReference Include="DSharpPlus" Version="5.0.0-nightly-02312" />
17-
<PackageReference Include="DSharpPlus.CommandsNext" Version="5.0.0-nightly-02312" />
18-
<PackageReference Include="DSharpPlus.SlashCommands" Version="5.0.0-nightly-02312" />
16+
<PackageReference Include="DSharpPlus" Version="5.0.0-nightly-02351" />
17+
<PackageReference Include="DSharpPlus.CommandsNext" Version="5.0.0-nightly-02351" />
18+
<PackageReference Include="DSharpPlus.SlashCommands" Version="5.0.0-nightly-02351" />
1919
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
20-
<PackageReference Include="Serilog" Version="4.0.0" />
20+
<PackageReference Include="Serilog" Version="4.0.1" />
2121
<PackageReference Include="Serilog.Expressions" Version="5.0.0" />
2222
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
2323
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
24-
<PackageReference Include="Serilog.Sinks.TextWriter" Version="2.1.0" />
24+
<PackageReference Include="Serilog.Sinks.TextWriter" Version="3.0.0" />
2525
<PackageReference Include="StackExchange.Redis" Version="2.8.0" />
2626
<PackageReference Include="System.Linq" Version="4.3.0" />
2727
<PackageReference Include="System.Linq.Async" Version="6.0.1" />

Program.cs

+21-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using DSharpPlus.Clients;
21
using DSharpPlus.Extensions;
32
using DSharpPlus.Net.Gateway;
43
using System.Reflection;
@@ -187,26 +186,33 @@ static async Task Main(string[] _)
187186
.HandleChannelDeleted(ChannelEvents.ChannelDeleted)
188187
);
189188

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
191200

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);
198206

199-
commands = discord.UseCommandsNext(new CommandsNextConfiguration
207+
commands.CommandErrored += ErrorEvents.CommandsNextService_CommandErrored;
208+
}, new CommandsNextConfiguration
200209
{
201210
StringPrefixes = cfgjson.Core.Prefixes
202211
});
203212

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();
210216
await discord.ConnectAsync();
211217

212218
await ReadyEvent.OnStartup(discord);

0 commit comments

Comments
 (0)