AudioPlayer.playable includes undefined channels

I've noticed a bug that comes and goes infrequently where AudioPlayer.playable includes voice connections whose joinConfig.channelId references a channel that doesn't exist. For example, I would like to run some code for every active voice connection. I do this as follows:
audioPlayer.playable.forEach(connection => {
let channel = Client.channels.cache.get(connection.joinConfig.channelId);

// do some cool stuff 😎
});
audioPlayer.playable.forEach(connection => {
let channel = Client.channels.cache.get(connection.joinConfig.channelId);

// do some cool stuff 😎
});
I expect channel to be set to the Voice Channel in which the connection is in, however in some rare cases, channel ends up being undefined. No sharding has been implemented so I would expect the bot to have cached every channel it has access to. Relevant Documentation Page: https://discordjs.dev/docs/packages/voice/0.11.0/AudioPlayer:Class#playable
voice | AudioPlayer
Used to play audio resources (i.e. tracks, streams) to voice connections.
1 Reply
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server