这是时间代码,StreamTime
是自动播放歌曲的时间,song.duration
是音乐持续时间。我的机器人说NaN
:NaN
代表song.duration
module.exports = {
name: "time",
description: "Show music time",
execute(message, song, duration) {
const queue = message.client.queue.get(message.guild.id);
const dispatcher = queue.connection.dispatcher
message.channel.send({
embed: {
color: 39935, //random color between one and 16777214 (dec)
author: {},
title: "Time ⏳",
color: 39935,
description: `${Math.floor(dispatcher.streamTime / 60000)}:${Math.floor((dispatcher.streamTime % 60000)/1000) <10 ? '0'+Math.floor((dispatcher.streamTime % 60000)/1000) : Math.floor((dispatcher.streamTime % 60000)/1000)} Duration: ${Math.floor(song.duration/60)}:${song.duration%60}`,
timestamp: new Date(),
footer: {
icon_url: message.client.user.avatarURL(),
text: "© test"
}
}
});
}}
似乎song.duration
似乎不是数字。
您需要先将其转换为数字
description: `${Math.floor(dispatcher.streamTime / 60000)}:${Math.floor((dispatcher.streamTime % 60000)/1000) <10 ? '0'+Math.floor((dispatcher.streamTime % 60000)/1000) : Math.floor((dispatcher.streamTime % 60000)/1000)} Duration: ${Math.floor(parseInt(song.duration)/60)}:${parseInt(song.duration)%60}`,