简体   繁体   English

没有定义Discord.js user.bot?

[英]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." 当我在不和谐聊天中说些什么时,在控制台中出现错误“ ReferenceError:未定义用户”。

You're getting the error ReferenceError: user is not defined. 您收到错误ReferenceError: user is not defined. because you haven't defined user , surprisingly enough. 因为您还没有定义user ,这令人惊讶。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM