Closed Yanishamburger closed 5 months ago
const lastPlayedTrack = player.queue.previous[0];
await player.queue.add(lastPlayedTrack); // to add to the pos in the queue 0 use: player.queue.splice(0, 0, lastPlayedTrack);
await player.skip();
or:
const lastPlayedTrack = player.queue.previous[0];
await player.play({ clientTrack: lastPlayedTrack });
Thank you, how can you activate auto recovery also please ?
what do you mean with "auto recovery"
you can provide the resume header on connect with the note, which then provides you the player data on the resumed event you can also provide a queuestore, to automatically store the queue remotely e.g. on redis or a database
Its auto resume, Do you have an example script to do this if it's not too much to ask? I'm not familiar with databases
I told you a way which doesn't need you to know databases.. you can also make it yourself by running a loop saving the player + queue data in a db and when yo uwant to call "autoresume" you create a player by the database data..
Sorry, I'm not English, I'm translating... So the answers are not exactly understandable to me. I should create an event for this or put it in the main file ?
And how to retrieve the header automatically?
https://lavalink.dev/api/index.html#resuming
or for more strict and manual playback control: on playerCreate create a interval, which saves the player data + player.queue in a database on "yourautoresume function" get the saved data(s) and create the player(s) with the queue
or
you can use ManagerOptions.queueOptions.queueStore to automatically store the queue externally.
to use resuming, you must do the following:
node.updateSession(true, 60000)
(enable resuming 'true' - allow it to keep playing while the bot is offline for 60000ms)node.sessionId
and then stop the playersessionId
in the nodeOptions while connecting (creating) the node nodes: [ {...nodeOptions, sessionId: "" }]
node.on("resumed", (node, payload, allNodePlayersFetched) => { /* handle it*/ })
Ok thx very much, I wish you a good day/evening if I have any other questions I will get back to you thank you again. You are a great help.
your welcome, you can also check out my musicium repository, how i did the queue sync there... it's same "principle" but different way of music playback.. (not lavalink) so you'd need to adapt!
Hello, how do I get the previous music because it gives me undefined when I go in the right path once the music skips.
I use player.queue.previous (it gives me the old skip music but when I want to play them again I cannot access the uri or the name because they are undefined)
Also i need help if you can tell me how to enable auto resume.
I use lavalink v4