WIP: Add subcommands for queue

This commit is contained in:
Mylloon 2023-02-11 16:58:14 +01:00
parent e1e0399970
commit 71af333da4
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 95 additions and 18 deletions

View file

@ -13,32 +13,99 @@ export default {
return; return;
} }
// TODO: Add pages -> option return (
// : Add shuffle -> subcommand new SlashCommandBuilder()
// : Add remove <id> -> subcommand .setName(filename.toLowerCase())
return new SlashCommandBuilder() .setDescription(loc_default.get(`c_${filename}_desc`) ?? "")
.setName(filename.toLowerCase()) .setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true))
.setDescription(loc_default.get(`c_${filename}_desc`) ?? "") .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`))
.setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true))
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`)); // Show the queue
.addSubcommand((subcommand) =>
subcommand
.setName(loc_default.get(`c_${filename}_sub1_name`)?.toLowerCase() ?? "")
.setDescription(loc_default.get(`c_${filename}_sub1_desc`) ?? "")
.setNameLocalizations(getLocalizations(client, `c_${filename}_sub1_name`, true))
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub1_desc`))
// Specified Page
.addNumberOption((option) =>
option
.setName(loc_default.get(`c_${filename}_sub1_opt1_name`)?.toLowerCase() ?? "")
.setDescription(loc_default.get(`c_${filename}_sub1_opt1_desc`) ?? "")
.setNameLocalizations(
getLocalizations(client, `c_${filename}_sub1_opt1_name`, true)
)
.setDescriptionLocalizations(
getLocalizations(client, `c_${filename}_sub1_opt1_desc`)
)
)
)
// Shuffle Queue
.addSubcommand((subcommand) =>
subcommand
.setName(loc_default.get(`c_${filename}_sub2_name`)?.toLowerCase() ?? "")
.setDescription(loc_default.get(`c_${filename}_sub2_desc`) ?? "")
.setNameLocalizations(getLocalizations(client, `c_${filename}_sub2_name`, true))
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub2_desc`))
)
// Remove <ID>
.addSubcommand((subcommand) =>
subcommand
.setName(loc_default.get(`c_${filename}_sub3_name`)?.toLowerCase() ?? "")
.setDescription(loc_default.get(`c_${filename}_sub3_desc`) ?? "")
.setNameLocalizations(getLocalizations(client, `c_${filename}_sub3_name`, true))
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub3_desc`))
// Specified ID
// TODO?: ID range -> as a string: 5-8 remove 5, 6, 7, 8
.addNumberOption((option) =>
option
.setName(loc_default.get(`c_${filename}_sub3_opt1_name`)?.toLowerCase() ?? "")
.setDescription(loc_default.get(`c_${filename}_sub3_opt1_desc`) ?? "")
.setNameLocalizations(
getLocalizations(client, `c_${filename}_sub3_opt1_name`, true)
)
.setDescriptionLocalizations(
getLocalizations(client, `c_${filename}_sub3_opt1_desc`)
)
)
)
);
}, },
interaction: async (interaction: ChatInputCommandInteraction, client: Client) => { 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 loc = getLocale(client, interaction.locale);
const queue = client.player.queues.get(interaction.guildId ?? ""); const queue = client.player.queues.get(interaction.guildId ?? "");
const embed = new EmbedBuilder().setAuthor({ name: loc.get("c_queue1") }); const embed = new EmbedBuilder().setAuthor({ name: loc.get("c_queue1") });
if (queue) { if (queue) {
const tracks = queue.tracks; const subcommand = interaction.options.getSubcommand();
// TODO: Add pages for +25 tracks on a queue switch (subcommand) {
// Limit of discord is 25 // Show the queue
tracks.slice(0, 25).forEach((t, idx) => case loc_default?.get(`c_${filename}_sub1_name`)?.toLowerCase() ?? "": {
embed.addFields({ const tracks = queue.tracks;
name: "\u200b", // TODO: Add pages for +25 tracks on a queue
value: `${idx + 1}. [${t.title}](${t.url}) (${t.duration})`, // Limit of discord is 25
}) tracks.slice(0, 25).forEach((t, idx) =>
); embed.addFields({
name: "\u200b",
value: `${idx + 1}. [${t.title}](${t.url}) (${t.duration})`,
})
);
break;
}
default:
return await interaction.reply("Not yet implemented.");
}
} else { } else {
embed.setDescription(loc.get("c_queue2")); embed.setDescription(loc.get("c_queue2"));
} }

View file

@ -99,7 +99,17 @@
"c_pause2": "Met en pause la musique.", "c_pause2": "Met en pause la musique.",
"c_pause3": "Le bot ne joue rien en ce moment.", "c_pause3": "Le bot ne joue rien en ce moment.",
"c_queue_name": "queue", "c_queue_name": "queue",
"c_queue_desc": "Affiche la file d'attente des musiques", "c_queue_desc": "Commande relative à la file d'attente des musiques",
"c_queue_sub1_name": "affiche",
"c_queue_sub1_desc": "Affiche la file d'attente des musiques",
"c_queue_sub1_opt1_name": "page",
"c_queue_sub1_opt1_desc": "Page à afficher",
"c_queue_sub2_name": "melange",
"c_queue_sub2_desc": "Mélange la file d'attente",
"c_queue_sub3_name": "retire",
"c_queue_sub3_desc": "Retire une chanson de la file d'attente",
"c_queue_sub3_opt1_name": "id",
"c_queue_sub3_opt1_desc": "ID de la chanson a retirer",
"c_queue1": "File d'attente", "c_queue1": "File d'attente",
"c_queue2": "La liste est vide.", "c_queue2": "La liste est vide.",
"c_skip_name": "skip", "c_skip_name": "skip",