Cooldowns
You 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)
Character | Duration | Example |
---|---|---|
s | Seconds | 30s |
m | Minutes | 10m |
h | Hours | 5h |
d | Days | 3d |
There are 4 types of cooldowns:
Cooldown Type | Description |
---|---|
perUser | Applies to a specific user across all guilds and DMs |
perUserPerGuild | Applies to a specific user in a specific guild |
perGuild | Applies to all users in a specific guild |
global | Applies to all users in all guilds |
Example of per-user cooldowns:
TypeScript
import { CommandObject, CommandType, CooldownTypes } from '@nyxb/commands'
export default {
description: 'Ping pong command',
type: CommandType.BOTH,
cooldowns: {
type: CooldownTypes.perUser,
duration: '1 d',
},
callback: () => {
return {
content: 'Pong!',
}
},
} as CommandObject
CommandsTest serversYou 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:CommandsRequired permissionsYou may want your commands to only be ran by users who have specific Discord permissions. This is often useful for administration commands.
Using NYXBCommands you can easily specify what Discord permissions users need to run the command: