简体   繁体   中英

Discord bot not responding to command javascript

I have been trying to make a Discord bot that responds to the user when they ask for help. Sadly I can't seem to get the bot to work. I am using Discord.JS on Node.JS. Any help would be welcome.

const Discord = require('discord.js');

const bot = new Discord.Client();

const token = '[token removed]';

const PREFIX = '!';

bot.on('ready', () => {
   console.log('K08 Help Bot is online!');
})

bot.on('message', message=>{

let args = message.content.substring(PREFIX.lenght).split(" ");

switch(args[0]){
    case 'help':
        message.reply('HELLO');
    break;
}

})

bot.login(token);

This might be the issue: let args = message.content.substring(PREFIX.lenght).split(" "); - length is mistyped as lenght

On a side note: I've submitted an edit to hide your token in this question. For security, you should never share your token; it would allow someone to take over your bot!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM