Setup & Options object

Here is a basic example of how to setup NYXBCommands. When calling the constructor you can pass in an options object that configures NYXBCommands to how you want.

Here is a simple example with only the essentials to get a bot up and running:

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', () => {
  new NYXB({
    client,
    commandsDir: path.join(__dirname, 'commands'),
  })
})

client.login(process.env.TOKEN)
Javascript
const path = require('node:path')
const { Client, IntentsBitField, Partials } = require('discord.js')
const NYXB = require('@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', () => {
  new NYXB({
    client,
    commandsDir: path.join(__dirname, 'commands'),
  })
})

client.login(process.env.TOKEN)

Here is a full example of all options:

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', () => {
  new NYXB({
    // The client for your bot. This is the only required property
    client,
    // Path to your commands folder
    commandsDir: path.join(__dirname, 'commands'),
    // Path to your features folder
    featuresDir: path.join(__dirname, 'features'),
    // Configure your event handlers
    events: {
      // Where your events are located. This is required if you
      // provide this events object
      dir: path.join(__dirname, 'events'),
      // To learn how to properly configure your events please see
      // https://docs.wornoffkeys.com/events/what-is-a-feature
    },
    // Your MongoDB connection URI
    mongoUri: process.env.MONGO_URI || '',
    // What server IDs are for testing. This is where test
    // only commands are registered to
    testServers: ['TEST_SERVER_ID_HERE'],
    // User IDs who are bot owners/developers. These users
    // can access owner only commands
    botOwners: ['YOUR_DISCORD_ID_HERE'],
    // Don't want some of the default commands? Add them here
    disabledDefaultCommands: [
      // DefaultCommands.ChannelCommand,
      // DefaultCommands.CustomCommand,
      // DefaultCommands.Prefix,
      // DefaultCommands.RequiredPermissions,
      // DefaultCommands.RequiredRoles,
      // DefaultCommands.ToggleCommand
    ],
    // Configure the cooldowns for your commands and features
    cooldownConfig: {
      errorMessage: 'Please wait {TIME} before doing that again.',
      botOwnersBypass: false,
      // The amount of seconds required for a cooldown to be
      // persistent via MongoDB.
      dbRequired: 300,
    },
    // Dynamic validations
    validations: {
      // Syntax based validations: Ran per command whenever
      // the bot starts up. Useful to throw errors if the
      // syntax of a command is not correct.
      syntax: path.join(__dirname, 'validations', 'syntax'),
      // Runtime based validations: Ran per command whenever
      // that command is ran. Should return true or false
      // depending on if the command should be ran or not.
      runtime: path.join(__dirname, 'validations', 'runtime'),
      // For more information on how to configure dyanmic validations
      // please see: TODO: add link
    }
  })
})

client.login(process.env.TOKEN)
Javascript
const path = require('node:path')
const { Client, IntentsBitField, Partials } = require('discord.js')
const NYXB = require('@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', () => {
  new NYXB({
    client,
    commandsDir: path.join(__dirname, 'commands'),
  })
})

client.login(process.env.TOKEN)