2017-12-27 157 views
0
const Discord = require('discord.js'); 
const testBot = new Discord.Client(); 
const config = require("./config.json"); 
const args = message.content.slice(prefix.length).trim().split(/ +/g); 
const command = args.shift().toLowerCase(); 


testBot.on("message", (message) => { 

    if(command === 'help') { 
     message.channel.send('ok'); 
     } else 
     if (command === 'hey') { 
     message.channel.send('yes?'); 
     } 

}); 

testBot.on('ready',() => { 
    console.log('I am ready!'); 
}) 


testBot.login("Secret"); 

我是一个node.js初学者。Discord.js消息未定义

错误是这样的。 'ReferenceError:消息未定义'我该如何解决?

谢谢。

回答

0

我想这是因为你可以像这样的东西试试你的可变信息尚未

声明?

const Discord = require('discord.js'); 
const testBot = new Discord.Client(); 
const config = require("./config.json"); 

testBot.on("message", (message) => { 
    const args = message.content.slice(prefix.length).trim().split(/ +/g); 
    const command = args.shift().toLowerCase(); 
    if(command === 'help') { 
     message.channel.send('ok'); 
     } else 
     if (command === 'hey') { 
     message.channel.send('yes?'); 
     } 
}); 

testBot.on('ready',() => { 
    console.log('I am ready!'); 
}) 


testBot.login("Secret"); 

希望它有帮助。