How do i fix this problem

if(!message.content.startWith(prefix) || return;

The error that comes out is

ReferenceError: message is not defined

The code so far ( not including bot token)
const Discord = require(‘discord.js’);
const client = new Discord.Client();
const PREFIX = ‘,’;

const fs = require(‘fs’);

client.commands = new Discord.Collection();

const commandFiles = fs.readdirSync(’./commands/’).filter(file => file.endsWith(’.js’));
for(const file of commandFiles){
const command = require(./commands/${file});

client.commands.set(, command);


var version = ‘1.0.1’

client.once(‘ready’, () =>{

client.on(‘message’, Message=>{
if(!message.content.startWith(prefix) || return;

const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();

if(command === 'ping'){
    client.commands.get('ping').execute(message, args);
if(command === 'calc'){
    client.commands.get('calc').execute(message, args);



Maybe this could be of use ^^^

1 Like

Hi there @qwertyuiopcoder!
It’s because you defined the message as Message not message. Whenever you use the variable you need to use the capital/same variable name you chose when you defined it.
Hope this helps! :slight_smile: :glitch:
P.S. If this worked please select the Solution button below this message so others can find it. Otherwise, get back in touch!

Variables are case sensitive, meaning you have to make them they same thing.

Here are the steps to fix it:

hit ctrl + alt + f,

then type “Message” and hit enter,

type in “message” and hit enter. You should be good to go!

Thanks, It worked