Fix registration not working in release

This commit is contained in:
Noi 2022-02-08 14:55:27 -08:00
parent 5c6e0777f5
commit 2c9920d87f

View file

@ -118,7 +118,7 @@ class ShardInstance : IDisposable {
} }
#if !DEBUG #if !DEBUG
// Remove any unneeded/unused commands // Remove any unneeded/unused commands
var existingcmdnames = cmds.Select(c => c.Name.Value).ToHashSet(); var existingcmdnames = commands.Select(c => c.Name.Value).ToHashSet();
foreach (var gcmd in await DiscordClient.GetGlobalApplicationCommandsAsync()) { foreach (var gcmd in await DiscordClient.GetGlobalApplicationCommandsAsync()) {
if (!existingcmdnames.Contains(gcmd.Name)) { if (!existingcmdnames.Contains(gcmd.Name)) {
Log("Command registration", $"Found registered unused command /{gcmd.Name} - sending removal request"); Log("Command registration", $"Found registered unused command /{gcmd.Name} - sending removal request");
@ -126,8 +126,8 @@ class ShardInstance : IDisposable {
} }
} }
// And update what we have // And update what we have
Log("Command registration", $"Bulk updating {cmds.Length} global command(s)"); Log("Command registration", $"Bulk updating {commands.Count} global command(s)");
await DiscordClient.BulkOverwriteGlobalApplicationCommandsAsync(cmds).ConfigureAwait(false); await DiscordClient.BulkOverwriteGlobalApplicationCommandsAsync(commands.ToArray()).ConfigureAwait(false);
#else #else
// Debug: Register our commands locally instead, in each guild we're in // Debug: Register our commands locally instead, in each guild we're in
foreach (var g in DiscordClient.Guilds) { foreach (var g in DiscordClient.Guilds) {