WOKCommands
Search…
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:
JavaScript
TypeScript
index.js
const DiscordJS = require('discord.js')
const WOKCommands = require('wokcommands')
const path = require('path')
const { Intents } = DiscordJS
const client = new DiscordJS.Client({
// These intents are recommended for the built in help menu
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
],
})
client.on('ready', () => {
new WOKCommands(client, {
// The name of the local folder for your command files
commandsDir: path.join(__dirname, 'commands'),
})
})
client.login('YOUR TOKEN HERE')
index.ts
import DiscordJS, { Intents } from 'discord.js'
import WOKCommands from 'wokcommands'
import path from 'path'
const client = new DiscordJS.Client({
// These intents are recommended for the built in help menu
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
],
})
client.on('ready', () => {
new WOKCommands(client, {
// The name of the local folder for your command files
commandsDir: path.join(__dirname, 'commands'),
// Allow importing of .ts files if you are using ts-node
typeScript: true
})
})
client.login('YOUR TOKEN HERE')
Here is a full example of all options:
JavaScript
TypeScript
index.js
const DiscordJS = require('discord.js')
const WOKCommands = require('wokcommands')
const path = require('path')
const { Intents } = DiscordJS
const client = new DiscordJS.Client({
// These intents are recommended for the built in help menu
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
],
})
client.on('ready', () => {
// The client object is required as the first argument.
// The second argument is the options object.
// All properties of this object are optional.
new WOKCommands(client, {
// The name of the local folder for your command files
commandsDir: path.join(__dirname, 'commands'),
// The name of the local folder for your feature files
featuresDir: path.join(__dirname, 'features'),
// The name of the local file for your message text and translations
// Omitting this will use the built-in message path
messagesPath: '',
// Allow importing of .ts files
typeScript: true,
// If WOKCommands warning should be shown or not, default true
showWarns: true,
// How many seconds to keep error messages before deleting them
// -1 means do not delete, defaults to -1
delErrMsgCooldown: -1,
// What language your bot should use
// Must be supported in your messages.json file
defaultLangauge: 'english',
// If your commands should not be ran by a bot, default false
ignoreBots: false,
// If interactions should only be shown to the one user
// Only used for when WOKCommands sends an interaction response
// Default is true
ephemeral: true,
// Various options for your MongoDB database connection
dbOptions: {
// These are the default options
keepAlive: true
},
// What server/guild IDs are used for testing only commands & features
// Can be a single string if there is only 1 ID
testServers: ['ID1', 'ID2', 'ID3'],
// User your own ID
// If you only have 1 ID then you can pass in a string instead
botOwners: ['ID1', 'ID2'],
// What built-in commands should be disabled.
// Note that you can overwrite a command as well by using
// the same name as the command file name.
disabledDefaultCommands: [
// 'help',
// 'command',
// 'language',
// 'prefix',
// 'requiredrole',
// 'channelonly'
],
// When connecting to a Mongo database.
// For more infomration view the "DATABASES" section
// of this documentation.
mongoUri: process.env.MONGO_URI,
// Provides additional debug logging
debug: false
})
// Here are some additional methods that you can chain
// onto the contrustor call. These will eventually be
// merged into the above object, but for now you can
// use them:
// The default is !
.setDefaultPrefix('?')
// Used for the color of embeds sent by WOKCommands
.setColor(0xff0000)
})
client.login('YOUR TOKEN HERE')
index.ts
import DiscordJS, { Intents } from 'discord.js'
import WOKCommands from 'wokcommands'
import path from 'path'
const client = new DiscordJS.Client({
// These intents are recommended for the built in help menu
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
],
})
client.on('ready', () => {
// The client object is required as the first argument.
// The second argument is the options object.
// All properties of this object are optional.
new WOKCommands(client, {
// The name of the local folder for your command files
commandsDir: path.join(__dirname, 'commands'),
// The name of the local folder for your feature files
featuresDir: path.join(__dirname, 'features'),
// The name of the local file for your message text and translations
// Omitting this will use the built-in message path
messagesPath: '',
// If WOKCommands warning should be shown or not, default true
showWarns: true,
// How many seconds to keep error messages before deleting them
// -1 means do not delete, defaults to -1
delErrMsgCooldown: -1,
// What language your bot should use
// Must be supported in your messages.json file
defaultLangauge: 'english',
// If your commands should not be ran by a bot, default false
ignoreBots: false,
// If interactions should only be shown to the one user
// Only used for when WOKCommands sends an interaction response
// Default is true
ephemeral: true,
// Various options for your MongoDB database connection
dbOptions: {
// These are the default options
keepAlive: true
},
// What server/guild IDs are used for testing only commands & features
// Can be a single string if there is only 1 ID
testServers: ['ID1', 'ID2', 'ID3'],
// User your own ID
// If you only have 1 ID then you can pass in a string instead
botOwners: ['ID1', 'ID2'],
// What built-in commands should be disabled.
// Note that you can overwrite a command as well by using
// the same name as the command file name.
disabledDefaultCommands: [
// 'help',
// 'command',
// 'language',
// 'prefix',
// 'requiredrole'
],
// When connecting to a Mongo database.
// For more infomration view the "DATABASES" section
// of this documentation.
mongoUri: process.env.MONGO_URI,
// Provides additional debug logging
debug: false
})
// Here are some additional methods that you can chain
// onto the contrustor call. These will eventually be
// merged into the above object, but for now you can
// use them:
// The default is !
.setDefaultPrefix('?')
// Used for the color of embeds sent by WOKCommands
.setColor(0xff0000)
})
client.login('YOUR TOKEN HERE')
Copy link