AudioPlayer amd VoiceConnection life and listeners
If I destroy a voice connection that has an audioplayer subscribed, will the player also be garbage collected / destroyed?
What about any event listeners attached to them? Do I need to remove them, or destroying the VoiceConnection removes them as well?
4 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!What do you refer to by "no reference"?
Oh yeah right, I reread the guide and it is indeed there, sorry.
Does declaring it as a constant like in the guide tho count as reference?
const player = createAudioPlayer();
Thank you!
So let's say I have two commands, one that connects the bot to a channel and plays something, and attaches some listeners to both the connection and the player to see their states. And the other disconnects the bot from voice.
How would I ensure no garbage is left where it shouldn't be?
I did this in the disconnect command:
is this valid?
or I could actually store the connection in a const as it does have it's destroy method, only the player needs to be without references.. 🤔 ?