Lavalink&Bot saying it's playing, but Bot wont join the channel
Hi,
Im new to moonlink.js and have worked with erela.js years ago, so i want to make a Radio Bot that should start all streams automatically when the Bot gets started. The Lavalink recieves the requests, and the bot also answers that it started playing, but the bot wont connect to my voice channel. I've included all Intents, the Bot has Administrator Perms, i've already tried to fetch the guild/all channels on startup but still it's refusing to connect to the Voice Channel. If i run the same command manually it works fine. I think it has something to with the cache but idk. Maybe someone can help!
I do not recieve any errors in my bot/lavalink.
The code is here:
Thanks for your Time & Merry Christmas
36 Replies
Hello, I just have one question, how did you put the spayload function in the main constructor?
client.moon = new MoonlinkManager(
[],
{},
Spayload
)
I forgot, merry Christmas to you too :hi:
adverse-sapphireOP•15mo ago
🙂
Will Send you tomorrow
When i am on My Computer. But i Think Its just default
Do you use discord.js V14?
adverse-sapphireOP•15mo ago
Yes
Did you place the intents in these stores?
adverse-sapphireOP•15mo ago
Yea
In the Spayload function, could you put a console.log of the two parameters?
adverse-sapphireOP•15mo ago
Another question, i want to do a 24/7 stream and I know that the stream will disconnect at one time because of discord. Do you know how I can detect this and reconnect automatically and how I can resume all lavalonk streams that have not been finished on reboot?
discord.js has an event called voiceStateUpdate
You can use it to identify if you have been disconnected from a call
For example:
In reality, I think you can do it using the package instead of the event
In moonlink there is an event called playerDisconnected
playerDisconnect: (player: MoonlinkPlayer) => void;
Disconnect*
It will output the player that was disconnected, you can reuse the class to connect in the call and restart
client.moon.on("playerDisconnect", async(player) => {
player.connect()
await player.restart()
})
I think this is the only thing that works
Restarting will make moonlink send the player information again and continue where it left off
adverse-sapphireOP•15mo ago
Okay, but will this work also with radio streams? Like it does not has an ending point
GG @Fireball, you just advanced to level 1!
Yes, in a stream it goes to the position where the stream is
I think, because I never tried it much on stream, I don't know if there's a way to go back 😦
I don't think so, because generally stream doesn't have a limit so the position is negative
It will stay where it is currently playing on the stream
adverse-sapphireOP•15mo ago
It’s not needed to go back
It only needs to restart the stream
Idc if it not continues
I'll give it a test
adverse-sapphireOP•15mo ago
Thanks
Did a question manage to make it work?
adverse-sapphireOP•15mo ago
?
Fix the bot thing that couldn't connect...
adverse-sapphireOP•15mo ago
Yea I got it by installing the newest version and doing some other stuff with fetching all guilds/channels
I think it couldn’t start the stream, bc it couldn’t find the channel as nothing was in the bots cache, so I’ve done a fetch function and a delay for the stream start
new error when playing a spotify playlist:
SyntaxError: Unterminated string in JSON at position 1200
at JSON.parse (<anonymous>)
at MoonlinkNode.message (C:\Users\paul0\Desktop\lavabeats\node_modules\moonlink.js\dist\src@Entities\MoonlinkNode.js:178:28)
at WebSocket.emit (node:events:513:28)
at Socket.<anonymous> (C:\Users\paul0\Desktop\lavabeats\node_modules\moonlink.js\dist\src@Services\PerforCWebsocket.js:124:30)
at Socket.emit (node:events:513:28)
at addChunk (node:internal/streams/readable:324:12)
at readableAddChunk (node:internal/streams/readable:297:9)
at Readable.push (node:internal/streams/readable:234:10)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
SyntaxError: Unexpected token 'w', "tworkUrl":n"... is not valid JSON
at JSON.parse (<anonymous>)
at MoonlinkNode.message (C:\Users\paul0\Desktop\lavabeats\node_modules\moonlink.js\dist\src@Entities\MoonlinkNode.js:178:28)
at WebSocket.emit (node:events:513:28)
at Socket.<anonymous> (C:\Users\paul0\Desktop\lavabeats\node_modules\moonlink.js\dist\src@Services\PerforCWebsocket.js:124:30)
at Socket.emit (node:events:513:28)
at addChunk (node:internal/streams/readable:324:12)
at readableAddChunk (node:internal/streams/readable:283:9)
at Readable.unshift (node:internal/streams/readable:239:10)
at Socket.<anonymous> (C:\Users\paul0\Desktop\lavabeats\node_modules\moonlink.js\dist\src@Services\PerforCWebsocket.js:148:33)
at Socket.emit (node:events:513:28)
-> after that, the music plays succesfully, but no events are triggered AND new requests wont be accepted with error "No Lavalink is connected"
i have the lavasrc plugin installed on my lavalink, but nothing on my bot side
& when using player.skip() i get
adverse-sapphireOP•15mo ago
It appears to be a Websocket code error
I will change to ws which is more stable
adverse-sapphireOP•15mo ago
okay, but like do i need any plugin for spotify on the bot code site, or just on the lavalink?
You just need LavaSrc and it will work
adverse-sapphireOP•15mo ago
ok
perfect
@1Lucas1.apk are you here
GG @Fireball, you just advanced to level 2!
adverse-sapphireOP•15mo ago
i have a question
so i have an array with youtube song urls, but somehow i cant add them to the queue, as it says i need to add it as a string/array
Hello
Moonlink doesn't support url arrays, but I can support it as soon as I figure out what I did wrong in websocket
adverse-sapphireOP•15mo ago
ok
but if i do this
it still wont play the song
I can't modify it to support array, because search already works with 2 types, object with sorce and request information and string, this causes conflict to support array
You will have to use this code you made 🥺 using map
A thousand apologies
adverse-sapphireOP•15mo ago
no problem
returns 0
is that right?
i need the already played duration, like how many seconds have already been played, is that the right function
or does that give me the status of the queue or some shit
Hello again, tomorrow I will fix this error, I apologize
@Fireball
I finished publishing a new version correcting the position
GitHub
Release v3.0.8 · Ecliptia/moonlink.js
What's Changed
Fixed track position error not leaving 0 by @1Lucas1apk in #53
Full Changelog: v3.0.5...v3.0.8
adverse-sapphireOP•15mo ago
Hi, sorry to annoy you again, but i think i found another bug
so what i am trying to do is a /back or /previous command, where you can play the last title again. but currently
player.previous
returns the current playing song and not the last played song
this is still not right. it sometimes returns the number in negative and sometimes in positive, also for me it always starts at 0:30minutes
sometimes the duration is -0:30 and sometimes its 0:30adverse-sapphireOP•15mo ago
https://i.imgur.com/E5VB65K.png soon its finished :D green=working, red=notworking, yellow:sometimes working
Thank you for reporting the errors, I will analyze the internal codes and update
It's getting really cool
I think I'm going to modify the position for two parameters, realtimeposition and position, brought by lavalink
adverse-sapphireOP•15mo ago
yeah