python - Discord.py 反应角色和 DMing 反应堆
问题描述
我希望机器人给对消息做出反应的人一个角色。机器人还应该 dm 做出反应的人。先感谢您。
这是我的代码:
@client.event
async def on_raw_reaction_add(payload):
if payload.emoji.name == "" and payload.user_id != client.user.id:
embed = discord.Embed(
description = "**You are now a Member of Resellheads!** ",
color=16769251)
channel = client.get_channel(payload.channel_id)
message = await channel.fetch_message(payload.message_id)
await message.channel.send(embed=embed)
await message.channel.send("<@&776929011757613057> Please add the role 'Member'!")
解决方案
在您的情况下无需使用原始反应添加,因为您仅使用它来发送命令。
@client.event
async def on_reaction_add(reaction, user):
if reaction.emoji == '':
await user.send("You are now a member of your community!")
if reaction.emoji == '':
await user.send("Sad to see you leave")
这将简单地发送任何对您的命令/消息表示赞同或反对的用户。
在这种情况下,如果您的机器人是私人或小型机器人,这应该可以使用,但是变得更大并且在更多服务器中,您应该使用反应等待,等待作者发送命令后他指定的反应。您的问题中没有详细解释,但我希望这会有所帮助
推荐阅读
- vend - VEND API 库存未显示正确的库存值
- javascript - 使用访问/刷新令牌和 axios(cookies?本地存储?)进行安全身份验证
- startapp - StartAppSDK:展示次数减少,因为 AD_CLOSED_TOO_QUICKLY
- python - python不允许将浮点数分配给nan值
- database-connection - 连接池库的连接队列
- javascript - 如何动态创建 div 并在复选框更改时调整 div
- python - 如何在 pygame 中添加分数?
- r - R中的代理::dist
- python - 如何在python的4维字典中找到最大值
- python - 如何只允许 python 类型中的某些字符?