WOKCommands
Search…
Command properties
This page assumes you have a basic bot running using WOKCommands as seen here.
There are many options you have when it comes to commands, all are optional aside from a callback function which will be ran when a user invokes your command.
A command's file name will become the executable name of the command. Additional aliases can be set, more information here.

Object properties

All commands are exported as objects who have properties to dictate the command's functionality. Here is a complete list of all current properties available to you:
JavaScript
TypeScript
1
module.exports = {
2
// The primary name of the command.
3
// If omitted the name of the file will take it's place.
4
name: 'ping',
5
6
// Alternative aliases, can be a string or an array of strings.
7
// Alternative property names are "commands" or "names".
8
aliases: ['p'],
9
10
// The name and description of the category for the command.
11
// Used in the built-in help menu.
12
category: 'Testing',
13
description: 'Replies with "Pong!"',
14
15
// The correct arguments to use for this command.
16
// Displayed when the number of arguments is incorrect
17
// from "minArgs" and "maxArgs".
18
// Typically required arguments should be surrounded with < and >
19
// and optional arguments should be surrounded with [ and ].
20
// For slash commands this string should be lower case and one word
21
expectedArgs: '',
22
23
// The minimum and maximum amount of arguments.
24
// Tells WOKCommands when to send the correct usage of this command.
25
// Setting maxArgs to -1 (the default) will allow any number of arguments.
26
minArgs: 0,
27
maxArgs: 0,
28
29
// The full syntax error, customizable per command.
30
// You can use "{PREFIX}" in this string to specify the current prefix
31
// for the guild where the command was sent.
32
// You can use "{ARGUMENTS}" in this string to specify the correct arguments.
33
syntaxError: {
34
'english': 'Incorrect syntax! Use `{PREFIX}`ping {ARGUMENTS}'
35
},
36
37
// What Discord permissions the user needs to run the command.
38
// Note that invalid permissions will throw an error to prevent typos.
39
permissions: ['ADMINISTRATOR'],
40
41
// How long the user needs to wait before using this command again.
42
// This string is in the "{DURATION}{DURATION TYPE}" format with the following:
43
// s = seconds, m = minutes, h = hours, and d = days.
44
// For cooldowns 5 minutes or more it is highly encouraged to provide a
45
// database connection URI to WOKCommands (see the "databases" section)
46
// as those cooldowns will be stored in that database. This is to protect
47
// you if the bot were to restart and lose all in-memory countdown data.
48
// Global cooldowns are a per-guild system and require a minimum duration of
49
// 1 minute to use. This property uses the same format as per-user cooldowns.
50
cooldown: '60s',
51
globalCooldown: '10m',
52
53
// Hides this command from the built-in help menu. Admins bypass this.
54
hidden: false,
55
56
// Forces this command to only be runnable from whitelisted user IDs.
57
// You can define these IDs in the "options" object passed to the constructor.
58
// For more information see the "Options object" page of the documentation.
59
ownerOnly: false,
60
61
// Forces this command to only be runnable from whitelisted guild IDs.
62
// You can define these IDs in the "options" object passed to the constructor.
63
// For more information see the "Options object" page of the documentation.
64
testOnly: false,
65
66
// Forces this command to only be ran in guilds rather than DMs and guilds.
67
guildOnly: false,
68
69
// Sets this command as a slash command.
70
// Can be the string 'both' as well for legacy and slash command support.
71
slash: false,
72
73
// What options are used for slash commands
74
options: [],
75
76
// Invoked whenever an error occurs within one of your commands.
77
error: ({
78
error, // A specific string for what type of command occurred. See https://docs.wornoffkeys.com/commands/handling-command-errors
79
command, // The name of the command that had an error
80
message, // The Discord.JS message object
81
info // Additional information if needed
82
}) => {},
83
84
// The function that is invoked whenever the command is ran by a user.
85
// An object is passed in as an argument that provides additional data.
86
// You can destructure any properties you need like so:
87
callback: ({
88
guild, // The guild where the command was sent
89
member, // The member who ran the command
90
user, // The user who ran the command
91
message, // The DJS message object
92
channel, // The DJS channel object
93
args, // An array of arguments without the command prefix/name
94
text, // A joined string of the above arguments
95
client, // Your bot's client object
96
prefix, // The prefix used to run this command
97
instance, // Your WOKCommands instance
98
interaction // The interaction for slash commands
99
}) => {}
100
}
Copied!
1
import { ICommand } from 'wokcommands'
2
3
export default {
4
// The primary name of the command.
5
// If omitted the name of the file will take it's place.
6
name: 'ping',
7
8
// Alternative aliases, can be a string or an array of strings.
9
// Alternative property names are "commands" or "names".
10
aliases: ['p'],
11
12
// The name and description of the category for the command.
13
// Used in the built-in help menu.
14
category: 'Fun & Games',
15
description: 'Replies with "Pong!"',
16
17
// The correct arguments to use for this command.
18
// Displayed when the number of arguments is incorrect
19
// from "minArgs" and "maxArgs".
20
// Typically required arguments should be surrounded with < and >
21
// and optional arguments should be surrounded with [ and ].
22
// For slash commands this string should be lower case and one word
23
expectedArgs: '',
24
25
// The minimum and maximum amount of arguments.
26
// Tells WOKCommands when to send the correct usage of this command.
27
// Setting maxArgs to -1 (the default) will allow any number of arguments.
28
minArgs: 0,
29
maxArgs: 0,
30
31
// The full syntax error, customizable per command.
32
// You can use "{PREFIX}" in this string to specify the current prefix
33
// for the guild where the command was sent.
34
// You can use "{ARGUMENTS}" in this string to specify the correct arguments.
35
syntaxError: {
36
'english': 'Incorrect syntax! Use `{PREFIX}`ping {ARGUMENTS}'
37
},
38
39
// What Discord permissions the user needs to run the command.
40
// Note that invalid permissions will throw an error to prevent typos.
41
permissions: ['ADMINISTRATOR'],
42
43
// How long the user needs to wait before using this command again.
44
// This string is in the "{DURATION}{DURATION TYPE}" format with the following:
45
// s = seconds, m = minutes, h = hours, and d = days.
46
// For cooldowns 5 minutes or more it is highly encouraged to provide a
47
// database connection URI to WOKCommands (see the "databases" section)
48
// as those cooldowns will be stored in that database. This is to protect
49
// you if the bot were to restart and lose all in-memory countdown data.
50
// Global cooldowns are a per-guild system and require a minimum duration of
51
// 1 minute to use. This property uses the same format as per-user cooldowns.
52
cooldown: '60s',
53
globalCooldown: '10m',
54
55
// Hides this command from the built-in help menu. Admins bypass this.
56
hidden: false,
57
58
// Forces this command to only be runnable from whitelisted user IDs.
59
// You can define these IDs in the "options" object passed to the constructor.
60
// For more information see the "Options object" page of the documentation.
61
ownerOnly: false,
62
63
// Forces this command to only be runnable from whitelisted guild IDs.
64
// You can define these IDs in the "options" object passed to the constructor.
65
// For more information see the "Options object" page of the documentation.
66
testOnly: false,
67
68
// Forces this command to only be ran in guilds rather than DMs and guilds.
69
guildOnly: false,
70
71
// Sets this command as a slash command.
72
// Can be the string 'both' as well for legacy and slash command support.
73
slash: false,
74
75
// What options are used for slash commands
76
options: [],
77
78
// Invoked whenever an error occurs within one of your commands.
79
error: ({
80
error, // A specific string for what type of command occurred. See https://docs.wornoffkeys.com/commands/handling-command-errors
81
command, // The name of the command that had an error
82
message, // The Discord.JS message object
83
info // Additional information if needed
84
}) => {},
85
86
// The function that is invoked whenever the command is ran by a user.
87
// An object is passed in as an argument that provides additional data.
88
// You can destructure any properties you need like so:
89
callback: ({
90
message, // The DJS message object
91
channel, // The DJS channel object
92
args, // An array of arguments without the command prefix/name
93
text, // A joined string of the above arguments
94
client, // Your bot's client object
95
prefix, // The prefix used to run this command
96
instance, // Your WOKCommands instance
97
interaction // The interaction for slash commands
98
}) => {}
99
} as ICommand
Copied!

Examples of each property

Full examples of each property in action can be found in the same documentation category as this one.