Skip to content

Instantly share code, notes, and snippets.

@Mr-KayJayDee
Last active May 25, 2020 22:48
Show Gist options
  • Save Mr-KayJayDee/f23084db89f0d3c8de537671090617e0 to your computer and use it in GitHub Desktop.
Save Mr-KayJayDee/f23084db89f0d3c8de537671090617e0 to your computer and use it in GitHub Desktop.
//Listen for message event
bot.on("message", async (message) {
//Check if the content of the message is "ping"
if (message.content === "ping") {
//Set the time that the command was executed in a variable
let now = Date.now()
//Send a loading ping message and set it in a variable
let m = await message.channel.send(`Pinging...`);
//Edit the m variable (the message that was sent before) with the date of the edit of the message minus the created date of the message
//Send too the api ping, by getting the bot.ping and roundig it to a whole number
m.edit(`Pong! BOT PING : \`${Date.now() - now}\`ms\n API PING : ${Math.round(bot.ping)}ms``) //or bot.ws.ping (for v12 users)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment