Bot joins the vc but audio doesn't play

yes the path is correct.
var { voice } = message.member
if(!voice.channelId) return message.reply({content:`This command requires you to join a vc in this server. [Get help](<https://discord.gg/steamhappy>)`})

const connection = joinVoiceChannel({
channelId: voice.channel.id,
guildId: voice.channel.guild.id,
adapterCreator: voice.channel.guild.voiceAdapterCreator,
});

if(!connection) return message.reply({content:`Couldn't connect to the voice channel. [Get help](<https://discord.gg/steamhappy>)`})

message.reply({content:`Successfully joined ${voice.channel}`})

const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause,
},
});

const resource = createAudioResource(path.join(__dirname + 'sounds/meow.mp3'));
player.play(resource);

connection.subscribe(player)
var { voice } = message.member
if(!voice.channelId) return message.reply({content:`This command requires you to join a vc in this server. [Get help](<https://discord.gg/steamhappy>)`})

const connection = joinVoiceChannel({
channelId: voice.channel.id,
guildId: voice.channel.guild.id,
adapterCreator: voice.channel.guild.voiceAdapterCreator,
});

if(!connection) return message.reply({content:`Couldn't connect to the voice channel. [Get help](<https://discord.gg/steamhappy>)`})

message.reply({content:`Successfully joined ${voice.channel}`})

const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause,
},
});

const resource = createAudioResource(path.join(__dirname + 'sounds/meow.mp3'));
player.play(resource);

connection.subscribe(player)
6 Replies
d.js toolkit
d.js toolkit5w 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
jimi
jimi5w ago
discord.js@14.14.1 node v21.6.0
"dependencies": {
"@discordjs/voice": "^0.16.1",
"discord.js": "^14.14.1",
"ffmpeg-static": "^5.2.0",
"libsodium-wrappers": "^0.7.13",
"opusscript": "^0.0.8"
}
"dependencies": {
"@discordjs/voice": "^0.16.1",
"discord.js": "^14.14.1",
"ffmpeg-static": "^5.2.0",
"libsodium-wrappers": "^0.7.13",
"opusscript": "^0.0.8"
}
NyR
NyR5w ago
Subscribe to the player first then play (I'm not 100% sure if that's the issue, but try)
jimi
jimi5w ago
nothing changed
d.js docs
d.js docs5w 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
duck5w ago
Please also log your file path to ensure it's correct If your player is autopaused because your connection never enters the ready state, please ensure you have the GuildVoiceStates intent