audio player doesn't seem to function

const audioPlayer = createAudioPlayer();
const audioResource = createAudioResource(
"../resources/soundboard/alert.mp3"
);
audioPlayer.on("error", (error) => {
console.log(
"Error:",
error.message,
"with track",
error.resource.metadata.title
);
});

const connection = getVoiceConnection(message.guild.id);
connection.subscribe(audioPlayer);
audioPlayer.play(audioResource);
const audioPlayer = createAudioPlayer();
const audioResource = createAudioResource(
"../resources/soundboard/alert.mp3"
);
audioPlayer.on("error", (error) => {
console.log(
"Error:",
error.message,
"with track",
error.resource.metadata.title
);
});

const connection = getVoiceConnection(message.guild.id);
connection.subscribe(audioPlayer);
audioPlayer.play(audioResource);
for whatever reason it just doesn't play the audio node version 19.0.0 djs version 14.13.0
3 Replies
d.js toolkit
d.js toolkit16mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
duck
duck16mo ago
in future, please use #djs-voice for /voice related questions/issues that being said, are you sure your relative path for your audio resource is correct? (the file path would be resolved through fs which uses the current working directory as a base for relative paths) have you considered using an absolute path instead? do you have the proper peer dependencies?
d.js docs
d.js docs16mo ago
To debug your voice connection and player: - Use debug: true when creating your VoiceConnection and AudioPlayer - Add an event listener to the <VoiceConnection> and the <AudioPlayer>:
// Add one for each class if applicable
<AudioPlayer | VoiceConnection>
.on('debug', console.log)
.on('error', console.error)
// Add one for each class if applicable
<AudioPlayer | VoiceConnection>
.on('debug', console.log)
.on('error', console.error)
- Add an error listener to the stream you are passing to the resource:
<Stream>.on('error', console.error)
<Stream>.on('error', console.error)
Note: The <> represents classes that need to be adapted to their respective name in your code
Want results from more Discord servers?
Add your server