Xtreme_Killer

Helping Hand V2

Aug 2nd, 2021 (edited)
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { MessageEmbed } = require("discord.js");
  2. const sendError = require("../util/error")
  3. const { splitBar } = require('string-progressbar');
  4.  
  5. module.exports = {
  6.   info: {
  7.     name: "nowplaying",
  8.     description: "To see song details",
  9.     usage: "",
  10.     aliases: ["np"],
  11.   },
  12.  
  13.   run: async function (client, message, args) {
  14.     const channel = message.member.voice.channel
  15.     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));
  16.     const serverQueue = message.client.queue.get(message.guild.id);
  17.     if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id)
  18.     return message.channel.send(`<a:Animated_Cross448:857518282206085120> **You Must be in same voice channel to use this command**`).catch(err => console.log(err));
  19.     if (!serverQueue) return sendError("**There is nothing playing in queue.**", message.channel);
  20.     let song = serverQueue.songs[0]
  21.     var totalseconds = parseInt(song.duration)/1000
  22.     var seconds_passed = message.guild.me.voice.connection.dispatcher.streamTime/1000
  23.     var t_now = time_convert(seconds_passed)
  24.     var t_all = time_convert(totalseconds)
  25.     var timeline = ''
  26.     for(var i = 1; i <= time(seconds_passed, totalseconds); i++){
  27.         timeline = timeline.concat('─')
  28.     }
  29.     timeline = timeline.concat('🔘')
  30.     for(var i = timeline.indexOf('🔘')+1; i <= 19; i++){
  31.         timeline = timeline.concat('─')
  32.     }
  33.     timeline = timeline.concat(`\n[${t_now}/${t_all}]`)
  34.     let thing = new MessageEmbed()
  35.       .setTitle(song.title)
  36.       .setURL(song.url)
  37.       .setColor("#ffb700")
  38.       .setDescription(timeline)
  39.       return message.channel.send(thing).catch(err => console.log(err));
  40.   },
  41. };
  42.  
  43. function time(now_sec, total_sec){
  44.     var song = Math.floor(now_sec/total_sec*100)
  45.     song = Math.floor(song/5)
  46.     return song
  47. }
  48.  
  49. function time_convert(seconds){
  50.     let mins = Math.floor(seconds / 60)
  51.     let hours = Math.floor(mins / 60)
  52.     let sec = seconds - (mins * 60)
  53.     mins = mins - (hours * 60)
  54.     sec = Math.round(sec)
  55.     if(hours < 10) hours = `0${hours}`
  56.     if(mins < 10) mins = `0${mins}`
  57.     if(sec < 10) sec = `0${sec}`
  58.     if(hours === `00`) return `${mins}:${sec}`
  59.     return `${hours}:${mins}`
  60. }
Add Comment
Please, Sign In to add comment