Skip to content

Conversation

@kar8uncle
Copy link
Contributor

As instructed in Discord documentation, if resuming did not succeed,
the bot should attempt to reconnect from scratch.

Why do we need to reconnect from scratch?

It seems that a resume does not have to succeed after voice connection closes. See Discord documentation Voice#Buffered Resume

The resume may be unsuccessful if the voice gateway buffer for the session no longer contains a message that has been missed. In this case the session will be closed and you should then follow the Connecting flow to reconnect.

What changed?

In this change I made discord_client pass a callback into voiceconn for initiating the voice connection. voiceconn also passes a callback into its owning discord_voice_client to execute when resuming fails. This callback will make voiceconn reinitiate the voice connection through its creator (the discord_client). This works even after shard reconnects.

Testing

I left the bot running in a voice channel for 2 days. Verified in the log that full voice reconnection, and shard reconnection were both triggered. Finally, I joined the voice channel myself and talked, the bot still receives my voice data.

Code change checklist

  • I have ensured that all methods and functions are fully documented using doxygen style comments.
  • My code follows the coding style guide.
  • I tested that my change works before raising the PR.
  • I have ensured that I did not break any existing API calls.
  • I have not built my pull request using AI, a static analysis tool or similar without any human oversight.

@netlify
Copy link

netlify bot commented Jul 18, 2025

Deploy Preview for dpp-dev ready!

Name Link
🔨 Latest commit 33b0165
🔍 Latest deploy log https://app.netlify.com/projects/dpp-dev/deploys/6879fbf2b71d3f00086ea108
😎 Deploy Preview https://deploy-preview-1465--dpp-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions bot added documentation Improvements or additions to documentation code Improvements or additions to code. labels Jul 18, 2025
As instructed in Discord documentation, if resuming did not succeed,
the bot should attempt to reconnect from scratch.
@braindigitalis braindigitalis merged commit 8293247 into brainboxdotcc:dev Jul 18, 2025
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code Improvements or additions to code. documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants