This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Get the discord.js library | |
const Discord = require("discord.js") | |
// Define the object | |
const cmd = {}; | |
// For each key in the bot commands (replace this.client.commands by for example client.commands oo bot.commands ) | |
for (const key of this.client.commands) { | |
//If the category of the command ins't in the object, push it in | |
if (!cmd[key[1].help.category]) { | |
cmd[key[1].help.category] = []; | |
}; |