简体   繁体   English

为什么是“节点。” 当我在 cmd 中输入时总是抛出错误?

[英]Why does 'node .' always throw an error when I type it in cmd?

I just started with my first discord bot and I am really stuck with this problem.我刚开始使用我的第一个 discord 机器人,我真的被这个问题困住了。 Everytime I write 'node.'每次我写“节点”。 it gives an error stating this 'throw new TypeError('CLIENT_MISSING_INTENTS');'can anybody tell me what I need to fix?它给出了一个错误,说明这个'throw new TypeError('CLIENT_MISSING_INTENTS');'谁能告诉我我需要修复什么?

That's all the code I got:这就是我得到的所有代码:

const Discord = require('discord.js');
const bot = new Discord.Client();
const token = 'myToken';

bot.on('ready', () =>{
    console.log('This bot is online!');
})

bot.login(token);

picture of the error错误的图片

You need to pass the intents field when initializing the Client.您需要在初始化客户端时传递intents字段。 Read more about intents here 在此处阅读有关意图的更多信息

const bot = new Discord.Client({ intents: [Discord.Intents.FLAGS.GUILDS, Discord.Intents.FLAGS.GUILD_MESSAGES] });

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

相关问题 当我尝试将音频连接到双二阶滤波器时,为什么 JS 会抛出类型错误? - Why does JS throw a Type Error when I try to connect audio to a Biquad Filter? 当 function 参数类型不匹配时,为什么 TypeScript 不抛出错误? - Why does TypeScript not throw an error when the function argument type is mismatched? 如果密码错误,Node 的加密解密是否总是抛出错误? - Does Node's crypto decipher always throw an error if the password is wrong? 为什么 Jest 不应该抛出错误? - Why does Jest throw an error when it should not? 为什么https.Agent在通过node-http-proxy进行代理时会抛出一个解析错误? - Why does https.Agent throw a parse error when proxying via node-http-proxy? 为什么这会在带有 --harmony 的 Node.js 中引发错误? - Why does this throw an error in Node.js with --harmony? 为什么当我尝试运行这个简单的 React 组件时会抛出错误? - Why does this simple React component throw an error when I try to run it? 当我尝试为iframe src属性构建URL时,为什么AngularJS会抛出错误? - Why does AngularJS throw an error when I try to build a URL for an iframe src attribute? 为什么当我将 JSX 元素放入其中时,此属性会引发错误? - Why does this property throw a error when I put JSX element inside? 在 Node 中使用 Multiparty 时,如何正确抛出错误? - When using Multiparty in Node, how do I properly throw an error?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM