0

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);
3
  • Have you done some sort of debugging yet ? We cannot know, out of no where, what's wrong here. Please refine your question, by adding what you've already test and what part, exactly is not working. Commented Aug 22, 2020 at 13:35
  • I have debugged the code and there seems to be nothign werong woth ot Commented Aug 22, 2020 at 13:40
  • If there is nothing wrong with it, why are we here ? Commented Aug 22, 2020 at 13:42

1 Answer 1

2

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!

Sign up to request clarification or add additional context in comments.

2 Comments

Hahaha, it's fine! I make those mistakes sometimes ^^
@Mallagua in regards of what DaChickenKing said with your token, you might want to generate a new one. Chances are this one will not be valid anymore. Discord has a very good token leak detection system.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.