Keith Gracshel
Keith Gracshel

Reputation: 19

Discord.js user.bot is not defined?

const Discord = require('discord.js');
const client = new Discord.Client();

client.on('ready', () => {
    console.log('Succesfully contacted the server.');
});

client.on('message', message => {
    if (!user.bot) {
        message.delete()
           .then(message.reply('nope.'));
    }
});



client.login('Nope');

When I say something in discord chat I get the error in the console "ReferenceError: user is not defined."

Upvotes: 0

Views: 4597

Answers (1)

Kae
Kae

Reputation: 638

You're getting the error ReferenceError: user is not defined. because you haven't defined user, surprisingly enough.

client.on('message', message => {
    let user = message.author;
    if (!user.bot) {
        message.delete()
           .then(message.reply('nope.'));
    }
});

Upvotes: 2

Related Questions