ytdl audioplayererror
Hi,
im trying to update my application so my bot connect to a voice channel, and put a sound on it.
I have this code :
// Function to start the music
async lancerMusique(message, numéroJeu) {
const vc = message.guild.channels.cache.find(
(channel) => channel.id === voiceChannel
);
const maZic = trouverMusiqueSelonJeu(numéroJeu);
if (!vc) {
return message.reply(
}
if (!maZic) {
return message.reply("La musique sélectionnée n'existe pas.");
}
try {
// Join the voice channel
const connection = joinVoiceChannel({
channelId: vc.id,
guildId: message.guild.id,
adapterCreator: message.guild.voiceAdapterCreator,
});
// Stream the audio from YouTube URL with better configuration for ytdl-core
const stream = ytdl(maZic, {
filter: 'audioonly',
quality: 'highestaudio',
highWaterMark: 1 << 25 // Increase buffer size for smoother playback
});
// Create audio resource from the stream
const resource = createAudioResource(stream);
// Create the audio player
const player = createAudioPlayer();
// Play the audio
player.play(resource);
// Subscribe to the connection
connection.subscribe(player);
// Respond to the user
message.reply(
// When the music stops, disconnect from the channel
player.on(AudioPlayerStatus.Idle, () => {
connection.destroy();
console.log("Déconnecté du channel vocal après la musique.");
});
} catch (error) {
console.error("Erreur lors de la lecture de la musique:", error);
message.reply("Il y a eu une erreur lors de la tentative de lecture de la musique.");
}
},
I have the last version for ytdl. However, i have this error that i don't know how to fix :
AudioPlayerError: Could not extract functions
Emitted 'error' event on AudioPlayer instance at:
Is someone knows how can i fix it ?
Thanks.
im trying to update my application so my bot connect to a voice channel, and put a sound on it.
I have this code :
// Function to start the music
async lancerMusique(message, numéroJeu) {
const vc = message.guild.channels.cache.find(
(channel) => channel.id === voiceChannel
);
const maZic = trouverMusiqueSelonJeu(numéroJeu);
if (!vc) {
return message.reply(
L'id du channel vocal : "${voiceChannel}" n'existe pas.);}
if (!maZic) {
return message.reply("La musique sélectionnée n'existe pas.");
}
try {
// Join the voice channel
const connection = joinVoiceChannel({
channelId: vc.id,
guildId: message.guild.id,
adapterCreator: message.guild.voiceAdapterCreator,
});
// Stream the audio from YouTube URL with better configuration for ytdl-core
const stream = ytdl(maZic, {
filter: 'audioonly',
quality: 'highestaudio',
highWaterMark: 1 << 25 // Increase buffer size for smoother playback
});
// Create audio resource from the stream
const resource = createAudioResource(stream);
// Create the audio player
const player = createAudioPlayer();
// Play the audio
player.play(resource);
// Subscribe to the connection
connection.subscribe(player);
// Respond to the user
message.reply(
La musique ${maZic} est jouée dans le vocal ! C'est la musique du __jeu ${numéroJeu}__.);// When the music stops, disconnect from the channel
player.on(AudioPlayerStatus.Idle, () => {
connection.destroy();
console.log("Déconnecté du channel vocal après la musique.");
});
} catch (error) {
console.error("Erreur lors de la lecture de la musique:", error);
message.reply("Il y a eu une erreur lors de la tentative de lecture de la musique.");
}
},
I have the last version for ytdl. However, i have this error that i don't know how to fix :
AudioPlayerError: Could not extract functions
Emitted 'error' event on AudioPlayer instance at:
Is someone knows how can i fix it ?
Thanks.
