refactor: update interaction responses to be deferal if theres db actions#779
Open
flaree wants to merge 2 commits into
Open
refactor: update interaction responses to be deferal if theres db actions#779flaree wants to merge 2 commits into
flaree wants to merge 2 commits into
Conversation
…better user experience
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors Discord interaction handling across multiple cogs to avoid interaction timeouts by deferring responses before database/long-running work, and then replying via interaction.followup. It also adds a small robustness improvement when editing spawn messages and improves spawn-failure logging context.
Changes:
- Deferred interactions (
interaction.response.defer(...)) were added to DB/long-running command handlers, with replies moved tointeraction.followup.send(...). - Trade commands were updated to defer early and consistently use followups for user-facing replies.
- Countryball catching now ignores
discord.NotFoundwhen the spawn message was deleted before it could be edited; spawn failure logs now include ball + channel.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
ballsdex/packages/trade/cog.py |
Defers trade interactions earlier and switches replies to followups to prevent timeouts. |
ballsdex/packages/players/cog.py |
Adds defers to player-related commands and converts responses to followups for post-defer compatibility. |
ballsdex/packages/info/cog.py |
Defers info/help commands and replies via followups. |
ballsdex/packages/guildconfig/cog.py |
Defers config commands and updates responses to use followups. |
ballsdex/packages/countryballs/countryball.py |
Adds NotFound guard when editing a deleted spawn message; improves spawn failure logging. |
ballsdex/packages/balls/cog.py |
Defers favorite and updates responses to followups to avoid interaction expiry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaced all commands that have db actions to use deferal, so they wont just drop/int failed if theres any hanging with the db
Replaced all uses of
interaction.response.send_messagewithinteraction.followup.sendafter deferring responses, ensuring proper handling of ephemeral and long-running interactions across commands inballs/cog.py,guildconfig/cog.py,info/cog.py, andplayers/cog.py. [Added
await interaction.response.defer(...)at the start of all relevant command handlers to indicate processing and prevent timeouts for longer operations. This was consistently applied to commands that modify state or might take time, such as favourites, settings, friend/block management, and configuration.Error Handling and Logging Improvements:
Improved error handling in
countryballs/countryball.pyby adding a try/except block to gracefully handle cases where a message to be edited was deleted before completion, preventing uncaught exceptions.Enhanced logging for failed ball spawns to include the ball name and channel, making debugging easier.