Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { MessageEmbed } = require("discord.js");
- const sendError = require("../util/error")
- const { splitBar } = require('string-progressbar');
- module.exports = {
- info: {
- name: "nowplaying",
- description: "To see song details",
- usage: "",
- aliases: ["np"],
- },
- run: async function (client, message, args) {
- const channel = message.member.voice.channel
- if (!channel)return message.channel.send("<a:Animated_Cross448:857518282206085120> **You must Join a voice channel before using this command!**", message.channel).catch(err => console.log(err));
- const serverQueue = message.client.queue.get(message.guild.id);
- if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id)
- return message.channel.send(`<a:Animated_Cross448:857518282206085120> **You Must be in same voice channel to use this command**`).catch(err => console.log(err));
- if (!serverQueue) return sendError("**There is nothing playing in queue.**", message.channel);
- let song = serverQueue.songs[0]
- var totalseconds = parseInt(song.duration)/1000
- var seconds_passed = message.guild.me.voice.connection.dispatcher.streamTime/1000
- var t_now = time_convert(seconds_passed)
- var t_all = time_convert(totalseconds)
- var timeline = ''
- for(var i = 1; i <= time(seconds_passed, totalseconds); i++){
- timeline = timeline.concat('─')
- }
- timeline = timeline.concat('🔘')
- for(var i = timeline.indexOf('🔘')+1; i <= 19; i++){
- timeline = timeline.concat('─')
- }
- timeline = timeline.concat(`\n[${t_now}/${t_all}]`)
- let thing = new MessageEmbed()
- .setTitle(song.title)
- .setURL(song.url)
- .setColor("#ffb700")
- .setDescription(timeline)
- return message.channel.send(thing).catch(err => console.log(err));
- },
- };
- function time(now_sec, total_sec){
- var song = Math.floor(now_sec/total_sec*100)
- song = Math.floor(song/5)
- return song
- }
- function time_convert(seconds){
- let mins = Math.floor(seconds / 60)
- let hours = Math.floor(mins / 60)
- let sec = seconds - (mins * 60)
- mins = mins - (hours * 60)
- sec = Math.round(sec)
- if(hours < 10) hours = `0${hours}`
- if(mins < 10) mins = `0${mins}`
- if(sec < 10) sec = `0${sec}`
- if(hours === `00`) return `${mins}:${sec}`
- return `${hours}:${mins}`
- }
Add Comment
Please, Sign In to add comment