JaBa/commands/Music/nowplaying.js

101 lines
3 KiB
JavaScript
Raw Normal View History

const { SlashCommandBuilder, EmbedBuilder } = require("discord.js"),
{ QueueRepeatMode } = require("discord-player");
const BaseCommand = require("../../base/BaseCommand");
class Nowplaying extends BaseCommand {
/**
*
* @param {import("../base/JaBa")} client
*/
constructor(client) {
super({
command: new SlashCommandBuilder()
.setName("nowplaying")
.setDescription(client.translate("music/nowplaying:DESCRIPTION"))
.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"),
})
.setDMPermission(false),
aliases: [],
dirname: __dirname,
ownerOnly: false,
});
}
/**
*
* @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
*/
2023-06-27 21:19:55 +05:00
async execute(client, interaction, data) {
await interaction.deferReply();
const queue = client.player.nodes.get(interaction.guildId);
if (!queue) return interaction.error("music/play:NOT_PLAYING", null, { edit: true });
const progressBar = queue.node.createProgressBar(),
track = queue.currentTrack;
const embed = new EmbedBuilder()
.setAuthor({
name: interaction.translate("music/nowplaying:CURRENTLY_PLAYING"),
})
.setThumbnail(track.thumbnail)
.addFields([
{
name: interaction.translate("music/nowplaying:T_TITLE"),
value: `[${track.title}](${track.url})`,
inline: true,
},
{
name: interaction.translate("music/nowplaying:T_AUTHOR"),
value: track.author || interaction.translate("common:UNKNOWN"),
inline: true,
},
{ 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),
inline: true,
},
{
name: interaction.translate("music/queue:ADDED"),
value: track.requestedBy.toString(),
inline: true,
},
{
name: interaction.translate("music/nowplaying:T_DURATION"),
value: progressBar,
},
{
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")
}\``,
},
])
.setColor(client.config.embed.color)
.setFooter(client.config.embed.footer)
.setTimestamp();
interaction.editReply({
embeds: [embed],
});
}
}
2023-07-05 00:58:06 +05:00
module.exports = Nowplaying;