1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-11-10 08:10:18 +00:00
musix-oss/commands/nowplaying.js

33 lines
1.7 KiB
JavaScript
Raw Normal View History

2020-02-05 20:02:53 +00:00
module.exports = {
name: 'nowplaying',
alias: 'np',
2020-02-24 18:41:40 +00:00
usage: '',
2020-02-05 20:02:53 +00:00
description: 'See the currently playing song position and length.',
onlyDev: false,
permission: 'none',
category: 'music',
async execute(msg, args, client, Discord, prefix) {
const getThumb = require('video-thumbnail-url');
const ytdl = require('ytdl-core');
const serverQueue = client.queue.get(msg.guild.id);
2020-03-13 14:20:23 +00:00
if (!serverQueue) return msg.channel.send(client.messages.noServerQueue);
2020-02-05 20:02:53 +00:00
let data = await Promise.resolve(ytdl.getInfo(serverQueue.songs[0].url));
let songtime = (data.length_seconds * 1000).toFixed(0);
serverQueue.time = serverQueue.connection.dispatcher.streamTime;
let completed = (serverQueue.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 thumbnail = getThumb(serverQueue.songs[0].url);
const embed = new Discord.MessageEmbed()
2020-03-12 11:56:31 +00:00
.setTitle(client.messages.nowPlaying)
.setDescription(`${client.messages.nowPlayingDesc} ${serverQueue.songs[0].title}\n${array.join('')} | \`${client.funcs.msToTime(completed, "hh:mm:ss")} / ${client.funcs.msToTime(songtime, "hh:mm:ss")}\``)
2020-02-05 20:02:53 +00:00
.setFooter(`Queued by ${serverQueue.songs[0].author.tag}`)
.setURL(serverQueue.songs[0].url)
.setThumbnail(thumbnail._rejectionHandler0)
.setColor(client.config.embedColor)
return msg.channel.send(embed);
}
};