在\u原始\u反应\u添加客户端.get\u用户(payload.user\u id)上返回无

2024-09-30 18:30:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图让机器人在人们对某个反应做出反应时加入角色,它以前工作得很好,但突然停止了工作

client.get_user(payload.user_id)本应返回用户,但它不返回任何用户,我打印了用户id,它工作了,打印了我自己的id,但当我添加get_用户时,它立即不返回任何用户(我正在使用我自己的id)

我不知道发生了什么,我确定discor.py是最新的更新

下面是相关的代码部分:https://paste.pythondiscord.com/olivohevud.cs

谢谢


Tags: 代码用户pyhttpsclientid角色get
1条回答
网友
1楼 · 发布于 2024-09-30 18:30:06

使用discord.py 1.5.x设置意图对于事件的正常运行是必要的

  1. 转到您的discord开发者门户
  2. 单击您的应用程序
  3. 点击你的机器人
  4. 向下滚动至“Privileged Gateway Intents”,并同时启用这两个选项

将此添加到您的代码中:

intents = discord.Intents.default()

# If you are using client
client = discord.Client(intents=intents)

# If you are using bot
bot = commands.Bot(command_prefix='!', intents=intents)

相关问题 更多 >