英文:
Java Discord API Join Event
问题
我是新手使用Java Discord API,尝试在用户加入时运行函数。根据javadocs,您需要启用GatewayIntent GUILD_MEMBERS,它默认处于禁用状态,但当我运行bot时使用JDABuilder#enableIntents(GatewayIntent.GUILD_MEMBERS);时,我收到了一个错误代码。
CloseCode(4014 / 不允许的意图。您的机器人可能无法请求特权意图,如GUILD_PRESENCES或GUILD_MEMBERS。)
英文:
I'm new to the Java Discord API, and I'm trying to run functions when users join. According to the javadocs, you need to enable the GatewayIntent GUILD_MEMBERS, which is disabled by default, but when I run the bot with JDABuilder#enableIntents(GatewayIntent.GUILD_MEMBERS); I get an error code.
CloseCode(4014 / Disallowed intents. Your bot might not be eligible to request a privileged intent such as GUILD_PRESENCES or GUILD_MEMBERS.)
答案1
得分: 4
我收到了CloseCode(4014 / 不允许的意图...)。
这意味着您尝试在应用程序仪表板中未启用的情况下使用GatewayIntent.GUILD_MEMBERS或GatewayIntent.GUILD_PRESENCES。要使用这些特权意图,您首先必须启用它们。
- 打开应用程序仪表板
- 选择您的机器人应用程序
- 打开"Bot"选项卡
- 在特权网关意图部分,根据您的需求启用"SERVER MEMBERS INTENT"或"PRESENCE INTENT"。
如果您使用这些意图,您的机器人在服务器上的数量将限制为100个。如果要允许机器人在使用此意图的同时加入更多服务器,您需要验证您的机器人。当机器人加入至少75个服务器时,此选项将在应用程序仪表板中可用。
英文:
From the JDA Troubleshooting Guide:
I'm getting CloseCode(4014 / Disallowed intents...)
This means you tried to use GatewayIntent.GUILD_MEMBERS or GatewayIntent.GUILD_PRESENCES without enabling it in your application dashboard. To use these privileged intents you first have to enable them.
- Open the application dashboard
- Select your bot application
- Open the Bot tab
- Under the Privileged Gateway Intents section, enable either SERVER MEMBERS INTENT or PRESENCE INTENT depending on your needs.
If you use these intents you are limited to 100 guilds on your bot. To allow the bot to join more guilds while using this intent you have to verify your bot. This will be available in your application dashboard when the bot joins at least 75 guilds.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论