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

99
Views
Discord.js voteskip system music bot

I am making a voteskip system for my music bot and there are 2 problems with it.

Problems

  • The same person can vote again

  • Even when the amount of required votes are reached the song wont skip Here is the code

    else if (cmd === "skip") {
      let queue = distube.getQueue(message.guild.id);
      let channel = message.member.voice.channel;
      if (!channel) {
       return message.channel.send( "You need to Join Voice Channel" )
     }
      if (!queue) {
       return message.channel.send( "Nothing Playing" )
     }
    
     if (queue.songs.length < 1){
       return message.channel.send("There are no more tracks left. Add some")
     }
    
    
       channel = message.member.voice.channel
       if (!channel){
         message.channel.send("You must be in a voice channel to skip this song")
       }
       var required = Math.ceil(message.member.voice.channel.size/2)
       if (voteskips.includes(message.member.id)){
         message.channel.send("You already voted for skipping this song")
       }
       voteskips.push(message.member.id)
       message.channel.send(`**Votes : ${voteskips.length}/${channel.members.size}**  ${required - voteskips.length} more votes needed to skip`)
    
       if (voteskips.length >= required){
    
         if (queue.autoplay || queue.songs.length > 1) distube.skip(message)
         else distube.stop(message)
         message.channel.send({embeds:[
           new Discord.MessageEmbed()
           .setTitle("Skipped current track")
           .setColor("LIGHT_GREY")
         ]})
    
    
       }
    
    
     }
    
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I made a careless mistake. Firstly the required variable is supposed to be

     var required = Math.ceil(message.member.voice.channel.members.size/2);

The next one is that i am supposed to push the authors id into the array. Not simply message.member.id . Here is the updated code.

       else if (cmd === "skip") {
  let queue = distube.getQueue(message.guild.id);
  let channel = message.member.voice.channel;
  let members = Math.ceil(message.member.voice.channel.members.size/2)
  if (!channel) {
    return message.channel.send( "You need to Join Voice Channel" )
  }
  if (!queue) {
    return message.channel.send( "Nothing Playing" )
  }
  
  if (queue.songs.length < 1){
    return message.channel.send("There are no more tracks left. Add some")
  }
  
 
 if (voteskips.find(id=>id == message.author.id)){
   message.channel.send("You have already voted")
 }else {
   voteskips.push(message.author.id)
   message.channel.send(`Votes ${voteskips.length}/${members}. ${members - voteskips.length} more votes to skip.`)
 }
 if (voteskips.length === members){
   if (queue.autoplay || queue.songs.length > 1){
     distube.skip(message)
   }else distube.stop(message)
 }



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