It does not work properly and gives errors, Even when I use the exact code of the example:
C:\Users\user\Desktop\bot\commands\ping.ts:20
if (error === CommandErrors.COMMAND_DISABLED) {
^
TypeError: Cannot read properties of undefined (reading 'COMMAND_DISABLED')
at error (C:\Users\user\Desktop\bot\commands\ping.ts:20:33)
at module.exports (C:\Users\user\Desktop\bot\node_modules\wokcommands\dist\command-checks\is-enabled.js:12:9)
at Client.<anonymous> (C:\Users\user\Desktop\bot\node_modules\wokcommands\dist\CommandHandler.js:119:33)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
[nodemon] app crashed - waiting for file changes before starting...
Here is the code:
import { MessageEmbed } from "discord.js";
import { ICommand, CommandErrors } from "wokcommands";
export default {
// Best practice for the built-in help menu
category: "Testing",
description: 'Replies with "Pong!"',
testOnly: true,
slash: "both",
// Invoked when the command is actually ran
callback: ({ message }) => {
message.reply({
content: "Pong!",
});
},
// Invoked when there is an error when running this command
error: ({ error, command, message, info }) => {
// "error" holds one of the strings mentioned in the above list
if (error === CommandErrors.COMMAND_DISABLED) {
// For example we can now create and send a custom embed
const embed = new MessageEmbed().setTitle("Command disabled").setColor(0xff0000);
message.reply({
embeds: [embed],
});
}
},
} as ICommand;
It does not work properly and gives errors, Even when I use the exact code of the example:
Here is the code:
https://docs.wornoffkeys.com/commands/handling-command-errors