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;
End Result:In a Server:
In a Direct Message:
Setting up a ownerOnly
command
ownerOnly
command/**
* @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