I am trying to create a music bot with discord.js
& ytdl-core
. I would like to display the current timestamp when using a command called !nowplaying
. However, I am not sure how I get the time. My code:
//bot.queue is a collection, and contains some attributes, like songs (array) and connection (ytdl)
let queue = bot.queue.get(message.guild.id);
const time = queue.connection.streamTime; //Doesn't work!
//Convert time here, then output
message.channel.send(`Now Playing - ${queue.songs[0].title} - ${time}`);
I've tried using queue.connection.streamTime
, and other methods, but they haven't worked
Use voiceConnection#dispatcher
(it returns a StreamDispatcher) instead of voiceConnection
:
//bot.queue is a collection, and contains some attributes, like songs (array) and connection (ytdl)
let queue = bot.queue.get(message.guild.id);
const time = queue.connection.dispatcher.streamTime; //Doesn't work!
//Convert time here, then output
message.channel.send(`Now Playing - ${queue.songs[0].title} - ${time}`);