Closed yazninja closed 1 year ago
Hey, something like that should work :
let query = interaction.options.getString("search_terms")
const queue = client.player.nodes.create(interaction.guild, {
metadata: {
channel: interaction.channel,
client: interaction.guild.members.me,
requestedBy: interaction.user,
},
selfDeaf: true,
volume: 80,
leaveOnEmpty: true,
leaveOnEmptyCooldown: 300000,
leaveOnEnd: true,
leaveOnEndCooldown: 300000,
});
if (!queue.connection) await queue.connect(interaction.member.voice?.channelId)
const search = await client.player.search(query, { searchEngine: QueryType.AUTO })
queue.addTrack(search.tracks)
await queue.node.play()
Try the following as it is working for me (YT and Spotify playlists):
Deleting node_modules and package-lock files. Then run npm i and try again
experiencing the same issue right now tried deleting node modules and package-lock files still not working
Can you guys share your play code so that we can take a look ?
Can you guys share your play code so that we can take a look ?
async function play_handler(interaction) {
const channel = interaction.member.voice.channel;
if (!channel)
return interaction.reply("You are not connected to a voice channel!");
const query = interaction.options.getString("query", true);
await interaction.deferReply();
try {
const searchResult = await player.search(query).catch(() => {
console.log("search failed");
});
if (!searchResult.hasTracks())
return interaction.followUp({content: "No results were found!"});
const {track} = await player.play(channel, searchResult, {
nodeOptions: {
metadata: interaction,
selfDeaf: false,
leaveOnEmpty: true,
leaveOnEmptyCooldown: 300000,
leaveOnEnd: true,
leaveOnEndCooldown: 300000,
},
});
return interaction.followUp(`**${track.title}** enqueued!`);
} catch (e) {
return interaction.followUp(`Something went wrong: ${e}`);
}
}
Node Version: 18.14.0 Discord Player Version: 6.0.0 Discord.js Version: 14.7.1
@sulsalloom
I tried your code.
Only thing I had to change was one line , metadata: interaction
to metadata: interaction.channel
.
After that everything worked as expected. Can you try that change to see if it fixes it.
@yazninja
The yt link that you gave (https://www.youtube.com/watch?v=572QgKc6xT8&list=RDCLAK5uy_k27uu-EtQ_b5U2r26DNDZOmNqGdccUIGQ) isn't a playlist, it's probably a yt music mix or something similar. (IDK much about those)
Playlist will have youtube.com/playlist?
in it. Player as far as I tested only supports such links.
The other two links worked perfectly fine for me.
The new event for same is playerStart
not trackStart
@sulsalloom I tried your code. Only thing I had to change was one line ,
metadata: interaction
tometadata: interaction.channel
.After that everything worked as expected. Can you try that change to see if it fixes it.
still the same using this playlist https://www.youtube.com/playlist?list=PLOHoVaTp8R7dfrJW5pumS0iD_dhlXKv17 also tested @yazninja other 2 lists both of them don't work
i tried trackStart and still @febkosq8
still the same using this playlist https://www.youtube.com/playlist?list=PLOHoVaTp8R7dfrJW5pumS0iD_dhlXKv17 also tested @yazninja other 2 lists both of them don't work
Just now tried that link works for me. Do you have your bot code on git ?
i tried trackStart and still @febkosq8
Do you have your bot code on git ?
@sawdex
Please create a git repo to show your code next time.
Can you update your event code to this and try again to see if its broadcasting the event ?
player.events.on('playerStart', (queue, track) => {
console.log("PlayerStart HIT");
if (queue.repeatMode !== 0) return;
queue.metadata.channel?.send({ embeds: [embed.Embed_play("Playing", track.title, track.url, track.duration, track.thumbnail, settings(queue))] });
});
@febkosq8 no embed i think the error from play command
image no embed i think the error from play command
So the event is working as intended. If you are fine with a simple update to the user, try what I have.
queue.metadata.send(`â–¶ | Started playing: **${track.title}**`);
@febkosq8 now working thank you, now I know that the problem is from embed.
@sulsalloom
You only have discord-player@6.0.0 in your package. You will need @discord-player/extractor, @discord-player/equalizer & @discord-player/utils for everything to properly work.
Run the following in terminal
npm i discord-player@latest @discord-player/extractor@latest @discord-player/equalizer@latest @discord-player/utils@latest
Then delete node_modules
& package-lock.json
.
Then run the following and try again
npm cache clean --force
npm i
@sulsalloom
You only have discord-player@6.0.0 in your package. You will need @discord-player/extractor, @discord-player/equalizer & @discord-player/utils for everything to properly work.
Run the following in terminal
npm i discord-player@latest @discord-player/extractor@latest @discord-player/equalizer@latest @discord-player/utils@latest
Then delete
node_modules
&package-lock.json
. Then run the following and try againnpm cache clean --force npm i
still same issue i pushed to the rep if you wanna have a look
@yazninja
The yt link that you gave (https://www.youtube.com/watch?v=572QgKc6xT8&list=RDCLAK5uy_k27uu-EtQ_b5U2r26DNDZOmNqGdccUIGQ) isn't a playlist, it's probably a yt music mix or something similar. (IDK much about those)
Playlist will have
youtube.com/playlist?
in it. Player as far as I tested only supports such links.The other two links worked perfectly fine for me.
Mixes are not supported, see skdhg/youtube-sr#31
@sulsalloom
I tried your code on my local machine, and it didn't work for me. I tried changing stuff but nothing worked out. Any single tracks would work. But no playlist would work. From debug logs, I found out that the searchResults are being fetched as expected but player.play doesn't seem to work. I also checked player debug event and every standard extractors were being loaded as expected.
Don't know what is going wrong over here. My best guess is the way your bot is structured. My bot uses cjs while yours use esm. I will try to dig around more in free time.
Error Stack
Error: Play request received but track was not provided
at GuildQueuePlayerNode.play (<dir>/discord-bot/node_modules/discord-player/dist/index.mjs:863:13)
at GuildQueuePlayerNode.play (<dir>/discord-bot/node_modules/discord-player/dist/index.mjs:888:16)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async _Player.play (<dir>/discord-bot/node_modules/discord-player/dist/index.mjs:2581:7)
at async play_handler (<dir>/discord-bot/commands/play.js:28:5)
@sulsalloom
I tried your code on my local machine, and it didn't work for me. I tried changing stuff but nothing worked out. Any single tracks would work. But no playlist would work. From debug logs, I found out that the searchResults are being fetched as expected but player.play doesn't seem to work. I also checked player debug event and every standard extractors were being loaded as expected.
Don't know what is going wrong over here. My best guess is the way your bot is structured. My bot uses cjs while yours use esm. I will try to dig around more in free time.
Error Stack
Error: Play request received but track was not provided at GuildQueuePlayerNode.play (<dir>/discord-bot/node_modules/discord-player/dist/index.mjs:863:13) at GuildQueuePlayerNode.play (<dir>/discord-bot/node_modules/discord-player/dist/index.mjs:888:16) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async _Player.play (<dir>/discord-bot/node_modules/discord-player/dist/index.mjs:2581:7) at async play_handler (<dir>/discord-bot/commands/play.js:28:5)
changed my code to cjs and now it works thats weird
changed my code to cjs and now it works thats weird
Yea, that should not be a thing.
Describe the bug Discord-player will happily play tracks/ singles, bhowever when there are multiple tracks being returned as a searchResult, it errors out.
To Reproduce Steps to reproduce the behavior: play any of these links;
Expected behavior to play the playlist and add it to queue if there are multiple tracks
Screenshots
Please complete the following information: