Java Discord API 加入事件

huangapple go评论118阅读模式
英文:

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

JDA故障排除指南

我收到了CloseCode(4014 / 不允许的意图...)。

这意味着您尝试在应用程序仪表板中未启用的情况下使用GatewayIntent.GUILD_MEMBERS或GatewayIntent.GUILD_PRESENCES。要使用这些特权意图,您首先必须启用它们。

  1. 打开应用程序仪表板
  2. 选择您的机器人应用程序
  3. 打开"Bot"选项卡
  4. 在特权网关意图部分,根据您的需求启用"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.

  1. Open the application dashboard
  2. Select your bot application
  3. Open the Bot tab
  4. 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.

huangapple
  • 本文由 发表于 2020年9月9日 01:07:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/63798536.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定