ReferenceError: message is not defined

Im trying to make some commands but i keep getting this error
ReferenceError: message is not defined

The code that i put in is
onst Discord = require (‘discord.js’);

const client = new Discord.Client();

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

console.log ('JorisAndCoStudiosBot is now Online!')

});

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

const command = args.shift().toLowerCase();

if(command === ‘ping’){

message.channel.send('pong!');

};

Can someone help?

Hi, you need to wrap your message code in a message event handler like this:

client.on("message", message => {
const args = message.content.slice(prefix.length).split(/ +/);

const command = args.shift().toLowerCase();

if(command === ‘ping’){

message.channel.send('pong!');
};
});
1 Like

it keeps saying invalid character

Hi. It looks like you are new to the Programming.
I recommend you to Learn first: >