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)

CharacterDurationExample
sSeconds30s
mMinutes10m
hHours5h
dDays3d

There are 4 types of cooldowns:

Cooldown TypeDescription
perUserApplies to a specific user across all guilds and DMs
perUserPerGuildApplies to a specific user in a specific guild
perGuildApplies to all users in a specific guild
globalApplies 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
JavaScript
const { CommandType, CooldownTypes } = require('@nyxb/commands')

module.exports = {
  description: 'Ping pong command',

  type: CommandType.BOTH,

  cooldowns: {
    type: CooldownTypes.perUser,
    duration: '1 d',
  },

  callback: () => {
    return {
      content: 'Pong!',
    }
  },
}