fix: Command Auto Syncing#2990
fix: Command Auto Syncing#2990Icebluewolf wants to merge 10 commits intoPycord-Development:masterfrom
Conversation
|
Thanks for opening this pull request! This pull request can be checked-out with: git fetch origin pull/2990/head:pr-2990
git checkout pr-2990This pull request can be installed with: pip install git+https://github.com/Pycord-Development/pycord@refs/pull/2990/head |
|
@Icebluewolf Feel free to mark this as ready for review once you think it is ready, note the linter failing in the gh actions |
|
Do you think that #1745 could be addressed here as well ? |
|
I updated the gist in the description to include a test file I do expect to do some cleanup tasks as well |
discord/bot.py
Outdated
| (MISSING, {0, 1}), lambda x, y: set(x) != set(y) | ||
| ), | ||
| # Discord States That This Defaults To "your app's configured contexts" | ||
| "contexts": DefaultSetComparison( |
There was a problem hiding this comment.
Could we fetch our app info and then fill it based on that ? See @Lumabots 's appinfo PR. Or would that not work ?
There was a problem hiding this comment.
Do we get app info before on_connect is called? Also that PR is not merged yet so this would have to wait.
There was a problem hiding this comment.
We don't but we could if this requires it
|
I have not done extensive testing with sub commands, sub sub commands, and if Discord gives extra information that we dont care about (aka not implemented) in the payload. |
|
Updated my tests in the gist again. This should be fully functional now except for integration types. I believe contexts does not need special casing like I previously thought. |
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.
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
examples, ...).
Checklist
type: ignorecomments were used, a comment is also left explaining why.