Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

217
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda