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

118
Visualizações
Discord Music Bot jumping function

I am designing a jump function for my music bot. When queue.connection.dispatcher.end('skipped') is called once only, it skips a song but when I put it into a loop, it returns an error about UnhandledPromiseRejectionWarning. Can anyone help?

Below is the code for the jump command:

const { MessageEmbed } = require('discord.js');

module.exports = {
    name: 'jump',
    aliases: [''],
    cooldown: 0,
    description: '',
    async execute(client, message, args, Discord) {
        const channel = message.member.voice.channel;
        if (!channel)
            return message.channel.send("You must be connected to a voice channel"
            );
            
                if (!args[0])
                return message.channel.send(
                  new MessageEmbed()
                    .setDescription(":x: No song number provided")
                    .setColor("RED")
                );
                if (isNaN(args[0]))
                return message.channel.send(
                  new MessageEmbed()
                    .setDescription(":x: **Args must be number [Example: -remove 2]**")
                    .setColor("RED")
                );
              
                let queue = message.client.queue.get(message.guild.id);
              if (queue.queue.length == 1)
                return message.channel.send(
                  new MessageEmbed()
                    .setDescription(
                      ":x: **Can't remove when only one song is playing, Use command stop**"
                    )
                    .setColor("RED")
                );
              if (args[0] > queue.queue.length)
                return message.channel.send(
                  new MessageEmbed()
                    .setDescription(":x: **The queue doesn't have that much songs**")
                    .setColor("RED")
                );
              if (!queue)
                return message.channel.send(
                  new MessageEmbed()
                    .setDescription(":x: **There are no songs playing in this server**")
                    .setColor("RED")
                );
            //   var name = queue.queue[args[0] - 1].name;
            //   queue.queue.splice(args[0] - 1);
             for (let i = 0; i < args[0]-1; i++) {
                queue.connection.dispatcher.end('skipped');
            }
            return message.channel.send(new MessageEmbed().setDescription("**Jumped**").setColor("PURPLE"))
    }}

This is the error i got

about 4 years ago · Juan Pablo Isaza
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