AudioPlayer not working, not sure what's wrong

this._audioPlayer = createAudioPlayer();
const connection = joinVoiceChannel({
channelId: voiceState.channelId,
guildId: voiceState.guild.id,
adapterCreator: voiceState.guild.voiceAdapterCreator
});
connection.subscribe(this._audioPlayer);
this._audioPlayer.play(url);
try {
await entersState(this._audioPlayer, AudioPlayerStatus.Playing, 5_000);
// The player has entered the Playing state within 5 seconds
console.log('Playback has started!');
} catch (error) {
// The player has not entered the Playing state and either:
// 1) The 'error' event has been emitted and should be handled
// 2) 5 seconds have passed
console.error(error);
}
this._audioPlayer.on('stateChange', (oldState, newState) => {
console.log(`Audio player transitioned from ${oldState.status} to ${newState.status}`);
})
this._audioPlayer = createAudioPlayer();
const connection = joinVoiceChannel({
channelId: voiceState.channelId,
guildId: voiceState.guild.id,
adapterCreator: voiceState.guild.voiceAdapterCreator
});
connection.subscribe(this._audioPlayer);
this._audioPlayer.play(url);
try {
await entersState(this._audioPlayer, AudioPlayerStatus.Playing, 5_000);
// The player has entered the Playing state within 5 seconds
console.log('Playback has started!');
} catch (error) {
// The player has not entered the Playing state and either:
// 1) The 'error' event has been emitted and should be handled
// 2) 5 seconds have passed
console.error(error);
}
this._audioPlayer.on('stateChange', (oldState, newState) => {
console.log(`Audio player transitioned from ${oldState.status} to ${newState.status}`);
})
The bot autopauses for no reason. Here are the logs:
Audio player transitioned from idle to buffering
Audio player transitioned from buffering to playing
Playback has started!
Audio player transitioned from playing to autopaused
Audio player transitioned from idle to buffering
Audio player transitioned from buffering to playing
Playback has started!
Audio player transitioned from playing to autopaused
├── @discordjs/[email protected]
├── @sapphire/[email protected]
├── @sapphire/[email protected]
├── @sapphire/[email protected]


v18.17.1
├── @discordjs/[email protected]
├── @sapphire/[email protected]
├── @sapphire/[email protected]
├── @sapphire/[email protected]


v18.17.1
7 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
ShompiFlen
ShompiFlen16mo ago
please run npm ls discord.js, and node -v commands separately you need some dependencies for playing audio too, ffmpeg, discordjs/opus, sodium and some other things that you can check in the guide
Disuqi
DisuqiOP16mo ago
You are right, I didn't have these packages installed, but I have now installed them and still same problem I have edited my comment above
ShompiFlen
ShompiFlen16mo ago
dont install ffmpeg through npm, you need to get the binaries from the internet and put them in your environment
d.js docs
d.js docs16mo ago
- npm: npm install ffmpeg-static - Install: Download | chocolatey | homebrew | your distributions package manager - Tutorial: YouTube - ffmpeg-binaries is deprecated, uninstall it with npm rm ffmpeg-binaries
ShompiFlen
ShompiFlen16mo ago
one of those choices (not ffmpeg binaries) once you resolve that make sure you have the GuildVoiceStates intent enabled in your bot you could actually try with the intent first and see if that resolves it. The other thing i notice is that you are not creating an audio resource from the url to be played with the audioplayer you are instead directly passing the url to the player which im not entirely sure if that works
Disuqi
DisuqiOP16mo ago
sorted thank you]
Want results from more Discord servers?
Add your server