How i can do a ping command

How i can do a ping command like this:Screenshot_20200114-093225

this might be worth checking out. DiscordJs Bot Tutorial

alternatively, I run a code server that you can join just tag me if thats easier for you and i will help you as soon as i can. I assume you want someone to give u the code. Not help u write it yourself correct?

Check this out: https://github.com/promise/countr/blob/master/commands/ping.js#L11-L42

Hey @ControlCit1,

The ping command is based on the difference in the time at which the message was posted and the timestamp of the message. This is generally how it works.

var ping = Date.now() - message.createdTimestamp + " ms";

To make this into a command, just wrap it up like this:

  if (message.content.startsWith(prefix + "ping")) {
    
    var ping = Date.now() - message.createdTimestamp + " ms";
    message.channel.sendMessage("Your ping is `" + `${Date.now() - message.createdTimestamp}` + " ms`");

  }

Replace prefix with the prefix of your bot.

Hope this helps!

2 Likes

people actually do it like that still? I would be lost without a command handler

1 Like