Discord.js: comand.run is not a function (fixed)

this is my code (event/messageCreate.js)
const client = require("…/index");

client.on(“messageCreate”, async (message) => {

if (

    message.author.bot ||

    !message.guild ||




const [cmd, ...args] = message.content



    .split(/ +/g);

const command = client.commands.get(cmd.toLowerCase()) || client.commands.find(c => c.aliases?.includes(cmd.toLowerCase()));

if (!command) return;

command.run(client, message, args);


It seems like there is no run function on your command object. I’d check the definition and see what has been exported.

BTW you should always try to output the various things to the console so you can inspect what the cmd variable contains and what sort of object command is. It will typically help reveal the issue.

I have no idea what .run is supposed to do.
Can you find a more simple and error-free way to do this?

It is supposed to execute the command but the command object has (probably) not been defined properly. In any case we can’t know until the guy responds.

it is error like that when i use “unban” command.

It has nothing to do with the command you enter and everything to do with the code that is in the command file for the bot. Did you write it? If you copied it perhaps you missed an important line of code.

If it isn’t huge you can post it in a message here. You can also compare it with any other command file you have (if you have more than one) to see if something important is missing.

oh, i know how to fix
change “async execute(client, message, args){”
“run: async (client, message, args, Discord) => {”
in file command Thanks for the reply :smiley: