本文介绍了Bot不想在反应中添加角色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望漫游器添加角色,并为那些对消息做出反应的人删除另一个角色.
I want bot to add role and remove another one for those who reacts on message.
@client.event
async def on_raw_reaction_add(payload):
rUnauthorized=payload.member.guild.get_role(672473730114387968)
rMember=payload.member.guild.get_role(672473925053055036)
if payload.message_id==679223445258633216:
if payload.emoji.name=='white_check_mark':
print('Sucess!')
await payload.member.add_roles(rMember)
await payload.member.remove_roles(rUnauthorized)
else:
return
但是当我对该消息做出反应时,什么也没有发生(控制台中也没有任何东西).
But when I am reacting to that message nothing happens(there is no anything in console as well).
推荐答案
我认为您在检查表情符号时犯了一个错误.尝试更换它:
I think you're making a mistake while checking the emoji. Try replacing this:
if payload.emoji.name == 'white_check_mark':
与此:
if str(payload.emoji) == '✅':
替代表情符号,您可以使用Unicode \ u2705
.
Alternative to the emoji, you can use the Unicode \u2705
.
注意:您也可以使用 payload.emoji.name
代替 payload.emoji
.仍然可以.
Note: You can also use payload.emoji.name
instead of payload.emoji
. It'll still work.
这篇关于Bot不想在反应中添加角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!