Skip to content

Commit

Permalink
added remove duplicates command and missing command registers
Browse files Browse the repository at this point in the history
  • Loading branch information
Moquent authored Oct 19, 2022
2 parents ccac544 + 219dbfe commit e081353
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
24 changes: 24 additions & 0 deletions src/commands/music/duplicates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { canModifyQueue } = require("../../util/queueModify");
const embedMessage = require("../../util/embedContent");

module.exports = {
name: "removeduplicates",
async execute(message) {
try {
if (!(await canModifyQueue(message))) return;
const player = message.client.manager.queue.get(message.guild.id);

let count = 0, a = [];;
for (let i = 0; i < player.queue.length; i++) {
if (a.includes(player.queue[i]?.info.uri)) {
player.queue.splice(i--, 1);
count++;
}
}

return message.reply({ embeds: [embedMessage(`${message.member.user} Removed **${count}** duplicate tracks from the queue`)] });
} catch (err) {
return message.reply({ embeds: [embedMessage("There was an error clearing the duplicates, please try again.")] });
}
},
};
7 changes: 6 additions & 1 deletion src/util/updateSlash.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = async (client) => {
{ name: "stop", description: "Disconnect the bot from the voice channel", type: ApplicationCommandType.ChatInput },
{ name: "help", description: "Show all the commands of the bot to use", type: ApplicationCommandType.ChatInput },
{ name: "removedefaultchannel", description: "Remove the default text channel configuration to respond everywhere", type: ApplicationCommandType.ChatInput },
{ name: "removeduplicates", description: "Remove all duplicate tracks from the queue", type: ApplicationCommandType.ChatInput },
{
name: "setdefaultchannel", description: "Configure a default text channel to respond in", type: ApplicationCommandType.ChatInput,
options: [
Expand Down Expand Up @@ -73,5 +74,9 @@ module.exports = async (client) => {
{ name: "track", value: "track", },
{ name: "queue", value: "queue" }]
}]
}, {
name: "lyrics", description: "Get the lyrics of a track", type: ApplicationCommandType.ChatInput,
options: [
{ name: "name", type: ApplicationCommandOptionType.String, description: "Name of the song to fetch lyrics" }]
}])
}
}

0 comments on commit e081353

Please sign in to comment.