Test servers
You may want some commands to only be enabled in specific servers/guilds for testing. This will give you a good idea if something is working in a production environment without risking bugs for your other users. You can easily specify a command as a "test only" command like so:
Typescript
const { CommandType } = require('@nyxb/commands')
module.exports = {
description: 'Ping pong command',
type: CommandType.BOTH,
testOnly: true,
callback: () => {
return {
content: 'Pong!',
}
},
}
You can then specify any amount of server/guild IDs when initializing NYXBCommands like so:
Typescript
import path from 'node:path'
import { Client, IntentsBitField, Partials } from 'discord.js'
import NYXB from '@nyxb/commands'
require('dotenv/config')
const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.DirectMessages,
IntentsBitField.Flags.MessageContent,
],
partials: [Partials.Channel],
})
client.on('ready', () => {
console.log('The bot is ready')
new NYXB({
client,
commandsDir: path.join(__dirname, 'commands'),
testServers: ['Server_id_here'],
})
})
client.login(process.env.TOKEN)
CommandsBot owner only commandsSome commands should only be available to the bot owners. A perfect example of this is a "status" command that updates the status of your bot. NYXBCommands comes with this capability.CommandsCooldownsYou can use command cooldowns to ensure your commands are only ran every so often. Each cooldown type requires a string for it's duration and duration type (seconds, minutes, etc)