Skip to content

Instantly share code, notes, and snippets.

View Mr-KayJayDee's full-sized avatar
🖥️
Coding

Mr¤KayJayDee Mr-KayJayDee

🖥️
Coding
View GitHub Profile
//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
//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] = [];
};