Voice self-disconnect not working with Lavalink
- 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!36 Replies
deppending of the wrapper you are using
you may have .disconnect()
maybe
hum, kick the bot of the voice call
and try again
becuse
if you restart the bot or the bot crash
and they are on the call
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Like, if it gave an error and disconnected or was restarted while it was connected in a call, it says that it is not connected
that problem happend with me when i was testing my also lavalink bot and they crash
hum, it not depend of lavalink
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
and yes
the wrapper
and also you tryed
to kick the bot of the voice call and execute again?
I already had similar problems, when I made the music bot and it for some reason crashed, I restarted and it accused that it was not in the call (but they was). Because the lavalink wrapper and lavalink only recognize that it is in a call when you call the
voice creation, if you restart the bot, you lose that connection
i can reproduce maybe what you having
let me grab my botthis is what i think you are facing
What i do:
Play a music into a voice chat -> shutdown the bot -> restart the bot -> try to disconnect then from the call
what they say:
I not connected to a voice call
but actually

you need to make lavalink/the wrapper reconnect into the voice
how?, maybe join or play command, that make new voice client to the voice call channel
joining / leaving (/moving to) a voice channel is done through main ws and not voice ws, so need to happen in/through djs.
Lavalink gives you the packets you need to forward to Discord (through djs) by sending you some event, forwarding these will fix those still connected bots in cases of non-restarts.
When restarting you either just wait for the session to timeout or can manually tell Discord that you'd like to join (again) or disconnect.
yes
I couldn't explain it very well but in short it's there.
And this doesn't only happen with djs, this bot in the video is done in dpy and has the same problems as djs
in this case, if i do z!stop yes
By forwarding the packet Lavalink gives you.
because the command will destroy the lavalink connection and also make it leave
no, just destroy
and it will leave for it self
The one causing the bot to disconnect. When in doubt, all.
for example

in this case is erelajs
but erela get deprecated
what are u using?
let me check
or you, are using directly lavalink API?
Oh
this is more sofisticated
hum
let me browse some docs
here
How do you make the bot join?
yeah i was ing it

but never used
ok you are calling for the destroy path

and that's was not disconnecting you bot, is it?
This is communicating with Lavalink, not Discord; This won't make it connect.

But isn't this making djs do all the voice stuff? This will interfere with Lavalink. 

hum
what i can do
becuse i dont know working with they api
is watching some destroy events from wrappers
let me check
i know is not js

but what the dpy wrapper for lavalink do
i update the voice status from a guild
to none
i have a wrapper called wavelink for discord .py (dont ban me mods 🤣 )
and in my command i go to package definition andfind it
Probably, the Lavalink Docs should describe what to do and to send to Discord WS.
On the djs side of things you want to go guild -> shard -> send()
hum, for me (because im very new do dpy), it's seems to update the voice state of the bot in the provided guild
to NONE
i was testing it now with some modifications
That's needed to start a connection
well,i was don;t undestand this code

but it's seems to be
well, i
i will try to make with nodejs acessing directly
to lavalink api
never done it before
but if I want help or at least try to understand
just ending some things in my job and i will try
already trying something

Joining a channel is done before establishing a connection to the voice ws.
Looks like you wondered in
3. here:
https://github.com/lavalink-devs/Lavalink/blob/master/IMPLEMENTATION.md#common-pitfalls
But the docs looks sparser than I remember them.
Looks like you manually need to manage the channel join / leave (/ switch) aspect then.
You can grab the relevant WS from Guild#shard and then send whatever you want to it by using the send method.
You can see what the payload looks like here: https://github.com/lavalink-devs/Lavalink/blob/master/IMPLEMENTATION.md#special-notes
You can listen to the respective events from Discord through Client#ws.
(i.e. VOICE_SERVER_UPDATE and VOICE_STATE_UPDATE)little confusing using this xD
No, you want to use
should use the way I pointed out, going through
Guild#shard https://old.discordjs.dev/#/docs/discord.js/main/class/Guild?scrollTo=shard
Stuff starting with _ are generally private and you shouldn't use them.
It's right up there in my response 😅
You're welcome 🙌
The event does not seem to exist anymore. I can't really tell you why.
should use the way I pointed out, going through Client#ws however.
Yeah, Discord still sends the event, but discord.js does no longer do anything with it directly.
@discordjs/voice gets it untransformed through Client#ws and so should you.
"raw" is not really intended for this use, but rather for debugging / testing purposes.
Carefully
You listen to it using the name of the event you care about, i.e. VOICE_SERVER_UPDATE.
It's not private
Documented and public:
- https://old.discordjs.dev/#/docs/discord.js/main/class/Client?scrollTo=ws
- https://old.discordjs.dev/#/docs/discord.js/main/class/WebSocketManager
Yes, that looks like what you should do. (Maybe using an enum instead of the string there, but w/e)
discord-api-types got GatewayDispatchEvents