javascript - 节点。制作不和谐机器人时不工作
问题描述
所以我想做一个不和谐的机器人,当我输入 node 时。进入 CMD 它给了我一个错误。我的代码在下面
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
const client = new Discord.Client();
client.once('ready', () => {
console.log('Better Call Saul!');
});
client.login('The code');
错误:
抛出新的 TypeError('CLIENT_MISSING_INTENTS'); ^ TypeError [CLIENT_MISSING_INTENTS]:必须为客户端提供有效的意图。在 Client._validateOptions (C:\Users\Uzivatel\Desktop\joe\node_modules\←[4mdiscord.js←[24m\src\client\Client.js:544:13) 在新客户端 (C:\Users\Uzivatel\ Desktop\joe\node_modules\←[4mdiscord.js←[24m\src\client\Client.js:73:10) 在对象。(C:\Users\Uzivatel\Desktop\joe\main.js:3:16) ←[90m at Module._compile (node:internal/modules/cjs/loader:1101:14)←[39m ←[90m at Object .Module._extensions..js
解决方案
看起来问题出在这里:
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
const client = new Discord.Client();
只有第一行有效。
推荐阅读
- angular - 角度导航路由数据
- title - 网站标题和标语问题
- reactjs - material-ui Drawer listitem 显示活动项目
- laravel - 如何在没有通知的情况下测试 Laravel 通知?
- kubernetes - Ingress 使用通配符,虽然我没有具体说明
- python - 时间数据 '(datetime.date(2021, 7, 30), )' 与格式 '%Y/%m/%d' 不匹配
- angular - Angular Reactive Forms Select 不显示初始值
- html - 无法使用 CSS Animation 为元素的宽度设置动画
- sql - 如何将一些行合并为一行,并删除其他行?
- html - 如何区分overflow-x-scroll的上div和下div