Easy Setup & Options Object

When calling the constructor you pass in an options object that configures SLCommands to how you want.

Here is an easy example of how to setup SLCommands:

index.js
const SLHandler = require('sl-commands').default
const { join } = require('path')

/** The DiscordJS client is created automatically */
new SLHandler({
  /** The command files directory name */
  commandsDir: join(__dirname, 'commands'),
  /** The token for your application */
  botToken: 'Your_Bot_Token',
})

Here is a full example of all options:

index.js
const { IntentsBitField }  = require('discord.js')
const SLHandler = require('sl-commands').default
const { join } = require('path')

new SLHandler({
  /** Your Discord Bot authorization token (required) */
  botToken: 'Your_Bot_Token',

  /** The local directories for features, commands and events */
  featuresDir: join(__dirname, 'features'),
  commandsDir: join(__dirname, 'commands'),
  eventsDir: join(__dirname, 'events'),

  /** The custom messages JSON path */
  messagesPath: join(__dirname, 'messages.json'),

  /** The options for your DiscordJS client */
  clientOptions: {
    intents: [IntentsBitField.Flags.Guilds, IntentsBitField.Flags.GuildMembers],
  },

  /** Test servers will be used to register testOnly commands */
  testServersIds: ['Id1', 'Id2'],
  /** Bots devs are the only ones who will be able to use devsOnly commands */
  botDevsIds: ['Id1', 'Id2'],

  /** If this is false, handler events will be emitted instead of auto replying */
  useDefaultMessages: true,
  /** The default language for handler replies (a little useless if useDefaultMessages is false) */
  language: 'pt-br',

  /** Whether the handler should log warns or not */
  showWarns: true,
  /** If a command does not have a testOnly property this one will be used */
  testOnly: true,

  /** Mongoose connect options */
  mongoUri: 'Your_Mongo_URI',
  dbOptions: {},
})

Last updated