Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead. discord.gateway.WebSocketClosure: During handling of the above exception, another exception occurred: discord.errors.ConnectionClosed: Shard ID None WebSocket closed with 4014 During handling of the above exception, another exception occurred: File "C:\Users\Administrator\Desktop\examples\pullDiscord.py", line 13, in <module> client.run('MTExNDA3NDUzMDE1NjEzMDMzNQ.GFKaeX.PVshsn-1qzFCqVBK6RU865CvKld_SUl1f8mP6g') # 将YOUR_BOT_TOKEN替换为您的Discord bot的令牌 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
时间: 2023-11-13 09:54:07 浏览: 397
discord-token-login:电子应用程序以简单的方式登录到 Discord 令牌
这个异常是因为你的 bot 请求了一些敏感的信息,如成员列表、消息内容等,而这些信息需要在 Discord 开发者门户中明确地启用。
你需要在 Discord 开发者门户中进行以下操作:
1. 进入你的应用页面;
2. 点击左侧的“Bot”选项卡;
3. 在“Privileged Gateway Intents”部分,启用你需要的敏感信息。
例如,如果你的 bot 需要访问成员列表和消息内容,就需要启用以下两个 Intent:
- SERVER_MEMBERS (用于访问成员列表)
- GUILD_MESSAGES (用于访问消息内容)
如果你不需要访问这些敏感信息,也可以将它们禁用。
启用或禁用 Intent 后,别忘了在代码中显式声明它们。例如,如果你启用了 SERVER_MEMBERS Intent,你需要将以下代码添加到你的 bot 初始化代码中:
```python
intents = discord.Intents.default()
intents.members = True # 启用 SERVER_MEMBERS Intent
client = discord.Client(intents=intents)
```
如果你禁用了某个 Intent,就不需要在代码中声明它了。
阅读全文