【问题标题】:Is there any way to make a ping command in discord.js? [duplicate]有没有办法在 discord.js 中发出 ping 命令? [复制]
【发布时间】:2021-08-07 15:11:00
【问题描述】:

由于我的 discord.py 问题,您可能认识我。这一次,我想知道如何在 discord.js 中做到这一点。如果你没有读过,我基本上不知道如何在 discord.js 中创建一个不和谐的 ping 命令。非常感谢

【问题讨论】:

标签: javascript discord.js


【解决方案1】:

编辑:这个问题已经回答了here

获取消息 ping:

client.on('message', message => {
  if (message.content === '!ping') {  
    message.channel.send(`Ping: ${Date.now() - message.createdTimestamp}ms`);
  }
});

延迟 ping:

client.on('message', message => {
  if (message.content === '!ping') {  
    message.channel.send(`API Latency is ${Math.round(client.ws.ping)}ms`);
  }
});

Discord.js Guide 中检查this

【讨论】:

    猜你喜欢
    • 2020-03-01
    • 2020-12-04
    • 1970-01-01
    • 2021-10-10
    • 2013-02-02
    • 1970-01-01
    • 2020-04-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多