【问题标题】:How to add reaction to message sent from bot如何对从机器人发送的消息添加反应
【发布时间】:2022-02-12 12:41:10
【问题描述】:

我的机器人将嵌入发送到特定频道,之后他还应该向他发送的嵌入添加 2 个反应。但我有点坚持,通过网站搜索并不成功。

if '!suggestion' in message.content:
        if "salus insured" in [y.name.lower() for y in message.author.roles]:
            channel = client.get_channel(938973763414921316)
            embedVar = discord.Embed(title="User suggestion, vote below!", color=0x03b2f8)
            embedVar.add_field(name="Suggestion", value="```"+substring+"```", inline=False)
            embedVar.add_field(name="Suggested by", value="<@{}>".format(message.author.id))
            embedVar.set_footer(text="Suggestion Poll | @Salus", icon_url="https://i.imgur.com/rwBBzGK.png")
            await channel.send(embed=embedVar)
            await message.delete()

这是我的代码的最后一部分。

【问题讨论】:

    标签: python discord discord.py embed


    【解决方案1】:

    您应该首先保留机器人发送的消息的消息对象...

    msg = await channel.send("whatever")
    

    然后,您可以像处理任何其他消息一样使用该消息对象 msg

    所以在你的情况下:

    msg.add_reaction(emoji)
    

    this question here 中找到不同的表情符号(例如自定义表情符号)有几个有用的提示

    【讨论】:

      猜你喜欢
      • 2021-09-12
      • 1970-01-01
      • 1970-01-01
      • 2017-11-01
      • 2021-04-11
      • 2020-08-02
      • 1970-01-01
      • 2022-01-05
      • 2021-07-04
      相关资源
      最近更新 更多