Skip to content
This repository was archived by the owner on Feb 12, 2026. It is now read-only.

Commit e90fccb

Browse files
author
Catalin Ta
committed
✨ added: vote to skip feature
1 parent c042de7 commit e90fccb

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

commands/player/skip.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const { SlashCommandBuilder } = require('discord.js');
33

44
const { Player } = require('discord-player');
55

6+
const skipVotes = new Map();
7+
68
module.exports = class Skip extends Command {
79
constructor(client) {
810
super(client, {
@@ -15,6 +17,7 @@ module.exports = class Skip extends Command {
1517
permissions: ['Use Application Commands', 'Send Messages', 'Embed Links'],
1618
});
1719
}
20+
1821
async run(client, interaction) {
1922
const player = Player.singleton();
2023
const queue = player.nodes.get(interaction.guild.id);
@@ -23,7 +26,20 @@ module.exports = class Skip extends Command {
2326
return await interaction.reply('<:red_emoji:1126936340022435963> There isn\'t currently any music playing.');
2427
}
2528

26-
queue.node.skip();
27-
return await interaction.reply(`<:green_emoji:1126936345043030026> The track **${queue.currentTrack.title}** was skipped.`);
29+
const usersInChannel = interaction.member.voice.channel.members.size;
30+
if (!skipVotes[interaction.guild.id]) {
31+
skipVotes[interaction.guild.id] = new Set();
32+
}
33+
const skipVotesTotal = skipVotes[interaction.guild.id];
34+
skipVotesTotal.add(interaction.user.id);
35+
36+
if (skipVotesTotal.size >= Math.ceil(usersInChannel * 0.35)) {
37+
queue.node.skip();
38+
skipVotes[interaction.guild.id] = new Set();
39+
return await interaction.reply(`<:green_emoji:1126936345043030026> The track **${queue.currentTrack.title}** was skipped.`);
40+
}
41+
else {
42+
return await interaction.reply(`You voted to skip. Required ${Math.ceil(usersInChannel * 0.35) - skipVotes.size - 1} more vote(s) needed to skip the track.`);
43+
}
2844
}
29-
};
45+
};

0 commit comments

Comments
 (0)