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
guildonly CommandWe will use the ping command as an example. Set guildonly to true if you want the ping command to work only in guilds.
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;import { ICommand, NoCliCommandType } from "nocli-handler.js";
export default {
guildOnly: true, // <-- Set guildOnly to true
description: "Checks client latency",
type: NoCliCommandType.Both,
callback: ({ client, message, args, text }) => {
return `π Pong! \`${client.ws.ping}ms\``;
}
} as ICommand;
End Result:In a Server:
In a Direct Message:
Setting up a ownerOnly command
ownerOnly command
End Result:For Normal User:
For Bot Owner:
Last updated



