Skip to content

refactor: update interaction responses to be deferal if theres db actions#779

Open
flaree wants to merge 2 commits into
Ballsdex-Team:v3from
flaree:feat/deferAnyDbCommands
Open

refactor: update interaction responses to be deferal if theres db actions#779
flaree wants to merge 2 commits into
Ballsdex-Team:v3from
flaree:feat/deferAnyDbCommands

Conversation

@flaree

@flaree flaree commented Jun 8, 2026

Copy link
Copy Markdown
Member

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_message with interaction.followup.send after deferring responses, ensuring proper handling of ephemeral and long-running interactions across commands in balls/cog.py, guildconfig/cog.py, info/cog.py, and players/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.py by 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.

@flaree flaree requested review from a team and Copilot June 8, 2026 14:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 to interaction.followup.send(...).
  • Trade commands were updated to defer early and consistently use followups for user-facing replies.
  • Countryball catching now ignores discord.NotFound when 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.

Comment thread ballsdex/packages/players/cog.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants