我想编辑这个嵌入到滑块"?“每7秒移动一次的地方。我还希望“剩余时间:”每7秒更改一次。
现在,所有的变化都是"queue.formattedCurrentTime“和"song.formattedDuration”
这是我到目前为止拥有的代码。有什么建议吗?
const { MessageEmbed } = require('discord.js-light')
const createBar = require('string-progressbar')
const { toColonNotation } = require('colon-notation')
module.exports = {
name: 'np',
aliases: ['nowplaying', 'currentsong'],
description: 'Show the currently playing song.',
usage: `${prefix}np`,
run: async(bot, message) => {
const queue = bot.distube.getQueue(message)
if(!queue) return message.channel.send('There are no songs in the queue.')
if(!queue && !bot.distube.isPlaying(message)) return('There is nothing playing.')
const song = queue.songs[0]
const name = song.name
const user = song.user.tag
const avatar = song.user.displayAvatarURL({ dynamic: true, format: "png" })
const link = song.url
const time = song.duration * 1000
const currenttime = queue.currentTime
const tn = song.thumbnail
const remaining = (time - currenttime < 0 ? "◉ LIVE" : time - currenttime)
try {
const embed = new MessageEmbed()
.setTitle(name)
.setAuthor(user, avatar)
.setURL(link)
.setDescription(`${createBar(time === 0 ? currenttime: time, currenttime, 27, "─", "?")[0]} \`[${queue.formattedCurrentTime}/${song.formattedDuration}]\`\n` +
`${bot.distube.isPaused(message) === true ? "⏸" : "▶"} ${time === 0 ? "" : `| **Time Remaining:**\`${toColonNotation(remaining)}\``}`)
.addField('In Channel:', `**${message.member.voice.channel.name}**`, { inline: true })
.addField('From Playlist:', song.fromPlaylist ? "✅" : "❌", { inline: true })
.setColor('#c1abff')
.setThumbnail(`${tn}`)
message.channel.send(embed).then((message) => {
var countdown = 10;
const interval = setInterval(() => {
if (countdown < 0) clearInterval(interval);
const embed = new MessageEmbed()
.setTitle(name)
.setAuthor(user, avatar)
.setURL(link)
.setDescription(`${createBar(time === 0 ? currenttime: time, currenttime, 27, "─", "?")[0]} \`[${queue.formattedCurrentTime}/${song.formattedDuration}]\`\n` +
`${bot.distube.isPaused(message) === true ? "⏸" : "▶"} ${time === 1 ? "" : `| **Time Remaining:**\`` + new Date()`${toColonNotation(remaining)}\``}`)
.addField('In Channel:', `**${message.member.voice.channel.name}**`, { inline: true })
.addField('From Playlist:', song.fromPlaylist ? "✅" : "❌", { inline: true })
.setColor('#c1abff')
.setThumbnail(`${tn}`)
message.edit(embed)
}, 7000)
})
} catch (e) {
message.channel.send(`There was an issue: \n\`${e}\``)
}
}
}发布于 2021-06-10 01:48:13
不断更新embed可能不是一个理想的解决方案。
相反,你可以尝试我在“现在播放”命令中的方法,并在你的嵌入中使用“Stylish text”。
const bar = require(`stylish-text`)
function toReadableTime(given){
var time = given;
var minutes = "0" + Math.floor(time / 60);
var seconds = "0" + (time - minutes * 60);
return minutes.substr(-2) + ":" + seconds.substr(-2);
}
const current = Math.floor(serverQueue.connection.dispatcher.streamTime / 1000) //ms --> seconds
const end = serverQueue.songs[0].length //video in seconds
const value = (current * (100 / end) / 5)
bar.default.full = "█";
bar.default.empty = " - ";
bar.default.start = "";
bar.default.end = "";
bar.default.text = "{bar}";
`${toReadableTime(current)} - [${bar.progress(20, value)}] - ${toReadableTime(end)}` //This would go in your embed输出:

https://stackoverflow.com/questions/66878067
复制相似问题