From 18638e10870894750acaddd3ffb3525cb21c9e0f Mon Sep 17 00:00:00 2001 From: Mylloon Date: Fri, 17 Feb 2023 22:55:26 +0100 Subject: [PATCH] * add embed in commands * add progress bar in nowplaying command --- src/commands/music/pause.ts | 14 +++++++------- src/commands/music/play.ts | 31 ++++++++++++++++++------------- src/locales/fr.json | 1 + 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/commands/music/pause.ts b/src/commands/music/pause.ts index 5c286a0..e7733a7 100644 --- a/src/commands/music/pause.ts +++ b/src/commands/music/pause.ts @@ -1,5 +1,5 @@ import { SlashCommandBuilder } from "@discordjs/builders"; -import { ChatInputCommandInteraction, Client } from "discord.js"; +import { ChatInputCommandInteraction, Client, EmbedBuilder } from "discord.js"; import { getLocale, getLocalizations } from "../../utils/locales"; import { getFilename } from "../../utils/misc"; @@ -25,20 +25,20 @@ export default { const queue = client.player.queues.get(interaction.guildId ?? ""); if (queue) { + const embed = new EmbedBuilder(); if (queue.paused) { queue.resume(); - // TODO: Pretty embed - return await interaction.reply(loc.get("c_pause1")); + embed.setDescription(loc.get("c_pause1")); + return await interaction.reply({ embeds: [embed] }); } else { queue.pause(); - // TODO: Pretty embed - return await interaction.reply(loc.get("c_pause2")); + embed.setDescription(loc.get("c_pause2")); + return await interaction.reply({ embeds: [embed] }); } } - // TODO: Pretty embed - return await interaction.reply(loc.get("c_pause3")); + return await interaction.reply(`❌ | ${loc.get("c_pause3")}`); }, }; diff --git a/src/commands/music/play.ts b/src/commands/music/play.ts index f1c17fa..5499761 100644 --- a/src/commands/music/play.ts +++ b/src/commands/music/play.ts @@ -2,6 +2,7 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction, Client, + EmbedBuilder, GuildResolvable, VoiceBasedChannel, } from "discord.js"; @@ -48,7 +49,7 @@ export default { if (!member?.voice.channelId) { return await interaction.reply({ - content: loc.get("c_play1"), + content: `❌ | ${loc.get("c_play1")}`, ephemeral: true, }); } @@ -58,7 +59,7 @@ export default { member.voice.channelId !== interaction.guild.members.me.voice.channelId ) { return await interaction.reply({ - content: loc.get("c_play2"), + content: `❌ | ${loc.get("c_play2")} ${interaction.guild.members.me.voice.channel}`, ephemeral: true, }); } @@ -75,16 +76,21 @@ export default { if (queue) { const track = queue.nowPlaying(); if (track) { - // TODO: Pretty embed - // Use: createProgressBar - return await interaction.reply( - `${loc.get("c_play7")} \`${track.title}\` - *${track.author}*` - ); + const embed = new EmbedBuilder() + .setDescription( + `${queue.createProgressBar()}\n\n${loc.get("c_play8")} ${track.requestedBy}` + ) + .setTitle(track.title) + .setURL(track.url) + .setThumbnail(track.thumbnail) + .setFooter({ text: loc.get("c_play7") }) + .setTimestamp(); + return await interaction.reply({ embeds: [embed] }); } } - // TODO: Pretty embed - return await interaction.reply(loc.get("c_play6")); + const embed = new EmbedBuilder().setDescription(`❌ | ${loc.get("c_play6")}`); + return await interaction.reply({ embeds: [embed] }); } const queue = client.player.createQueue(interaction.guild as GuildResolvable, { @@ -99,7 +105,7 @@ export default { } catch { queue.destroy(); return await interaction.reply({ - content: loc.get("c_play3"), + content: `❌ | ${loc.get("c_play3")}`, ephemeral: true, }); } @@ -112,8 +118,8 @@ export default { .then((x) => x); if (!result.tracks[0]) { - // TODO: Pretty embed - return await interaction.followUp({ content: `❌ | \`${query}\` ${loc.get("c_play4")}.` }); + const embed = new EmbedBuilder().setDescription(`❌ | \`${query}\` ${loc.get("c_play4")}.`); + return await interaction.followUp({ embeds: [embed] }); } let title; @@ -132,7 +138,6 @@ export default { queue.play(); } - // TODO: Pretty embed return await interaction.followUp({ content: `⏱️ | \`${title}\` ${loc.get("c_play5")}.`, }); diff --git a/src/locales/fr.json b/src/locales/fr.json index 8e580dc..3ca6516 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -88,6 +88,7 @@ "c_play5": "ajouté à la file d'attente", "c_play6": "Le bot ne joue rien en ce moment.", "c_play7": "Joue actuellement", + "c_play8": "Demandé par", "c_stop_name": "stop", "c_stop_desc": "Stop la musique",