-
-
Notifications
You must be signed in to change notification settings - Fork 318
avoid bulk overwriting global commands #2115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
avoid bulk overwriting global commands #2115
Conversation
VelvetToroyashi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OoLunar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the following code snippet reused a LOT:
if ((a is null || a.Count == 0) && (b is null || b.Count == 0))
{
return true;
}
if (a is null || b is null)
{
return false;
}
if (a.Count != b.Count)
{
return false;
}Can we extract this to an interface-based method?
Generally LGTM at a glance, have not tested or used anything.
...mands/Processors/SlashCommands/RemoteRecordRetentionPolicies/IRemoteRecordRetentionPolicy.cs
Show resolved
Hide resolved
DSharpPlus.Commands/Processors/SlashCommands/SlashCommandConfiguration.cs
Show resolved
Hide resolved
DSharpPlus.Commands/Processors/SlashCommands/SlashCommandProcessor.Registration.Remote.cs
Show resolved
Hide resolved
DSharpPlus.Commands/Processors/SlashCommands/SlashCommandProcessor.Registration.Remote.cs
Show resolved
Hide resolved
DSharpPlus/Entities/Interaction/Application/DiscordApplicationCommand.WeakEquals.cs
Show resolved
Hide resolved
DSharpPlus/Entities/Interaction/Application/DiscordApplicationCommand.WeakEquals.cs
Show resolved
Hide resolved
DSharpPlus/Entities/Interaction/Application/DiscordApplicationCommand.WeakEquals.cs
Show resolved
Hide resolved
DSharpPlus/Entities/Interaction/Application/DiscordApplicationCommandType.cs
Show resolved
Hide resolved
|
a note to the pattern matching suggestions from @OoLunar : pattern matching is only possible when matching against constants. |
|
0 and null are both constants - at the very least I would recommend merging some of those |
DSharpPlus/Entities/Interaction/Application/DiscordApplicationCommand.WeakEquals.cs
Outdated
Show resolved
Hide resolved
DSharpPlus/Entities/Interaction/Application/DiscordApplicationCommand.WeakEquals.cs
Show resolved
Hide resolved
| else | ||
| { | ||
| await this.extension.Client.DeleteGuildApplicationCommandAsync(this.extension.DebugGuildId, command.Id); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code stylistically, should be the same as in CreateGlobalCommandAsync, because except for the different method call it is the same. So either an if-else or ?: in both
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't be, because this one doesn't return a value it can't be a ternary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad then, overlooked it sorry
* preliminary mitigation of the issue * rewire everything to avoid global bulk updates * formatting artifact * treat GuildInstall as default * some pattern matching, as a treat

avoids bulk overwriting global commands, and instead fetches all commands and only updates/creates/deletes whatever necessary
also adds an option to restore the old behaviour in case this causes issues for users. i'm unsure on keeping that option in the future, but for now, while this hotfix is not battle-tested, it's probably a good idea to have
autocomplete and chat input commands are tested and work.