Skip to content

fix: Command Auto Syncing#2990

Open
Icebluewolf wants to merge 96 commits intoPycord-Development:masterfrom
Icebluewolf:fix-auto-sync
Open

fix: Command Auto Syncing#2990
Icebluewolf wants to merge 96 commits intoPycord-Development:masterfrom
Icebluewolf:fix-auto-sync

Conversation

@Icebluewolf
Copy link
Member

@Icebluewolf Icebluewolf commented Nov 5, 2025

Summary

This is very much a draft and needs lots of testing. I just want to put it somewhere public so that I can get eyes on it.
This is something I am not quite sure how to cleanly fix at the moment.

TODO: Change the below default if needed to use the correct default integration types and contexts

I also need to check what the behavior is for undocumented fields in the payload from discord that may be added in the future. I believe the best option is to ignore those fields.
This gist (https://gist.github.com/Icebluewolf/1842ea5f7234ba40e5df18191bb135a0) contains 2 files. The first is where I developed the fix so that I did not have to make real API calls and is here for reference if someone wants to do the same. The second is unit tests for the new system. Both are very rough and messy sorry 🙃. This change needs to be tested extensively, so if someone sees test cases I missed or more test cases that should be added please let me know.

This PR attempts to fix the long running issue with the application command auto-syncing system. Currently the system is over eager and preforms upserts on commands that do not need to be updated. The main culprit is incorrect default value checking. This PR implements a more robust and easily extendable comparison system for commands.

Information

  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed).
  • This PR is not a code change (e.g. documentation, README, typehinting,
    examples, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why.
  • I have updated the changelog to include these changes.

@pycord-app
Copy link

pycord-app bot commented Nov 5, 2025

Thanks for opening this pull request!
Please make sure you have read the Contributing Guidelines and Code of Conduct.

This pull request can be checked-out with:

git fetch origin pull/2990/head:pr-2990
git checkout pr-2990

This pull request can be installed with:

pip install git+https://github.com/Pycord-Development/pycord@refs/pull/2990/head

@Lulalaby Lulalaby added bug Something isn't working help wanted Extra attention is needed labels Nov 5, 2025
@github-project-automation github-project-automation bot moved this to In Progress in Pycord Releases Nov 5, 2025
@Lulalaby Lulalaby requested review from a team and Lulalaby November 5, 2025 04:40
Lumabots and others added 19 commits November 7, 2025 17:15
Introduces the AppInfo.edit coroutine to allow editing application settings. Updates AppInfo and related types to support new fields such as bot, flags, event webhooks, integration_types_config, and approximate_user_authorization_count. Also refactors type hints and improves handling of optional fields for better API compatibility.
Introduces the AppInfo.edit() method to allow editing application settings, including new and previously missing fields such as icon, cover_image, tags, install_params, integration_types_config, flags, event_webhooks_url, event_webhooks_status, and event_webhooks_types. Also adds related helper classes and properties for handling these fields and updates the CHANGELOG accordingly.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
Updated the AppInfo class to only accept bytes or None for the icon and cover_image parameters, removing support for str. This change clarifies the expected types and may prevent type-related errors.
@Paillat-dev Paillat-dev modified the milestones: v2.8.0, Next minor rc1 Mar 15, 2026
Copy link
Member

@Paillat-dev Paillat-dev left a comment

Choose a reason for hiding this comment

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

Have had this bug where commands are not being upserted when an option goes from required to non required:

bot = discord.Bot()

my_group = bot.create_group(name="my_group")


@my_group.command(name="my_command")
async def my_command(ctx: discord.ApplicationContext):
    await ctx.respond("Hello world!")


@my_group.command(name="hello", description="Say hello to a user")
async def hello(ctx: discord.ApplicationContext, user: discord.User | None = None):
    user = user or ctx.user
    await ctx.respond(f"Hello {user.mention}!")


@my_group.command(name="hello2", description="Say hello to a user")
async def hello2(ctx: discord.ApplicationContext, user: discord.User | None = None):
    user = user or ctx.user
    await ctx.respond(f"Hello {user.mention}!")


@bot.slash_command()
async def ping(ctx: discord.ApplicationContext):
    await ctx.respond("Pong!")

# Start the bot
# -> DEBUG:discord.bot:Bulk updating commands {'my_group': 'upsert', 'ping': 'upsert'} for guild None
# /my_group hello2 requires user, /my_group hello does not
# Make /my_group hello2 user not required
# Restart the bot
# should re-sync, yet
# DEBUG:discord.bot:Skipping bulk command update: Commands are up to date

@Paillat-dev Paillat-dev removed the hold: changelog This pull request is missing a changelog entry label Mar 18, 2026
@Icebluewolf
Copy link
Member Author

That was actually an issue with sub command checking. I was returning if the first sub commands was or was not the same and never checking the other sub commands. Added tests to cover this case as well now.

@Paillat-dev
Copy link
Member

@Icebluewolf I think you forgot to push

@Lulalaby
Copy link
Member

oh so its not me wondering where the damn commit is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working help wanted Extra attention is needed hold: testing This pull request requires further testing PA: All Contributors pending PA: Maintainers pending priority: medium Medium Priority

Projects

Status: Todo
Status: In Progress

Development

Successfully merging this pull request may close these issues.

Remove for perms v2

5 participants