0

我正在尝试使用discord.js&创建一个音乐机器人ytdl-core。我想在使用名为!nowplaying. 但是,我不确定我是如何获得时间的。我的代码:

//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}`);

我尝试过使用queue.connection.streamTime, 和其他方法,但它们没有奏效

4

1 回答 1

1

使用voiceConnection#dispatcher(它返回一个StreamDispatcher)而不是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}`);
于 2020-09-02T17:27:42.430 回答