WOKCommands
Search…
Replying to commands
Sometimes you will want to reply to a message the same way you will reply to an interaction. Instead of manually replying to the correct method, WOKCommands makes it easy by returning from the callback function. You can return a string, a Message Embed, or a reply object:
JavaScript
TypeScript
ping.js
1
module.exports = {
2
category: 'Testing',
3
description: 'Replies with pong', // Required for slash commands
4
5
slash: 'both', // Create both a slash and legacy command
6
testOnly: true, // Only register a slash command for the testing guilds
7
8
callback: ({ message, interaction }) => {
9
// OPTION 1: Replying to each method manually
10
const reply = 'Pong!'
11
12
if (message) {
13
message.reply({
14
content: reply
15
})
16
}
17
18
if (interaction) {
19
interaction.reply({
20
content: reply
21
})
22
}
23
24
// OPTION 2: Replying with a string as "content"
25
return reply
26
27
// OPTION 3: Replying with a reply object that will be used
28
// in message.reply() or interaction.reply()
29
return {
30
content: reply,
31
ephemeral: true,
32
}
33
},
34
}
Copied!
ping.ts
1
import { ICommand } from 'wokcommands'
2
3
export default {
4
category: 'Testing',
5
description: 'Replies with pong', // Required for slash commands
6
7
slash: 'both', // Create both a slash and legacy command
8
testOnly: true, // Only register a slash command for the testing guilds
9
10
callback: ({ message, interaction }) => {
11
// OPTION 1: Replying to each method manually
12
const reply = 'Pong!'
13
14
if (message) {
15
message.reply({
16
content: reply
17
})
18
}
19
20
if (interaction) {
21
interaction.reply({
22
content: reply
23
})
24
}
25
26
// OPTION 2: Replying with a string as "content"
27
return reply
28
29
// OPTION 3: Replying with a reply object that will be used
30
// in message.reply() or interaction.reply()
31
return {
32
content: reply,
33
ephemeral: true,
34
}
35
},
36
} as ICommand
Copied!
Copy link