I am working on a Discord music bot powered by discord-player v6.6.10 and discord.js v14.15.3.
Current behavior
Currently, when the user executes the /play command, the bot properly searches for the given URL, grabs the video, joins the channel, and then returns an interaction that the song has been added to the queue. But after that, it does not start the playback and instead immediately disconnects from the channel.
Steps to reproduce the behavior: (using current "up-to-date" usage for player.play on the documentation)
join voice channel
execute /play url command
see errors (if any)
Expected behavior
Bot joins channel and begins streaming the given query.
module.exports = {
data: new SlashCommandBuilder()
.setName('play')
.setDescription('Plays a song from YouTube')
.addStringOption(option =>
option.setName('url')
.setDescription('The URL or name of the song')
.setRequired(true)
),
async execute(interaction) {
const player = useMainPlayer();
const channel = interaction.member.voice.channel;
if (!channel) {
return interaction.reply({
content: 'You need to be in a voice channel to play music!',
ephemeral: true
});
}
const query = interaction.options.getString('url', true);
await interaction.deferReply();
try {
const { track } = await player.play(channel, query, {
nodeOptions: {
metadata: interaction
}
});
return interaction.followUp(`**${track.cleanTitle}** enqueued!`);
} catch (e) {
console.error('Error:', e);
return interaction.followUp(`Something went wrong: ${e.message || e}`);
}
}
I am working on a Discord music bot powered by discord-player v6.6.10 and discord.js v14.15.3.
Current behavior Currently, when the user executes the /play command, the bot properly searches for the given URL, grabs the video, joins the channel, and then returns an interaction that the song has been added to the queue. But after that, it does not start the playback and instead immediately disconnects from the channel.
Steps to reproduce the behavior: (using current "up-to-date" usage for player.play on the documentation)
Expected behavior Bot joins channel and begins streaming the given query.
Screenshots![Screenshot 2024-06-16 013909](https://github.com/Androz2091/discord-player/assets/139281974/74c526e0-4db7-4d1e-8109-03ef5c5561e9)
Please complete the following information:
Discord.js Version: v14.15.3
Current play.js
module.exports = { data: new SlashCommandBuilder() .setName('play') .setDescription('Plays a song from YouTube') .addStringOption(option => option.setName('url') .setDescription('The URL or name of the song') .setRequired(true) ), async execute(interaction) { const player = useMainPlayer(); const channel = interaction.member.voice.channel;
};