A
A
Alexander2020-05-29 19:28:19
JavaScript
Alexander, 2020-05-29 19:28:19

How to make Discord bot read multiple commands in one file?

Good evening, the structure for each new command I have is this:

const Discord = module.require("discord.js");
const fs = require("fs");
module.exports.run = async (robot,message,args) => {
     // содержимое 
};
module.exports.help = {
    name: "название_команды"
};

This structure can only read one command, which is in module.exports.help = { ... , but if I use if (message.content == .. ) , and I enter a command there that does not match module.exports.help - it is not perceived by the bot. How to fix this problem, please tell me.
Thanks in advance to everyone for the replies.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denisca Gareev, 2020-05-29
@Alexandre888

I suggest you just do this:

switch(command){
case "help":
    // code
break;
default:
    // Command is undefined
break;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question