add skipto command

This commit is contained in:
Mylloon 2023-02-10 18:32:24 +01:00
parent fdf5f488ad
commit 3a871a3350
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 36 additions and 10 deletions

View file

@ -13,21 +13,44 @@ export default {
return;
}
return new SlashCommandBuilder()
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`));
.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"));

View file

@ -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"
}