Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

224
Views
discord.js bot playing audio without sound

I am using discord.js v13 and attempting to play audio files using @discordjs/voice. My problem is that the bot will do everything correctly, but when the green circle that indicates that a sound is coming from the bot appears, I don't hear anything. I don't think this is an audio issue with my headphones because I can hear everything else fine, including other people on discord.

Here is my code:

const { getVoiceConnection, joinVoiceChannel, AudioPlayerStatus, createAudioResource, getNextResource, createAudioPlayer, NoSubscriberBehavior } = require('@discordjs/voice');

module.exports = {
    name: "play",
    category: "music",
    description: "plays audio",
    usage: "<id | mention>",
    run: async (client, message, args) => {
        
        const voiceChannel =  message.member.voice.channel;
        
        const connection = joinVoiceChannel({
            channelId: voiceChannel.id,
            guildId: message.guild.id,
            adapterCreator: message.guild.voiceAdapterCreator
        });
        
        const audioPlayer = createAudioPlayer();
        connection.subscribe(audioPlayer);
        audioPlayer.play(createAudioResource('./sound/audio.mp3'));
    }
}

Any help is appreciated.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Simply writing createAudioResource('./sound/audio.mp3') isn't the correct syntax to get the audio resource of the mp3 file you have, the only thing you miss is the createReadStream() which will create a readable stream before transforming it into an audio resource. In clear, just change

  audioPlayer.play(createAudioResource('./sound/audio.mp3'));

to

  audioPlayer.play(createAudioResource(createReadStream('./sound/audio.mp3')));

If this still doesn't solve your answer maybe try adding options like the inlineVolume option as the second parameter:

  audioPlayer.play(createAudioResource(createReadStream('./sound/audio.mp3')),
    { inlineVolume: true });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!