discord.js: Voice Connection not null but voice channel is undefined

image

image EDIT: Updated the screenshot due to a mistake on my part when testing with eval. The issue still persisted at the time whether I had .voiceChannel or .channel, since the argument on my end is that I would get a null value for both.

This happens occasionally and I’m not sure what causes it. Sometimes my bot will be returning a voiceConnection for a guild, but it’s not visibily in any voice channels and the voice channel is undefined. Calling .disconnect() seems to do nothing, as the bot still returns a voiceConnection.

  • discord.js version: 11.1
  • node.js version: 6.10
  • OS: Distributor ID: Debian, Description: Debian GNU/Linux 8.5 (jessie), Release: 8.5, Codename: jessie
  • Low/Medium priority. Reproducibility is about 5% of the time, but only in “production”. I can’t reproduce it at all on my test bot.

This has been occurring since v9 but hasn’t been reliably reproducible. I can try using node v7 too but it’s hard for me to figure out what’s causing it. I think it’s a timeout issue where the bot may disconnect as soon as it connects, but the library still thinks there’s a voice connection. Is there a way to absolutely force disconnect to destroy a connection just in case?

I’ve also tried some ultra defensive coding around it as well… image

But like I said, .disconnect() does nothing after this starts happening for a guild and this code ends up failing, saying there’s a voice connection. If I restart my node process, it works as intended again but until I do that, it seems to not work after that.

The status is 4, not 0: image

Code example: image

What else should I provide?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

I don’t even see your problem, other then the voiceChannel part. I don’t know how people have not realized this… .voiceChannel has never been a method on a voiceConnection. Please do some more research before marking something as a bug. Like holy hell. If this is a bigger issue then enlighten me. Because I don’t really see your issue. My bot never sticks around a voice connection and never hangs in a channel unless I restart it. Maybe it’s because your storing the items in the guild. Which I used to do at one point then it all stopped working so I moved to maps. If you want a general understand of maps to be used in a voice bot let me know and I will be happy to write something up for you to see how maps work. Of course only if you don’t already know about maps.

Maps are a way better way of doing it and being able to delete that guilds map upon disconnect is much better.

EdibleDerpy’s comment

How was this not noticed before? 😂😂😂

As you can see, I made a PR (referenced above) to attempt to fix this. Please try it out and let me know if there are any unexpected issues and whether it fixes the issue for you.