-
Notifications
You must be signed in to change notification settings - Fork 808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't use VoiceConnection when the bot is moved to another vc by a User #849
Comments
I'm having same issue. When I moved the bot to another VC, I got the following log.
This log is output from voice.go Lines 351 to 368 in 37088ae
I found the same issue at Rapptz/discord.py#5904. |
Btw, as a general Go tip, you need not store it as a global. If you have something like this: type MyBot struct {
d *discordgo.Session
vc *discordgo.VoiceConnection
}
func (b *MyBot) onError(str string, err error) {
b.vc.Disconnect()
} You can assign a method "bound" to this struct like this: func main() {
bot := &MyBot{}
// assign some things inside bot
dgvoice.OnError = bot.onError
} |
Ran into a situation where when playing a sound, if the bot was moved to another voice channel, it seemingly gets stuck in limbo. Running
Disconnect()
just crashes.s.VoiceConnections[e.GuildID]
seems to just flat out returnnil
every time (for me at least).I was able to sorta get around this by storing the
VoiceConnection*
as a global, then setting a custom error handler for dgvoice:then setting up an event handler for
voiceStateUpdate
:This also requires #833 in order to work, or some manual work keeping track of the bot's previous voice channel.
Basically, if it detects the bot being moved (
e.BeforeUpdate != nil
) then it reconnects to the same channel manually, bringing it out of "limbo". Then it just disconnects.Obviously this isn't the end of the world, but it's a pretty rough fix. Does anyone have any better approaches? My ideas are:
VoiceStateUpdate
, then it's at least a bit easier for users to define their wanted behaviorVoiceConnection*
update itself when movedThoughts?
The text was updated successfully, but these errors were encountered: