feat: Music support #62
2 changed files with 51 additions and 1 deletions
46
src/commands/music/queue.ts
Normal file
46
src/commands/music/queue.ts
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
import { SlashCommandBuilder } from "@discordjs/builders";
|
||||||
|
import { ChatInputCommandInteraction, Client, EmbedBuilder } from "discord.js";
|
||||||
|
import { getLocale, getLocalizations } from "../../utils/locales";
|
||||||
|
import { getFilename } from "../../utils/misc";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
scope: () => [],
|
||||||
|
|
||||||
|
data: (client: Client) => {
|
||||||
|
const filename = getFilename(__filename);
|
||||||
|
const loc_default = client.locales.get(client.config.default_lang);
|
||||||
|
if (!loc_default) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Add pages
|
||||||
|
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`));
|
||||||
|
},
|
||||||
|
|
||||||
|
interaction: async (interaction: ChatInputCommandInteraction, client: Client) => {
|
||||||
|
const loc = getLocale(client, interaction.locale);
|
||||||
|
const queue = client.player.queues.get(interaction.guildId ?? "");
|
||||||
|
|
||||||
|
const embed = new EmbedBuilder().setAuthor({ name: loc.get("c_queue1") });
|
||||||
|
|
||||||
|
if (queue) {
|
||||||
|
const tracks = queue.tracks;
|
||||||
|
// TODO: Add pages for +25 tracks on a queue
|
||||||
|
// 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})`,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
embed.setDescription(loc.get("c_queue2"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return await interaction.reply({ embeds: [embed] });
|
||||||
|
},
|
||||||
|
};
|
|
@ -97,5 +97,9 @@
|
||||||
"c_pause_desc": "Met en pause ou relance la musique",
|
"c_pause_desc": "Met en pause ou relance la musique",
|
||||||
"c_pause1": "Relance la musique...",
|
"c_pause1": "Relance la musique...",
|
||||||
"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_desc": "Affiche la file d'attente des musiques",
|
||||||
|
"c_queue1": "File d'attente",
|
||||||
|
"c_queue2": "La liste est vide."
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue