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

120
Views
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
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!