Bot joins but does nothing

code:
const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause,
},
});
joinVoiceChannel({
channelId: interaction.member.voice.channelId,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator,
}).subscribe(player);

const resource = createAudioResource(join('..', '..', 'assets', 'idgaf.mp3'));

player.play(resource);
const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause,
},
});
joinVoiceChannel({
channelId: interaction.member.voice.channelId,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator,
}).subscribe(player);

const resource = createAudioResource(join('..', '..', 'assets', 'idgaf.mp3'));

player.play(resource);
19 Replies
d.js toolkit
d.js toolkit13mo 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
Miga
MigaOP13mo ago
[email protected] node v18.11.0
d.js docs
d.js docs13mo 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
duck
duck13mo ago
if your connection doesn't enter the ready state please ensure you have the GuildVoiceStates intent
Miga
MigaOP13mo ago
it showing no errors
duck
duck13mo ago
that's great does the connection enter the ready state?
Miga
MigaOP13mo ago
player.on(AudioPlayerStatus.Playing, () => {
console.log('player is playing');
});
player.on(AudioPlayerStatus.Playing, () => {
console.log('player is playing');
});
console: player is playing player is playing so yes it is
duck
duck13mo ago
that just tells you that the player is playing please actually check if the connection enters the ready state
Miga
MigaOP13mo ago
im not really sure how.. can you please help me?
duck
duck13mo ago
well in your original code, you weren't storing the VoiceConnection that joinVoiceChannel returns, so you'd first need to do that then you can listen for the status on the connection in the same way you're doing with your player (except with the VoiceConnectionStatus enum instead)
d.js docs
d.js docs13mo ago
guide Library: Voice Connections - Life cycle read more
Miga
MigaOP13mo ago
joinVoiceChannel({
channelId: interaction.member.voice.channelId,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator,
}).subscribe(player).connection.on('stateChange', (oldState, newState) => {
console.log(`Connection`);
});
joinVoiceChannel({
channelId: interaction.member.voice.channelId,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator,
}).subscribe(player).connection.on('stateChange', (oldState, newState) => {
console.log(`Connection`);
});
like that? console: Connection Connection
duck
duck13mo ago
well if you intend to listen to state changes like that, it'd probably help to actually log the states
Miga
MigaOP13mo ago
the connection does enter to the ready state.
duck
duck13mo ago
then do you have the proper dependencies to play an mp3 file? could you generate a dependency report?
d.js docs
d.js docs13mo ago
guide Getting Started: Introduction - Debugging Dependencies read more
Miga
MigaOP13mo ago
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.16.1
- prism-media: 1.3.5

Opus Libraries
- @discordjs/opus: not found
- opusscript: not found

Encryption Libraries
- sodium-native: not found
- sodium: not found
- libsodium-wrappers: 0.7.13
- tweetnacl: not found

FFmpeg
- version: 6.0-essentials_build-www.gyan.dev
- libopus: yes
--------------------------------------------------
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.16.1
- prism-media: 1.3.5

Opus Libraries
- @discordjs/opus: not found
- opusscript: not found

Encryption Libraries
- sodium-native: not found
- sodium: not found
- libsodium-wrappers: 0.7.13
- tweetnacl: not found

FFmpeg
- version: 6.0-essentials_build-www.gyan.dev
- libopus: yes
--------------------------------------------------
duck
duck13mo ago
sounds like you're missing an opus library please install one
Miga
MigaOP13mo ago
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.16.1
- prism-media: 1.3.5

Opus Libraries
- @discordjs/opus: 0.9.0
- opusscript: 0.0.8

Encryption Libraries
- sodium-native: not found
- sodium: not found
- libsodium-wrappers: 0.7.13
- tweetnacl: not found

FFmpeg
- version: 6.0-essentials_build-www.gyan.dev
- libopus: yes
--------------------------------------------------
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.16.1
- prism-media: 1.3.5

Opus Libraries
- @discordjs/opus: 0.9.0
- opusscript: 0.0.8

Encryption Libraries
- sodium-native: not found
- sodium: not found
- libsodium-wrappers: 0.7.13
- tweetnacl: not found

FFmpeg
- version: 6.0-essentials_build-www.gyan.dev
- libopus: yes
--------------------------------------------------
installed Oh its working! thank you ! @duck
Want results from more Discord servers?
Add your server