2017-12-27 161 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"); 

希望它有幫助。