【问题标题】:How to make an event to give reactions in discord.py?如何在 discord.py 中进行事件以给出反应?
【发布时间】:2020-12-16 11:38:37
【问题描述】:

我正在尝试创建一个事件,当有人在特定频道中发送消息时会触发该事件。在该消息中,如果用户提到 4 个用户,则机器人会对他的消息做出反应。

我知道我可以做出反应

await ctx.message.add_reaction(emoji="<a:tick:748476262640779276>")

但我不明白如何创建这种事件。我应该使用什么功能?

【问题讨论】:

    标签: python discord discord.py


    【解决方案1】:

    您可以创建on_message 事件和message.mentions,这将为您提供提及的成员列表。你可以拿它的长度。

    @bot.event
    async def on_message(message):
        if len(message.mentions) >= 4 and message.channel.id == 123456789:
            await message.add_reaction(emoji="<a:tick:748476262640779276>")
    
        await bot.process_commands(message) # to allow commands
    

    【讨论】:

      猜你喜欢
      • 2021-03-13
      • 1970-01-01
      • 2020-10-11
      • 1970-01-01
      • 2020-12-11
      • 2022-01-02
      • 2021-12-31
      • 2019-05-24
      • 1970-01-01
      相关资源
      最近更新 更多