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
GuikiPT
GuikiPT•3y ago
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
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
GuikiPT
GuikiPT•3y ago
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
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
GuikiPT
GuikiPT•3y ago
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 bot
GuikiPT
GuikiPT•3y ago
GuikiPT
GuikiPT•3y ago
this 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
GuikiPT
GuikiPT•3y ago
but actually
No description
GuikiPT
GuikiPT•3y ago
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
space
space•3y ago
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.
GuikiPT
GuikiPT•3y ago
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
space
space•3y ago
By forwarding the packet Lavalink gives you.
GuikiPT
GuikiPT•3y ago
because the command will destroy the lavalink connection and also make it leave no, just destroy and it will leave for it self
space
space•3y ago
The one causing the bot to disconnect. When in doubt, all.
GuikiPT
GuikiPT•3y ago
for example
No description
GuikiPT
GuikiPT•3y ago
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
space
space•3y ago
How do you make the bot join?
GuikiPT
GuikiPT•3y ago
yeah i was ing it
No description
GuikiPT
GuikiPT•3y ago
but never used
GuikiPT
GuikiPT•3y ago
ok you are calling for the destroy path
No description
GuikiPT
GuikiPT•3y ago
and that's was not disconnecting you bot, is it?
space
space•3y ago
This is communicating with Lavalink, not Discord; This won't make it connect.
GuikiPT
GuikiPT•3y ago
Thonkang
space
space•3y ago
But isn't this making djs do all the voice stuff? This will interfere with Lavalink. confusedBecel
GuikiPT
GuikiPT•3y ago
hum what i can do becuse i dont know working with they api is watching some destroy events from wrappers let me check
GuikiPT
GuikiPT•3y ago
i know is not js
No description
GuikiPT
GuikiPT•3y ago
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
space
space•3y ago
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()
GuikiPT
GuikiPT•3y ago
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
space
space•3y ago
That's needed to start a connection
GuikiPT
GuikiPT•3y ago
well,i was don;t undestand this code
No description
GuikiPT
GuikiPT•3y ago
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
GuikiPT
GuikiPT•3y ago
already trying something
No description
space
space•3y ago
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)
GuikiPT
GuikiPT•3y ago
little confusing using this xD
space
space•3y ago
No, you want to use 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. jynEHEH 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

Did you find this page helpful?