Python 为什么我的bot.get_user(user_id)在discord.py中不返回我?

Python 为什么我的bot.get_user(user_id)在discord.py中不返回我?,python,discord.py,Python,Discord.py,我正在用python编写一个discord机器人,我遇到了一个问题。 这是我的密码: import discord from discord.utils import get from discord.ext import commands #Créer une instance du bot bot = commands.Bot(command_prefix='!') #Donner le jeton pour l'identifier jeton = "Here is the

我正在用python编写一个discord机器人,我遇到了一个问题。 这是我的密码:

import discord
from discord.utils import get
from discord.ext import commands

#Créer une instance du bot
bot = commands.Bot(command_prefix='!')

#Donner le jeton pour l'identifier
jeton = "Here is the token"

#Detecter quand le bot est allumé
@bot.event
async def on_ready():
    print("Bot Prêt")
    await bot.change_presence(status=discord.Status.idle, activity=discord.Game('Hello World !'))
    print("Bonjour")

@bot.event
async def on_raw_reaction_add(payload):

    user_id = payload.user_id
    emoji = payload.emoji.name
    canal = payload.channel_id
    message = payload.message_id
    membre = bot.get_user(user_id)

    if canal == 826772563715555358 and message == 826773226675896340 and emoji == "python":
        print("Grade ajouté !")
        print(membre)


@bot.event
async def on_raw_reaction_remove(payload):

    emoji = payload.emoji.name
    canal = payload.channel_id
    message = payload.message_id

    if canal == 826772563715555358 and message == 826773226675896340 and emoji == "python":
        print("Grade enlevé !")



#Créer la commande !regles
@bot.command()
async def regles(ctx):
    await ctx.send("Les règles : \n1. Pas d'insulte \n2. Pas de double compte \n3. Pas de spam")

#Créer la commande !bienvenue
@bot.command()
async def bienvenue(ctx, member: discord.Member):
    pseudo = member.mention
    await ctx.send(f"Bienvenue {pseudo} ! ")

#tester l'erreur de la commande
@bienvenue.error
async def on_command_error(ctx, error):
    if isinstance(error, commands.MissingRequiredArgument):
        await ctx.send("Veuillez préciser une personne")


#Connecter le bot
bot.run(jeton)

但是在on_raw_reaction_add中,当我打印成员时,它不会返回任何结果。为什么?为了获得它,我使用bot.get\u user(user\u id)。 多谢各位


PS:很抱歉用法语输入变量和注释,因为我是法国人,通常情况下,事件返回
none
而不是有效成员的最常见原因是由于未编辑的成员意图

需要访问成员的事件必须要求启用该成员。 可以从Discord developer portal启用意图,从那里您只需确保已在“Bot”类别的意图中启用成员。然后,您需要在定义bot或客户端的部分中定义并使用bot代码中的意图:

在代码中使用以下代码定义和访问Discord的成员意图

intents=discord.intents.default()
intents.members=True
bot=commands.bot(命令前缀='!',意图=意图)

确保用上面的代码替换
bot=commands.bot(command_prefix='!')

我在文档中找不到答案,那么我应该在我的代码中写些什么呢?开始时,用意图加上bot替换bot=commands.bot(command_prefix='!')。这是怎么回事?还是不起作用。我有:
RuntimeError:事件循环已关闭