我正在尝试用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
和其他方法,但它们都不起作用
发布于 2020-09-02 17:27:42
使用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}`);
https://stackoverflow.com/questions/63710477
复制相似问题