我想制作一个机器人,当成员对消息做出反应时,它会为成员添加角色。@client.eventasync def on_raw_reaction_add(reaction, member: discord.Member): ChID = '678640775747076097' if reaction.message != ChID: await member.send("Nope") return else: if member.reaction.emoji == ":white_check_mark:": Role = discord.utils.get(member.server.roles, id="672473925053055036") await client.add_roles(member, Role) await user.send("Success")当我回复消息时,出现以下错误:TypeError: on_raw_reaction_add() missing 1 required positional argument: 'member'
1 回答
一只萌萌小番薯
TA贡献1795条经验 获得超7个赞
这是因为on_raw_reaction_add函数不应该期望接收member参数,而只能接收payload: discord.RawReactionActionEvent参数。
尝试这个:
@client.event
async def on_raw_reaction_add(payload):
reaction_message_id = payload.message_id
member = payload.member
ChID = '678640775747076097'
if reaction_message_id != ChID:
await member.send("Nope")
return
else:
if member.reaction.emoji == ":white_check_mark:":
Role = discord.utils.get(member.server.roles, id="672473925053055036")
await client.add_roles(member, Role)
await user.send("Success")
因为它是有关如何从有效负载中获取所需属性的示例。
添加回答
举报
0/150
提交
取消