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/[email protected] +-- @discordjs/[email protected] +-- @discordjs/[email protected] +-- [email protected] +-- [email protected] +-- [email protected] +-- [email protected] -- [email protected] 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 toolkit9mo 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!
ThePedroo
ThePedroo9mo ago
And you should (almost) never use absolute path It will break when you switch folder
Want results from more Discord servers?
Add your server