【发布时间】:2020-07-10 06:47:15
【问题描述】:
我一直致力于在 python 中编写我自己的 discord 机器人,并且我一直在尝试以某种方式实现对特定消息的反应,你会给你一个特定的角色吗?我想出了如何让它工作自定义不和谐表情符号,但我正在努力让它与原生不和谐表情符号一起工作。我知道我应该尝试以某种方式使用表情符号的 unicode,但我就是想不通
#roles for hemisphere and native fruit
#first part - emoji id, second part - role id
#CUSTOM EMOJIS
hemisphere = {693662576936222811:[693663054788821092],
693662585953714256:[693663114914168913]
}
#NATIVE DISCORD EMOJIS
native_fruit = {693711698082660427:[693711520953270293],
693711724024430633:[693711530197516289],
693711811312353330:[693711572312391721],
693711739744813056:[693711538623742042],
693711786582474752:[693711553257799720]
}
hemisphere_id=693914783979667506
native_fruit_id=693914786773205103
#add roles
@bot.event
async def on_raw_reaction_add(reaction):
if reaction.user_id==bot.user.id:
return
if not ((reaction.emoji.id in hemisphere) or (reaction.emoji.id in native_fruit)):
return
guild = await bot.fetch_guild(reaction.guild_id)
user = await guild.fetch_member(reaction.user_id)
#CUSTOM EMOJIS
if reaction.message_id == hemisphere_id:
emojiid = hemisphere.get(reaction.emoji.id)
id =emojiid[0]
await user.add_roles(guild.get_role(id))
#NATIVE DISCORD EMOJIS
elif reaction.message_id == native_fruit_id:
emojiid = native_fruit.get(reaction.emoji.id)
id = emojiid[0]
await user.add_roles(guild.get_role(id))
else:
return
我一般是 python 新手,所以我无法弄清楚如何前进
【问题讨论】:
-
您能否更具体地说明问题是什么?