Guild and Owner-only Commands

Some commands should only work in guilds while some cannot. Some commands should also only be used by a bot developer.

Setting up a guildonly Command

We will use the ping command as an example. Set guildonly to true if you want the ping command to work only in guilds.

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

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

module.exports = Command;

End Result:

In a Server:

In a Direct Message:

Setting up a ownerOnly command

ownerOnly option requires you to insert an array of IDs for botOwners option (which is mentioned on the Setting Up Your Project page).

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

module.exports = Command;

End Result:

For Normal User:

For Bot Owner:

Last updated