mirror of
https://github.com/musix-org/musix-oss
synced 2024-11-10 02:00:20 +00:00
28 lines
1.5 KiB
JavaScript
28 lines
1.5 KiB
JavaScript
const { EmbedBuilder } = require('discord.js');
|
|
|
|
module.exports = {
|
|
name: 'nowplaying',
|
|
description: 'Now playing command.',
|
|
alias: 'np',
|
|
cooldown: 5,
|
|
async execute(message, args, client, prefix) {
|
|
const ytdl = require('ytdl-core');
|
|
const serverQueue = client.queue.get(message.guild.id);
|
|
if (!serverQueue) return message.channel.send(':x: There is nothing playing.');
|
|
if (!serverQueue.playing) return message.channel.send(':x: There is nothing playing.');
|
|
let data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url));
|
|
let songtime = (data.length_seconds * 1000).toFixed(0);
|
|
let completed = (serverQueue.connection.dispatcher.time).toFixed(0);
|
|
let barlength = 30;
|
|
let completedpercent = ((completed / songtime) * barlength).toFixed(0);
|
|
let array = []; for (let i = 0; i < completedpercent - 1; i++) { array.push('⎯'); } array.push('⭗'); for (let i = 0; i < barlength - completedpercent - 1; i++) { array.push('⎯'); }
|
|
const embed = new EmbedBuilder()
|
|
.setTitle("__Now playing__")
|
|
.setDescription(`🎶**Now playing:** ${serverQueue.songs[0].title}\n${array.join('')} | \`${client.funcs.msToTime(completed)} / ${client.funcs.msToTime(songtime)}\``)
|
|
.setFooter({ text: `Queued by ${serverQueue.songs[0].author.tag}` })
|
|
.setURL(serverQueue.songs[0].url)
|
|
.setColor(client.config.embedColor)
|
|
return message.channel.send({ embeds: [embed] });
|
|
}
|
|
};
|