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
module.exports = {
category: 'Testing',
description: 'Replies with pong', // Required for slash commands
slash: 'both', // Create both a slash and legacy command
testOnly: true, // Only register a slash command for the testing guilds
callback: ({ message, interaction }) => {
// OPTION 1: Replying to each method manually
const reply = 'Pong!'
if (message) {
message.reply({
content: reply
})
}
if (interaction) {
interaction.reply({
content: reply
})
}
// OPTION 2: Replying with a string as "content"
return reply
// OPTION 3: Replying with a reply object that will be used
// in message.reply() or interaction.reply()
return {
content: reply,
ephemeral: true,
}
},
}
ping.ts
import { ICommand } from 'wokcommands'
export default {
category: 'Testing',
description: 'Replies with pong', // Required for slash commands
slash: 'both', // Create both a slash and legacy command
testOnly: true, // Only register a slash command for the testing guilds
callback: ({ message, interaction }) => {
// OPTION 1: Replying to each method manually
const reply = 'Pong!'
if (message) {
message.reply({
content: reply
})
}
if (interaction) {
interaction.reply({
content: reply
})
}
// OPTION 2: Replying with a string as "content"
return reply
// OPTION 3: Replying with a reply object that will be used
// in message.reply() or interaction.reply()
return {
content: reply,
ephemeral: true,
}
},
} as ICommand
Copy link