【发布时间】:2020-11-08 10:15:28
【问题描述】:
基本上机器人不会打开,每次我进入 node 。进入终端我得到这个错误:ReferenceError: discord is not defined 在对象。 (C:\Users\Izzabell\Downloads\discord-bot\index.js:1:23) 在 Module._compile (internal/modules/cjs/loader.js:1138:30) 在 Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10) 在 Module.load (internal/modules/cjs/loader.js:986:32) 在 Function.Module._load (internal/modules/cjs/loader.js:879:14) 在 Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) 在 internal/main/run_main_module.js:17:47
如果有人可以帮忙,这是我使用的屏幕截图和确切代码。
var Discord = require(discord.js);
var bot = new Discord.Client ();
const token = 'Enter token here';
bot.on('ready', () =>{
console.log('This bot is online!');
})
bot.on ('message', msg=>{
if (msg.content === "boomer"){
msg.reply ('Im not a boomer >:(');
}
})
bot.login(token);
[1]:https://i.stack.imgur.com/aidrG.png我有一个代码截图的链接,我在这里复制并粘贴了代码。在屏幕截图中,被屏蔽的区域是我的令牌,我将输入令牌放在这里令牌应该去的地方。在实际代码中插入了正确的令牌。
【问题讨论】: