2022-08-03 20:57:54 +05:00
|
|
|
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js"),
|
2023-03-24 00:09:26 +05:00
|
|
|
{ QueueRepeatMode } = require("discord-player");
|
2022-08-02 17:18:47 +05:00
|
|
|
const BaseCommand = require("../../base/BaseCommand");
|
|
|
|
|
|
|
|
class Nowplaying extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
constructor(client) {
|
|
|
|
super({
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
.setName("nowplaying")
|
2022-10-13 00:05:36 +05:00
|
|
|
.setDescription(client.translate("music/nowplaying:DESCRIPTION"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
2023-07-05 00:58:06 +05:00
|
|
|
uk: client.translate("music/nowplaying:DESCRIPTION", null, "uk-UA"),
|
|
|
|
ru: client.translate("music/nowplaying:DESCRIPTION", null, "ru-RU"),
|
2023-06-15 19:46:27 +05:00
|
|
|
})
|
2022-10-13 00:05:36 +05:00
|
|
|
.setDMPermission(false),
|
2022-08-02 17:18:47 +05:00
|
|
|
aliases: [],
|
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: false,
|
2022-08-02 17:18:47 +05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
async onLoad() {
|
|
|
|
//...
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
2022-08-09 23:48:33 +05:00
|
|
|
* @param {Object} data
|
2022-08-02 17:18:47 +05:00
|
|
|
*/
|
2023-06-27 21:19:55 +05:00
|
|
|
async execute(client, interaction, data) {
|
2022-08-03 20:57:54 +05:00
|
|
|
await interaction.deferReply();
|
2022-09-13 22:19:51 +05:00
|
|
|
|
2023-03-24 00:09:26 +05:00
|
|
|
const queue = client.player.nodes.get(interaction.guildId);
|
2022-09-13 22:19:51 +05:00
|
|
|
if (!queue) return interaction.error("music/play:NOT_PLAYING", null, { edit: true });
|
2023-03-24 00:09:26 +05:00
|
|
|
const progressBar = queue.node.createProgressBar(),
|
|
|
|
track = queue.currentTrack;
|
2022-08-02 17:18:47 +05:00
|
|
|
|
|
|
|
const embed = new EmbedBuilder()
|
|
|
|
.setAuthor({
|
2022-12-15 21:02:38 +05:00
|
|
|
name: interaction.translate("music/nowplaying:CURRENTLY_PLAYING"),
|
2022-08-02 17:18:47 +05:00
|
|
|
})
|
2022-08-28 16:45:05 +05:00
|
|
|
.setThumbnail(track.thumbnail)
|
2022-08-02 17:18:47 +05:00
|
|
|
.addFields([
|
|
|
|
{
|
|
|
|
name: interaction.translate("music/nowplaying:T_TITLE"),
|
2022-09-10 23:38:11 +05:00
|
|
|
value: `[${track.title}](${track.url})`,
|
2022-12-15 21:02:38 +05:00
|
|
|
inline: true,
|
2022-08-02 17:18:47 +05:00
|
|
|
},
|
|
|
|
{
|
2022-08-03 20:57:54 +05:00
|
|
|
name: interaction.translate("music/nowplaying:T_AUTHOR"),
|
2022-09-10 23:38:11 +05:00
|
|
|
value: track.author || interaction.translate("common:UNKNOWN"),
|
2022-12-15 21:02:38 +05:00
|
|
|
inline: true,
|
2022-09-10 23:38:11 +05:00
|
|
|
},
|
|
|
|
{ name: "\u200B", value: "\u200B", inline: true },
|
|
|
|
{
|
|
|
|
name: interaction.translate("common:VIEWS"),
|
2023-06-27 21:19:55 +05:00
|
|
|
value: track.raw.live ? "" : new Intl.NumberFormat(interaction.client.languages.find(language => language.name === data.guldData.language).moment, { notation: "standard" }).format(track.raw.views),
|
2022-12-15 21:02:38 +05:00
|
|
|
inline: true,
|
2022-09-10 23:38:11 +05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: interaction.translate("music/queue:ADDED"),
|
|
|
|
value: track.requestedBy.toString(),
|
2022-12-15 21:02:38 +05:00
|
|
|
inline: true,
|
2022-08-02 17:18:47 +05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: interaction.translate("music/nowplaying:T_DURATION"),
|
2022-12-15 21:02:38 +05:00
|
|
|
value: progressBar,
|
2022-08-02 17:18:47 +05:00
|
|
|
},
|
|
|
|
{
|
2022-08-03 20:57:54 +05:00
|
|
|
name: "\u200b",
|
|
|
|
value: `${interaction.translate("music/nowplaying:REPEAT")}: \`${
|
2023-07-05 00:58:06 +05:00
|
|
|
queue.repeatMode === QueueRepeatMode.AUTOPLAY
|
|
|
|
? interaction.translate("music/nowplaying:AUTOPLAY")
|
|
|
|
: queue.repeatMode === QueueRepeatMode.QUEUE
|
|
|
|
? interaction.translate("music/nowplaying:QUEUE")
|
|
|
|
: queue.repeatMode === QueueRepeatMode.TRACK
|
|
|
|
? interaction.translate("music/nowplaying:TRACK")
|
|
|
|
: interaction.translate("common:DISABLED")
|
2022-12-15 21:02:38 +05:00
|
|
|
}\``,
|
|
|
|
},
|
2022-08-02 17:18:47 +05:00
|
|
|
])
|
|
|
|
.setColor(client.config.embed.color)
|
2023-07-07 21:13:11 +05:00
|
|
|
.setFooter(client.config.embed.footer)
|
2022-08-02 17:18:47 +05:00
|
|
|
.setTimestamp();
|
|
|
|
|
2022-08-03 20:57:54 +05:00
|
|
|
interaction.editReply({
|
2022-12-15 21:02:38 +05:00
|
|
|
embeds: [embed],
|
2022-08-02 17:18:47 +05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-05 00:58:06 +05:00
|
|
|
module.exports = Nowplaying;
|