WOKCommands
Search
K
Comment on page

Command initialization method

Some commands may require you to run code when they are loaded. You can use the init() method within your command to handle this type of functionality:
JavaScript
TypeScript
ping.js
const { CommandType } = require("wokcommands");
module.exports = {
description: "Ping pong command",
type: CommandType.BOTH,
init: (client, instance) => {
console.log("Ping command has been loaded");
},
callback: () => {
return {
content: "Pong!",
};
},
};
ping.ts
import { Client } from "discord.js";
import WOKCommands, { CommandObject, CommandType } from "wokcommands";
export default {
description: "Ping pong command",
type: CommandType.BOTH,
init: (client: Client, instance: WOKCommands) => {
console.log("Ping command has been loaded");
},
callback: () => {
return {
content: "Pong!",
};
},
} as CommandObject;