Tut*_*tez 1 python-3.x discord discord.py
我正在进行机器人不和谐,我希望我的机器人在删除消息之前计算对消息的反应数量
@client.event
async def on_raw_reaction_add(payload):
if payload.channel_id == 614467771866021944:
if payload.emoji.name == "":
# if number of reactions > 4:
# delete the message
Run Code Online (Sandbox Code Playgroud)
您需要使用有效负载中的 ids 来获取Message消息的对象,然后检查count相应Reactionfrom的属性Message.reactions:
from discord.utils import get
@client.event
async def on_raw_reaction_add(payload):
if payload.channel_id == 614467771866021944:
if payload.emoji.name == "":
channel = client.get_channel(payload.channel_id)
message = await channel.fetch_message(payload.message_id)
reaction = get(message.reactions, emoji=payload.emoji.name)
if reaction and reaction.count > 4:
await message.delete()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14450 次 |
| 最近记录: |