Discord.js user.bot未定义?

时间:2017-08-19 00:48:01

标签: javascript discord

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');

当我在不和谐聊天中说些什么时,我在控制台中收到错误" ReferenceError:未定义用户。"

1 个答案:

答案 0 :(得分:1)

您收到错误ReferenceError: user is not defined.,因为您还没有明确定义user

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