feat: Music support #62
2 changed files with 95 additions and 18 deletions
|
@ -13,23 +13,83 @@ export default {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Add pages -> option
|
return (
|
||||||
// : Add shuffle -> subcommand
|
new SlashCommandBuilder()
|
||||||
// : Add remove <id> -> subcommand
|
|
||||||
return new SlashCommandBuilder()
|
|
||||||
.setName(filename.toLowerCase())
|
.setName(filename.toLowerCase())
|
||||||
.setDescription(loc_default.get(`c_${filename}_desc`) ?? "")
|
.setDescription(loc_default.get(`c_${filename}_desc`) ?? "")
|
||||||
.setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true))
|
.setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true))
|
||||||
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`));
|
.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 subcommand = interaction.options.getSubcommand();
|
||||||
|
switch (subcommand) {
|
||||||
|
// Show the queue
|
||||||
|
case loc_default?.get(`c_${filename}_sub1_name`)?.toLowerCase() ?? "": {
|
||||||
const tracks = queue.tracks;
|
const tracks = queue.tracks;
|
||||||
// TODO: Add pages for +25 tracks on a queue
|
// TODO: Add pages for +25 tracks on a queue
|
||||||
// Limit of discord is 25
|
// Limit of discord is 25
|
||||||
|
@ -39,6 +99,13 @@ export default {
|
||||||
value: `${idx + 1}. [${t.title}](${t.url}) (${t.duration})`,
|
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"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -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",
|
||||||
|
|
Loading…
Reference in a new issue