【发布时间】:2021-03-16 14:12:18
【问题描述】:
这是代码:
@bot.event
async def on_ready():
print('We have logged in as {0.user}'.format(bot))
moji = await bot.get_channel(775355712271941647).send("react to get banana")
await moji.add_reaction(emoji='????')
@bot.event
async def on_reaction_add(reaction, user):
if reaction.emoji == "????":
role = discord.utils.get(user.guild.roles, name="banana")
await user.add_role(role)
这是错误:
AttributeError: 'Member' object has no attribute 'add_role'
我到处搜索,但每个答案都告诉我做user.add_role。我也查了文档,没找到。请帮忙。哦,还有,client.add_role(user, name) 也不起作用
【问题讨论】:
-
await user.add_role(role) > 改成await user.add_roles(role)
-
@Sofia 谢谢,它解决了我的问题,哈哈
标签: python-3.x discord.py roles