我正在制作一个主要功能是播放音乐的不和谐机器人。我有一个正在播放的命令,它会显示您在歌曲中的进度,我想每 5 秒左右进行一次更新。我知道编辑嵌入,但我需要它一直循环直到歌曲停止。这是现在的代码:
const createBar = require("string-progressbar");
const { MessageEmbed } = require("discord.js");
module.exports = {
name: "np",
description: "Show now playing song",
execute(message) {
const queue = message.client.queue.get(message.guild.id);
if (!queue) return message.reply(`Nothing's playing right now!`).catch(console.error);
const song = queue.songs[0];
const seek = (queue.connection.dispatcher.streamTime - queue.connection.dispatcher.pausedTime) / 1000;
const left = song.duration - seek;
let nowPlaying = new MessageEmbed()
.setTitle("Now playing:")
.setDescription(`${song.title}\n\`Requested by:\` ${message.author}`)
.setColor("#ff0000")
.setThumbnail('https://img.icons8.com/clouds/2x/play.png')
.addField(
"\u200b",
new Date(seek * 1000).toISOString().substr(11, 8) +
"[ " +
createBar(song.duration == 0 ? seek : song.duration, seek, 10)[0] +
"] " +
(song.duration == 0 ? " ◉ LIVE" : new Date(song.duration * 1000).toISOString().substr(11, 8)),
false
);
if (song.duration > 0)
nowPlaying.setFooter("Time Remaining: " + new Date(left * 1000).toISOString().substr(11, 8));
return message.channel.send(nowPlaying);
}
};
皈依舞
相关分类