[英]how can i get the id of an emoji in reaction?
我试图在消息的反应中获取表情符号的 ID,但我不知道该怎么做。
@client.event
async def on_message(message):
channal = client.get_channel(825523364844142601)
embeds = message.embeds
for embed in embeds:
if embed.author.name in wishlist:
reaction = get(message.reactions)
print(reaction)
await channal.send("yes")
else:
await channal.send("false")
背景:我在玩一个不和谐的游戏,机器人发送一个带有角色名称的嵌入,在这个嵌入上,机器人会自动添加一个反应。 我想要的是获取机器人反应的 id 并使用 id 添加相同的
您无需再次获取表情符号即可做出反应。 您可以添加来自 Emoji class 的反应。
我还建议稍等片刻,然后再次收到消息,因为消息 object 不会立即做出反应。
@client.event
async def on_message(message):
channal = client.get_channel(825523364844142601)
embeds = message.embeds
for embed in embeds:
if embed.author.name in wishlist:
await asyncio.sleep(1.0) # Give time for reaction to update on cache
message = await message.channel.fetch_message(message.id) # Update message object
reaction = message.reactions[0] # Get first reaction of a message
emoji = reaction.emoji
emoji_id = emoji.id
await message.add_reaction(emoji) # You can just add with emoji, you don't need to get emoji again
await channal.send("yes")
else:
await channal.send("false")
参见discord.Reaction
.反应 object。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.