Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

243
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda