Discord.py 如何将str()转换为discord.Member?不和谐

Discord.py 如何将str()转换为discord.Member?不和谐,discord.py,Discord.py,文件: 78573462558784356 #那是身份证 异步定义: @bot.event async def on_raw_reaction_add(payload): with open("createteam.txt", "r", encoding = "utf-8") as file: # id is in a file author_id = file.read() #the id in str()

文件: 78573462558784356

#那是身份证

异步定义:

@bot.event
async def on_raw_reaction_add(payload):
    with open("createteam.txt", "r", encoding = "utf-8") as file: # id is in a file
        author_id = file.read() #the id in str()
        author_user = ???author_id.User??? #how to translate a str(id) to discord.user
        author_member = ???author_id.Member??? #how to translate a str(id) to discord.member

1您所需要的只是用户的id

2如果您需要获取变量discord.User,请使用bot.get_User(id)

3如果你需要获得一个变量discord.Member,你可以使用message.guild.get_Member(id)

Where message.guild是发送邮件的服务器


每一次你需要将str()int()或其他东西转换成机器人可以读取的变量时,你需要使用bot.get或guild.get。您可以使用
discord.utils.get()
获取用户

@bot.event
原始反应添加上的异步def(有效负载):
打开(“createteam.txt”、“r”,encoding=“utf-8”)作为文件:
author\u id=file.read()
member=discord.utils.get(payload.message.guild.members,id=int(author\u id))

所以你可以对
成员做任何你想做的事

这个问题是我开始学习discord.py时提出的,但我找不到答案。