Bot joining voice channel but not playing audio

Hi everyone. I am making a soundboard and while the bot is successfully joining the voice channel the audio file is not playing. Here are my versions +-- @discordjs/builders@1.7.0 +-- @discordjs/rest@2.2.0 +-- @discordjs/voice@0.16.1 +-- discord-api-types@0.37.75 +-- discord.js@14.14.1 +-- ffmpeg-static@5.2.0 +-- libsodium-wrappers@0.7.13 -- opusscript@0.0.8 Here is where I cam creating my client ```javascript const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildVoiceStates ] }); ``` And here is where I am trying to play an audio file. ```javascript /// file - '/audio/audioFile.mp3' const play = (file, voiceChannelId, guild) => { let voiceConnection = joinVoiceChannel({ channelId: voiceChannelId, guildId: guild.id, adapterCreator: guild.voiceAdapterCreator, selfDeaf: false }); const stream = createReadStream(file); const resource = createAudioResource(stream); let audioPlayer = createAudioPlayer({ behaviors: { noSubscriber: NoSubscriberBehavior.Stop } }); audioPlayer.play(resource); voiceConnection.subscribe(audioPlayer); audioPlayer.on(AudioPlayerStatus.Idle, () => { console.log('end'); //voiceConnection.destroy(); }); audioPlayer.on(AudioPlayerStatus.Playing, () => console.log('playing')) audioPlayer.on('error', err => console.log(err)); }; ``` I am not getting any error messages and both the 'playing' and 'end' logs are printed to the console. This is code I have from a file called client.js` the structure in which it is related to the audio file is the following:
client.js
/audio
audioFile.mp3
client.js
/audio
audioFile.mp3
3 Replies
d.js toolkit
d.js toolkit3mo 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!
TseShanties
TseShanties3mo ago
+-- @discordjs/builders@1.7.0 +-- @discordjs/rest@2.2.0 +-- @discordjs/voice@0.16.1 +-- discord-api-types@0.37.75 +-- discord.js@14.14.1 +-- ffmpeg-static@5.2.0 +-- libsodium-wrappers@0.7.13 `-- opusscript@0.0.8 Node v20.11.1
ThePedroo
ThePedroo3mo ago
And you should (almost) never use absolute path It will break when you switch folder