WOKCommands
Search…
Required permissions
You may want your commands to only be ran by users who have specific Discord permissions. This is often useful for moderation tools, you would only want your staff members to be able to use that command.
Using WOKCommands you can easily specify what Discord permissions users need to run the command:
JavaScript
TypeScript
ban.js
1
module.exports = {
2
// Best practice for the built-in help menu
3
category: 'Moderation',
4
description: 'Bans a member',
5
6
// For the correct usage of the command
7
expectedArgs: '<target> [reason]',
8
minArgs: 1,
9
10
// Who can use this command
11
// If you provide an incorrect string then WOKCommands will throw an error
12
// This way you don't have to worry about about typos
13
permissions: ['ADMINISTRATOR'],
14
15
// A ban command should not be used in DMs
16
guildOnly: true,
17
18
// Invoked when the command is actually ran
19
callback: ({ message, args }) => {
20
const target = message.mentions.members.first()
21
22
if (!target) {
23
message.reply({
24
content: 'Please tag someone to ban!'
25
})
26
return
27
}
28
29
if (!target.bannable) {
30
message.reply({
31
content: 'This bot does not have the ability to ban that user!'
32
})
33
return
34
}
35
36
// Get the reason of the ban
37
// First remove the @ from the args array
38
args.shift()
39
const reason = args.join(' ')
40
41
target.ban({
42
reason,
43
// How many days of messages to delete
44
// Must be between 0-7
45
days: 5,
46
})
47
48
message.reply({
49
content: `Banned ${target}!`
50
})
51
},
52
}
Copied!
ban.ts
1
export default {
2
// Best practice for the built-in help menu
3
category: 'Moderation',
4
description: 'Bans a member',
5
6
// For the correct usage of the command
7
expectedArgs: '<target> [reason]',
8
minArgs: 1,
9
10
// Who can use this command
11
// If you provide an incorrect string then WOKCommands will throw an error
12
// This way you don't have to worry about about typos
13
permissions: ['ADMINISTRATOR'],
14
15
// A ban command should not be used in DMs
16
guildOnly: true,
17
18
// Invoked when the command is actually ran
19
callback: ({ message, args }) => {
20
const target = message.mentions.members.first()
21
22
if (!target) {
23
message.reply({
24
content: 'Please tag someone to ban!'
25
})
26
return
27
}
28
29
if (!target.bannable) {
30
message.reply({
31
content: 'This bot does not have the ability to ban that user!'
32
})
33
return
34
}
35
36
// Get the reason of the ban
37
// First remove the @ from the args array
38
args.shift()
39
const reason = args.join(' ')
40
41
target.ban({
42
reason,
43
// How many days of messages to delete
44
// Must be between 0-7
45
days: 5,
46
})
47
48
message.reply({
49
content: `Banned ${target}!`
50
})
51
},
52
} as ICommand
Copied!
Copy link