Then create a "commands" folder where you can create a "ping.js" file with the following contents:
ping.js
const { CommandType } =require("wokcommands");module.exports= {// Required for slash commands description:"Ping pong command",// Create a legacy and slash command type:CommandType.BOTH,// Invoked when a user runs the ping commandcallback: () => {// Return the same object you would use in// message.reply// or// interaction.reply// WOKCommands will reply to the message or the interaction// depending on how the user ran the command (legacy vs slash)return { content:"Pong!", } },}
ping.ts
import { CommandObject, CommandType } from"wokcommands";exportdefault {// Required for slash commands description:"Ping pong command",// Create a legacy and slash command type:CommandType.BOTH,// Invoked when a user runs the ping commandcallback: () => {// Return the same object you would use in// message.reply// or// interaction.reply// WOKCommands will reply to the message or the interaction// depending on how the user ran the command (legacy vs slash)return { content:"Pong!", } },} asCommandObject
After inviting your bot to a Discord server and running !ping ("!" is the default command prefix) or /ping, your bot should reply with Pong!.