WOKCommands
  • WOKCommands Documentation
  • Useful Links
    • Setup & Options object
    • 🧠 Build a website dashboard, monetize your bot, and get more users
    • 💰 $100 in FREE Hosting Credits
    • 🙋‍♂️ Support Server
    • 📺 YouTube Channel
  • Commands
    • Ping pong command example
    • Command properties
    • Correct argument usage
    • Command initialization method
    • Bot owner only commands
    • Test servers
    • Cooldowns
    • Required permissions
    • Slash commands
    • Inferred slash command arguments
    • Custom slash command arguments
    • Autocomplete
  • Command Validations
    • Validation setup
    • Runtime validations
    • Syntax validations
  • Event Handler
    • Event Handling
    • Dynamic Validations
  • Features
    • Features
  • Built-in commands and features
    • Enabling and disabling commands
    • Configurable required roles
    • Configurable required permissions
    • Per-guild prefixes
    • Customizable channel specific commands
    • Custom commands
Powered by GitBook
On this page

Was this helpful?

  1. Useful Links

Setup & Options object

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

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

index.js
const { Client, IntentsBitField, Partials } = require("discord.js");
const WOK = require("wokcommands");
const path = require("path");
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 WOK({
    client,
    commandsDir: path.join(__dirname, "commands"),
  });
});

client.login(process.env.TOKEN);
index.ts
import { Client, IntentsBitField, Partials } from "discord.js";
import WOK from "wokcommands";
import path from "path";
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 WOK({
    client,
    commandsDir: path.join(__dirname, "commands"),
  });
});

client.login(process.env.TOKEN);

Here is a full example of all options:

index.js
const { Client, IntentsBitField, Partials } = require("discord.js");
const WOK = require("wokcommands");
const path = require("path");
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 WOK({
    // 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);
index.ts
import { Client, IntentsBitField, Partials } from "discord.js";
import WOK from "wokcommands";
import path from "path";
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 WOK({
    // 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);
PreviousWOKCommands DocumentationNextPing pong command example

Last updated 2 years ago

Was this helpful?