【问题标题】:Ping problems discord.jsPing 问题 discord.js
【发布时间】:2020-04-16 12:19:07
【问题描述】:

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 显示为负数并且是一个很大的数字。请帮忙!

【问题讨论】:

    标签: javascript discord discord.js ping


    【解决方案1】:

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

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

    把它改成相反的:

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

    您的代码已更改:

    (msg.createdTimestamp - Date.now())
    

    【讨论】:

      猜你喜欢
      • 2017-09-16
      • 1970-01-01
      • 2020-12-04
      • 1970-01-01
      • 2021-10-09
      • 2020-04-29
      • 2018-10-21
      • 2022-10-15
      • 2020-07-24
      相关资源
      最近更新 更多