Message is not defined

Well, never thought I would be the one asking a discord bot question!

I am currently working on a bot when I got this error:

/home/pi/discord_bot/Bot/server.js:42
      if(db.has(message.guild.id)){
                ^

ReferenceError: message is not defined

I searched it up and everyone seems to have a different answer.

Here is a snippet of my code:

var rep = "!report";

  if(msg.content.includes(rep) !== false){
        console.log("Report detected, phase one.");                                                                         var id = msg.content.substr(7);
     console.log("Passed async");
      if(db.has(message.guild.id)){
        if(!message.guild.member(message.author).hasPermission('MANAGE_MESSAGES')){
          msg.reply("We are sorry, but you do not have the permisions to do this.")
        }

There is a msg in msg.content.includes(rep) on lines 3 and 8 but there is also a message in lines 5 and 6.

3 Likes

Yeah, I think you should replace the messages with msg.

1 Like

If you did it in glitch take a shortcut by hitting Ctrl + Alt + F then typing in message and then type in msg to replace all of the words that match it in the file.

1 Like

Let’s be honest, we have all done this at least once.

1 Like

Well, you are right. We need to give ourselves a break, though.