1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-09-20 14:01:55 +00:00
musix-oss/commands/nowplaying.js

33 lines
1.6 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',
2020-03-14 16:38:02 +00:00
async execute(msg, args, client, Discord, prefix, command) {
2020-02-05 20:02:53 +00:00
const getThumb = require('video-thumbnail-url');
const ytdl = require('ytdl-core');
2020-03-14 16:38:02 +00:00
const queue = client.queue.get(msg.guild.id);
if (!queue) return msg.channel.send(client.messages.noServerQueue);
let data = await Promise.resolve(ytdl.getInfo(queue.songs[0].url));
2020-02-05 20:02:53 +00:00
let songtime = (data.length_seconds * 1000).toFixed(0);
2020-03-14 16:38:02 +00:00
queue.time = queue.connection.dispatcher.streamTime;
let completed = (queue.time.toFixed(0));
2020-02-05 20:02:53 +00:00
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('⎯'); }
2020-03-14 16:38:02 +00:00
const thumbnail = getThumb(queue.songs[0].url);
2020-02-05 20:02:53 +00:00
const embed = new Discord.MessageEmbed()
2020-03-12 11:56:31 +00:00
.setTitle(client.messages.nowPlaying)
2020-03-14 16:38:02 +00:00
.setDescription(`${client.messages.nowPlayingDesc} ${queue.songs[0].title}\n${array.join('')} | \`${client.funcs.msToTime(completed, "hh:mm:ss")} / ${client.funcs.msToTime(songtime, "hh:mm:ss")}\``)
.setFooter(`Queued by ${queue.songs[0].author.tag}`)
.setURL(queue.songs[0].url)
2020-02-05 20:02:53 +00:00
.setThumbnail(thumbnail._rejectionHandler0)
.setColor(client.config.embedColor)
return msg.channel.send(embed);
}
};