Creating a simple "Ping Pong" Command

At this page, you will learn how to create a simple "Ping Pong" command.

How to create a "Ping Pong" Command

Firstly, create a file in the commands directory you specified in the index.js file, and name it ping.js.

Secondly, paste this code into your ping.js file.

ping.js
const { NoCliCommandType } = require("nocli-handler.js");

/**
 * @type {import("nocli-handler.js").ICommand}
 */
const Command = {
    type: NoCliCommandType.Legacy,
    description: "Checks client latency",
    callback: ({ client, message, args, text }) => {
        return `๐Ÿ“ Pong! \`${client.ws.ping}ms\``
    }
}

module.exports = Command;

You may receive a warning from the console that says No mongoURI provided. Just ignore that warning since this command doesn't require a database.

Once your program starts, try running the ping command:

For the default prefix during the nocli-handler.js initialization, if you have set any, please replace "!" with the default prefix you have set.

Last updated