Skip to content

Conversation

@akiraveliara
Copy link
Member

@akiraveliara akiraveliara commented Oct 14, 2024

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.

@akiraveliara akiraveliara added bugfix commands For issues related to DSharpPlus.Commands labels Oct 14, 2024
@akiraveliara akiraveliara added this to the v5.0 milestone Oct 14, 2024
Copy link
Member

@VelvetToroyashi VelvetToroyashi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

@akiraveliara akiraveliara changed the title preliminarily try to detect changes in command records before bulk overwriting avoid bulk overwriting global commands Oct 18, 2024
@akiraveliara akiraveliara marked this pull request as ready for review October 18, 2024 16:33
@akiraveliara akiraveliara mentioned this pull request Oct 19, 2024
36 tasks
Copy link
Contributor

@OoLunar OoLunar left a 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.

@akiraveliara
Copy link
Member Author

a note to the pattern matching suggestions from @OoLunar : pattern matching is only possible when matching against constants.

@VelvetToroyashi
Copy link
Member

0 and null are both constants - at the very least I would recommend merging some of those

@akiraveliara akiraveliara merged commit f930da7 into master Oct 24, 2024
@akiraveliara akiraveliara deleted the aki/avoid-bulk-overwriting-commands-if-possible branch October 24, 2024 17:18
else
{
await this.extension.Client.DeleteGuildApplicationCommandAsync(this.extension.DebugGuildId, command.Id);
}

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

Copy link
Member Author

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

Copy link

@Voroniyx Voroniyx Oct 24, 2024

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

Instellate pushed a commit that referenced this pull request Nov 4, 2024
* preliminary mitigation of the issue

* rewire everything to avoid global bulk updates

* formatting artifact

* treat GuildInstall as default

* some pattern matching, as a treat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix commands For issues related to DSharpPlus.Commands discord-issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants