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

236
Vistas
Discord.js V13 Player is not defined

I'm building a discord.js v13.6.0 music bot and everything is working except this code

const { QueryType } = require('discord-player');
module.exports = {
    name: 'play',
    aliases: ['p'],
    utilisation: '{prefix}play [song name/URL]',
    voiceChannel: true,

    async execute(client, message, args) {
        if (!args[0]) return message.channel.send(`${message.author}, Write the name of the music you want to search. ❌`);

        const res = await client.player.search(args.join(' '), {
            requestedBy: message.member,
            searchEngine: QueryType.AUTO
        });

        if (!res || !res.tracks.length) return message.channel.send(`${message.author}, No results found! ❌`);

        const queue = await client.player.createQueue(message.guild, {
            metadata: message.channel
        });

        try {
            if (!queue.connection) await queue.connect(message.member.voice.channel);
        } catch {
            await client.player.deleteQueue(message.guild.id);
            return message.channel.send(`${message.author}, I can't join audio channel. ❌`);
        }

        await message.channel.send(`Your ${res.playlist ? 'Your Playlist' : 'Your Track'} Loading... 🎧`);

        res.playlist ? queue.addTracks(res.tracks) : queue.addTrack(res.tracks[0]);

        if (!queue.playing) await queue.play();
    },
};

When I use this command, the following error occurs:

Unhandled promise rejection: ReferenceError: player is not defined

I'm new to programming, sorry for any silly mistakes, if you need any info don't hesitate to ask

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The possibility of such errors appears either by throwing inside of a async function without a catch block or rejecting a promise which didn't had a .catch()

You might be doing:

  1. you put your code inside an async function in order to use await calls.
  2. The awaited function fails.

The solutions are:

  1. Either use .catch()

    await returnsPromise().catch(e => { console.log(e) })

or

2.Use try/ catch block


try {
  await returnsPromise()
} catch (error) {
  console.log('That did not go well.')
}
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