visual-studio-code - Visual Studio 代码中的 Discord 未定义错误。我可以做些什么来修复我的代码?
问题描述
基本上机器人不会打开,每次我进入 node 。进入终端我得到这个错误:ReferenceError: discord is not defined at Object. (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我有一个代码截图的链接,我在这里复制并粘贴了代码。在屏幕截图中,被屏蔽的区域是我的令牌,我将输入令牌放在这里令牌应该去的地方。在实际代码中,插入了正确的令牌。
解决方案
var Discord = require('discord.js'); 确保在 require 中添加两个 '
推荐阅读
- r - 创建多个数据框
- autohotkey - 如何一个接一个地按住3个键
- c - 从字符串中删除所有不是字母的字符并将单词的每个第一个字母更改为大写字母
- spring - Repository.save() 不保留 CascadeType = all 的实体
- kubernetes - 如何使用内部网络设置 k8s IP?
- javascript - 编辑 div 内容未按预期工作 React
- c# - Asp .Net MVC 中枚举的 Html 助手
- javascript - 在 Angular 聊天组件中使用 apollos subscribeToMore 方法进行订阅时,未处理的 GraphQL 订阅错误
- r - 错误:不支持`dim<-.haven_labelled()`
- javascript - 如何阻止事件触发两次?