andersfylling / disgord

Go module for interacting with the documented Discord's bot interface; Gateway, REST requests and voice
BSD 3-Clause "New" or "Revised" License
502 stars 71 forks source link

VoiceChannel().Connect() seems to not handle moving channels properly #473

Open ImVexed opened 2 years ago

ImVexed commented 2 years ago

Describe the bug 1: Connect to a voice channel and start playing audio (in my case calling SendOpusFrame in a loop) 2: Move the bot to a different voice channel 3: Audio stops playing, and no errors are returned

Expected behavior SendOpusFrame to either return an error to close the voice connection, or, preferably, handle the move to a new channel seamlessly and have SendOpusFrame continue working as expected, just in the new channel.

Error messages DEBU[0014] [ws-v,s:7,shard:0]discord sent a 4014 websocket code and the bot will now disconnect But no other errors returned

Desktop (please complete the following information):

andersfylling commented 2 years ago

I have to take a look into this before making a call, but I have grown quite a liking to minimalistic api's that can be used by helper functions, so if you throw up a PR that simply returns an error when this happens I won't mind merging that. Should allow for a future implementation that has a seamless move imo.

ImVexed commented 2 years ago

If we do have SendOpusFrame return an error to notify the calling function that the bot has been moved, how should the calling function be expected to proceed? Call Close() and disconnect the bot? What if the calling function wants to continue to play audio in the new channel? As in that case the calling function would need to find what channel it was moved to, Close() , then re-connect to voice in that new channel and start sending opus frames again.

ImVexed commented 2 years ago

Also, maybe worth another ticket, but the same thing seems to happen when discord requests a reconnect:

time="2022-02-17T05:07:36Z" level=info msg="[ws-e,s:8487,shard:0]Discord requested a reconnect"
time="2022-02-17T05:07:36Z" level=debug msg="[ws-e,s:8488,shard:0]is reconnecting"
time="2022-02-17T05:07:36Z" level=debug msg="[ws-e,s:8489,shard:0]closing emitter"
time="2022-02-17T05:07:36Z" level=debug msg="[ws-e,s:8491,shard:0]stopping pulse"
time="2022-02-17T05:07:36Z" level=debug msg="[ws-e,s:8490,shard:0]closing operations handler"
time="2022-02-17T05:07:36Z" level=debug msg="[ws-e,s:8492,shard:0]closing receiver"
time="2022-02-17T05:07:36Z" level=info msg="[ws-e,s:8493,shard:0]disconnected"
time="2022-02-17T05:07:36Z" level=debug msg="[ws-e,s:8494,shard:0]trying to connect"
time="2022-02-17T05:07:36Z" level=debug msg="[shardSync]shard0is waiting to identify"
time="2022-02-17T05:07:37Z" level=debug msg="[ws-e,s:8495,shard:0]waiting to send identify/resume"
time="2022-02-17T05:07:37Z" level=debug msg="[ws-e,s:8496,shard:0]starting receiver"
time="2022-02-17T05:07:37Z" level=debug msg="[ws-e,s:8497,shard:0]starting emitter"
time="2022-02-17T05:07:37Z" level=debug msg="[ws-e,s:8498,shard:0]Ready to receive operation codes..."
time="2022-02-17T05:07:37Z" level=debug msg="[ws-e,s:8499,shard:0]heartbeat ACK ok"
time="2022-02-17T05:07:37Z" level=debug msg="[ws-e,s:8500,shard:0]sent heartbeat"
time="2022-02-17T05:07:37Z" level=debug msg="[ws-e,s:8501,shard:0]sendHelloPacket is acquiring once channel"
time="2022-02-17T05:07:37Z" level=debug msg="[ws-e,s:8502,shard:0]writing to once channel0xc000455aa0"
time="2022-02-17T05:07:37Z" level=debug msg="[ws-e,s:8503,shard:0]finished writing to once channel0xc000455aa0"
time="2022-02-17T05:07:37Z" level=debug msg="[ws-e,s:8504,shard:0]sent identify/resume"
time="2022-02-17T05:07:37Z" level=debug msg="[shardSync]shard0waited and finished execution after123.116143ms"
time="2022-02-17T05:07:37Z" level=debug msg="[ws-e,s:8505,shard:0]establishing connection succeeded"
time="2022-02-17T05:07:37Z" level=debug msg="[ws-v,s:23,shard:0]discord sent a 4014 websocket code and the bot will now disconnect"

After this, SendOpusFrame will continue to run without returning errors