From 3a871a33507c1d99af9f0934015461241edc3c4a Mon Sep 17 00:00:00 2001 From: Mylloon Date: Fri, 10 Feb 2023 18:32:24 +0100 Subject: [PATCH] add skipto command --- src/commands/music/skip.ts | 39 ++++++++++++++++++++++++++++++-------- src/locales/fr.json | 7 +++++-- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/commands/music/skip.ts b/src/commands/music/skip.ts index 9b36e31..66838a6 100644 --- a/src/commands/music/skip.ts +++ b/src/commands/music/skip.ts @@ -13,21 +13,44 @@ export default { return; } - return new SlashCommandBuilder() - .setName(filename.toLowerCase()) - .setDescription(loc_default.get(`c_${filename}_desc`) ?? "") - .setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true)) - .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`)); + return ( + new SlashCommandBuilder() + .setName(filename.toLowerCase()) + .setDescription(loc_default.get(`c_${filename}_desc`) ?? "") + .setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true)) + .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`)) + + // Command option + .addNumberOption((option) => + option + .setName(loc_default.get(`c_${filename}_opt1_name`)?.toLowerCase() ?? "") + .setDescription(loc_default.get(`c_${filename}_opt1_desc`) ?? "") + .setNameLocalizations(getLocalizations(client, `c_${filename}_opt1_name`, true)) + .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_opt1_desc`)) + ) + ); }, interaction: async (interaction: ChatInputCommandInteraction, client: Client) => { + const loc_default = client.locales.get(client.config.default_lang); + const filename = getFilename(__filename); + const loc = getLocale(client, interaction.locale); const queue = client.player.queues.get(interaction.guildId ?? ""); - if (queue) { - queue.skip(); + const id = interaction.options.getNumber(loc_default?.get(`c_${filename}_opt1_name`) as string); - return await interaction.reply(loc.get("c_skip1")); + if (queue) { + let msg; + if (id) { + queue.skipTo(id - 1); + msg = loc.get("c_skip3") + " #" + id + "..."; + } else { + queue.skip(); + msg = loc.get("c_skip1") + "..."; + } + + return await interaction.reply(msg); } return await interaction.reply(loc.get("c_skip2")); diff --git a/src/locales/fr.json b/src/locales/fr.json index 8539617..b41c429 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -104,6 +104,9 @@ "c_queue2": "La liste est vide.", "c_skip_name": "skip", "c_skip_desc": "Passe la chanson en cours", - "c_skip1": "Passe la chanson...", - "c_skip2": "Le bot ne joue rien en ce moment." + "c_skip_opt1_name": "id", + "c_skip_opt1_desc": "ID de la chanson que vous voulez écouter", + "c_skip1": "Passe la chanson", + "c_skip2": "Le bot ne joue rien en ce moment.", + "c_skip3": "Passe à la chanson" }