【问题标题】:I want to react on a message in discord and then it should send a embed in discord.py我想对 discord 中的消息做出反应,然后它应该发送一个嵌入 discord.py
【发布时间】:2020-12-13 13:36:28
【问题描述】:
if message.content.startswith('/overview'):
    embed = discord.Embed(title='**Overview**', description='This is a Overview for the Service! (easier then the manual methode)', color=16769251)
    embed.add_field(name='Create an Offer:', value='React on ✉️ to Create an own Offer')
    mess = await message.channel.send(embed=embed)
    await mess.add_reaction('✉️')

我用它来发送带有✉️ 的嵌入作为反应。

现在我希望,如果您做出反应,机器人会在同一频道中发送一个新的嵌入。

【问题讨论】:

  • 当您尝试这样做时究竟是什么问题?

标签: python encoding discord bots


【解决方案1】:

您可以使用事件discord.on_raw_reaction_add,当响应添加到消息中时将调用该事件,这是一个示例:

@client.event
async def on_raw_reaction_add(payload):
    if payload.emoji.name == "✉️" and payload.user_id != client.user.id:
        embed = discord.Embed(
            description = "This embed was sent because you have reacted with ✉️ ",
            colour = discord.Colour.from_rgb(0, 255, 0)
        )
        channel = client.get_channel(payload.channel_id)
        message = await channel.fetch_message(payload.message_id)
        await message.channel.send(embed=embed)

【讨论】:

  • 如果您查看我的脚本:当您使用 /overview 时,它会自动对消息做出反应。然后它发送嵌入消息,但如果作者是机器人,我希望不发送嵌入:D 请;D
  • 我已经编辑了答案,如果机器人对消息做出反应,它将停止发送嵌入。
  • 文件“c:\Users\jonas\Desktop\Service Bot own\Service_Bot.py”,第 214 行,如果 payload.emoji.name == "✉️" payload.user_id != client.user。 id:这是错误
  • 现在试试,这是我打错了:)
  • 没问题,如果有帮助,请务必将答案标记为解决方案:)
猜你喜欢
  • 1970-01-01
  • 2022-01-08
  • 2021-04-11
  • 2020-06-13
  • 2020-07-16
  • 2021-03-25
  • 1970-01-01
  • 1970-01-01
  • 2021-07-25
相关资源
最近更新 更多