Ping问题discord.js

时间:2020-04-16 12:19:07

标签: javascript discord discord.js ping

https://gyazo.com/fce96f41aee0160e197981d1646600a2

bot.on('message', msg=> { 
    if(msg.content == "ping"){ 
            msg.reply("Asteapta...") 
            .then((msg) => { // Resolve promise
                msg.edit("> Pingul este: " + (Date.now() - msg.createdTimestamp)+" milisecunde") // Edits message with current timestamp minus timestamp of message
            });
        }
})

正如您在视频中看到的那样,ping显示为负数并且是一个很大的数字。请帮忙!

1 个答案:

答案 0 :(得分:1)

如果Date.now()大于msg.createdTimestamp,它将给出一个负数。

Date.now() - (Date.now() + 1400) = -1400

将其更改为反向:

(Date.now() + 1400) - Date.now() = 1400

您的代码已更改:

(msg.createdTimestamp - Date.now())