Discord Api 必须向客户提供有效意图,但代码不起作用

发布于 2025-01-10 00:19:41 字数 543 浏览 3 评论 0原文

我为我的discord.js 机器人设置了

const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });

但现在我只收到错误消息:

未捕获的 c:\Users\niko\Documents\bot\receptionist\index.js:8

我的 index.js 中的第 8 行是这样的:

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

I set up the

const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });

for my discord.js bot.

But now I just get the error message:

Uncaught c:\Users\niko\Documents\bot\receptionist\index.js:8

The line 8 in my index.js is this:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

许一世地老天荒 2025-01-17 00:19:41

删除代码的第一行,其中指出:

  
 const Discord = require('discord.js')

并删除以下代码的第三行:

const client= new Discord.Client()

因为您在声明后使用以下意图声明客户端
前缀
并且还删除

const bot = client

remove the first line of the code which states:

  
 const Discord = require('discord.js')

and also delete the third line of the code which follows :

const client= new Discord.Client()

because you're declaring the client with the intents below after declaring the
prefix.
And also delete

const bot = client
娇纵 2025-01-17 00:19:41
const { Client, Intents, MessageEmbed, Presence, Collection, Interaction } = require ('discord.js');

const client = new Client({
    intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES]
});
const { Client, Intents, MessageEmbed, Presence, Collection, Interaction } = require ('discord.js');

const client = new Client({
    intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES]
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文