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
1
const DiscordJS = require('discord.js')
2
const WOKCommands = require('wokcommands')
3
const path = require('path')
4
5
const { Intents } = DiscordJS
6
7
const client = new DiscordJS.Client({
8
// These intents are recommended for the built in help menu
9
intents: [
10
Intents.FLAGS.GUILDS,
11
Intents.FLAGS.GUILD_MESSAGES,
12
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
13
],
14
})
15
16
client.on('ready', () => {
17
new WOKCommands(client, {
18
// The name of the local folder for your command files
19
commandsDir: path.join(__dirname, 'commands'),
20
})
21
})
22
23
client.login('YOUR TOKEN HERE')
Copied!
index.ts
1
import DiscordJS, { Intents } from 'discord.js'
2
import WOKCommands from 'wokcommands'
3
import path from 'path'
4
5
const client = new DiscordJS.Client({
6
// These intents are recommended for the built in help menu
7
intents: [
8
Intents.FLAGS.GUILDS,
9
Intents.FLAGS.GUILD_MESSAGES,
10
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
11
],
12
})
13
14
client.on('ready', () => {
15
new WOKCommands(client, {
16
// The name of the local folder for your command files
17
commandsDir: path.join(__dirname, 'commands'),
18
// Allow importing of .ts files if you are using ts-node
19
typeScript: true
20
})
21
})
22
23
client.login('YOUR TOKEN HERE')
Copied!
Here is a full example of all options:
JavaScript
TypeScript
index.js
1
const DiscordJS = require('discord.js')
2
const WOKCommands = require('wokcommands')
3
const path = require('path')
4
5
const { Intents } = DiscordJS
6
7
const client = new DiscordJS.Client({
8
// These intents are recommended for the built in help menu
9
intents: [
10
Intents.FLAGS.GUILDS,
11
Intents.FLAGS.GUILD_MESSAGES,
12
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
13
],
14
})
15
16
client.on('ready', () => {
17
// The client object is required as the first argument.
18
// The second argument is the options object.
19
// All properties of this object are optional.
20
21
new WOKCommands(client, {
22
// The name of the local folder for your command files
23
commandsDir: path.join(__dirname, 'commands'),
24
25
// The name of the local folder for your feature files
26
featuresDir: path.join(__dirname, 'features'),
27
28
// The name of the local file for your message text and translations
29
// Omitting this will use the built-in message path
30
messagesPath: '',
31
32
// Allow importing of .ts files
33
typeScript: true,
34
35
// If WOKCommands warning should be shown or not, default true
36
showWarns: true,
37
38
// How many seconds to keep error messages before deleting them
39
// -1 means do not delete, defaults to -1
40
delErrMsgCooldown: -1,
41
42
// What language your bot should use
43
// Must be supported in your messages.json file
44
defaultLangauge: 'english',
45
46
// If your commands should not be ran by a bot, default false
47
ignoreBots: false,
48
49
// If interactions should only be shown to the one user
50
// Only used for when WOKCommands sends an interaction response
51
// Default is true
52
ephemeral: true,
53
54
// Various options for your MongoDB database connection
55
dbOptions: {
56
// These are the default options
57
keepAlive: true
58
},
59
60
// What server/guild IDs are used for testing only commands & features
61
// Can be a single string if there is only 1 ID
62
testServers: ['ID1', 'ID2', 'ID3'],
63
64
// User your own ID
65
// If you only have 1 ID then you can pass in a string instead
66
botOwners: ['ID1', 'ID2'],
67
68
// What built-in commands should be disabled.
69
// Note that you can overwrite a command as well by using
70
// the same name as the command file name.
71
disabledDefaultCommands: [
72
// 'help',
73
// 'command',
74
// 'language',
75
// 'prefix',
76
// 'requiredrole',
77
// 'channelonly'
78
],
79
80
// When connecting to a Mongo database.
81
// For more infomration view the "DATABASES" section
82
// of this documentation.
83
mongoUri: process.env.MONGO_URI,
84
85
// Provides additional debug logging
86
debug: false
87
})
88
// Here are some additional methods that you can chain
89
// onto the contrustor call. These will eventually be
90
// merged into the above object, but for now you can
91
// use them:
92
93
// The default is !
94
.setDefaultPrefix('?')
95
96
// Used for the color of embeds sent by WOKCommands
97
.setColor(0xff0000)
98
})
99
100
client.login('YOUR TOKEN HERE')
Copied!
index.ts
1
import DiscordJS, { Intents } from 'discord.js'
2
import WOKCommands from 'wokcommands'
3
import path from 'path'
4
5
const client = new DiscordJS.Client({
6
// These intents are recommended for the built in help menu
7
intents: [
8
Intents.FLAGS.GUILDS,
9
Intents.FLAGS.GUILD_MESSAGES,
10
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
11
],
12
})
13
14
client.on('ready', () => {
15
// The client object is required as the first argument.
16
// The second argument is the options object.
17
// All properties of this object are optional.
18
19
new WOKCommands(client, {
20
// The name of the local folder for your command files
21
commandsDir: path.join(__dirname, 'commands'),
22
23
// The name of the local folder for your feature files
24
featuresDir: path.join(__dirname, 'features'),
25
26
// The name of the local file for your message text and translations
27
// Omitting this will use the built-in message path
28
messagesPath: '',
29
30
// If WOKCommands warning should be shown or not, default true
31
showWarns: true,
32
33
// How many seconds to keep error messages before deleting them
34
// -1 means do not delete, defaults to -1
35
delErrMsgCooldown: -1,
36
37
// What language your bot should use
38
// Must be supported in your messages.json file
39
defaultLangauge: 'english',
40
41
// If your commands should not be ran by a bot, default false
42
ignoreBots: false,
43
44
// If interactions should only be shown to the one user
45
// Only used for when WOKCommands sends an interaction response
46
// Default is true
47
ephemeral: true,
48
49
// Various options for your MongoDB database connection
50
dbOptions: {
51
// These are the default options
52
keepAlive: true
53
},
54
55
// What server/guild IDs are used for testing only commands & features
56
// Can be a single string if there is only 1 ID
57
testServers: ['ID1', 'ID2', 'ID3'],
58
59
// User your own ID
60
// If you only have 1 ID then you can pass in a string instead
61
botOwners: ['ID1', 'ID2'],
62
63
// What built-in commands should be disabled.
64
// Note that you can overwrite a command as well by using
65
// the same name as the command file name.
66
disabledDefaultCommands: [
67
// 'help',
68
// 'command',
69
// 'language',
70
// 'prefix',
71
// 'requiredrole'
72
],
73
74
// When connecting to a Mongo database.
75
// For more infomration view the "DATABASES" section
76
// of this documentation.
77
mongoUri: process.env.MONGO_URI,
78
79
// Provides additional debug logging
80
debug: false
81
})
82
// Here are some additional methods that you can chain
83
// onto the contrustor call. These will eventually be
84
// merged into the above object, but for now you can
85
// use them:
86
87
// The default is !
88
.setDefaultPrefix('?')
89
90
// Used for the color of embeds sent by WOKCommands
91
.setColor(0xff0000)
92
})
93
94
client.login('YOUR TOKEN HERE')
Copied!
Copy link