Skip to content

Muting/unmuting a user changes the sequence number of packets they send #1085

@NDobricic

Description

@NDobricic

Summary

I have a bot (not mine) playing some music on repeat which is meant to simulate a user talking. My bot's job is to constantly listen to all users in the channel using the VoiceReceive event from VoiceNext. If I'm connected to the channel from my account and I mute and then unmute the bot that's playing music (just for myself, this is not a server mute), the sequence numbers of the packets that my bot is receiving become completely different.

Steps to reproduce

  1. Log the packet sequence number to the console from function ProcessPacket in VoiceNextConnection.cs
  2. Join a channel from your account
  3. Find a bot to provide a constant stream of audio (I used the Pancake bot and played music on repeat)
  4. Mute the bot for yourself
  5. Wait for 10-20 seconds
  6. Establish a VoiceNextConnection to the channel and set EnableIncoming to true
  7. Your bot should start logging the sequence numbers of the packets it's receiving
  8. Unmute the music bot from your account
  9. The sequence numbers should become completely different

Notes

The result is the same regardless of what machine I'm connected from (phone or PC). I've even tried connecting from both my PC and my phone at the same time using different accounts and muting/unmuting from either still changes the sequence numbers (different values depending on the account!).

IMPORTANT: From what I've gathered during my testing, this only happens if both the music bot and my account were connected to the channel before my bot joins the channel and starts receiving packets.

I've tried playing audio with 2 different music bots (Pancake and Octave) and the result is the same.

I'm not an expert on this topic but as far as I can see from the source code, the sequence numbers are retrieved directly from Discord and are not being altered by the library. I have no idea how to fix this or why this happens in the first place, but it should be dealt with since it creates 2 big issues:

  1. If the sequence number becomes lower than it was before muting/unmuting, all of the subsequent packets will be discarded because the library thinks they are out of order
  2. If the sequence number becomes larger than it was before, the library thinks that those packets in between were lost and fills the "gap" with empty PCM data (which should not happen in this case since there was no gap in reality)

Metadata

Metadata

Assignees

No one assigned

    Type

    Effort

    None yet

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions