【问题标题】:How to make a bot ignore certain channels in discord.py?如何让机器人忽略 discord.py 中的某些频道?
【发布时间】:2019-04-15 18:34:22
【问题描述】:

我正在尝试制作一个机器人,当会员说出某些关键字时将其重定向到某个频道,但如果他们已经在#commands 中,我不希望该机器人告诉他们进入#commands。如何让机器人忽略#commands 中的所有消息?

【问题讨论】:

    标签: python-3.x discord discord.py


    【解决方案1】:

    如果message.channel.id 等于#commands 的ID,只需在on_message 事件中添加一个检查即可返回。

    @client.event
    async def on_message(message):
        #Ignore messages sent in channel with id 1234567890 (#commands channel)
        if message.channel.id == 1234567890:
            return
    
        #Ignore messages sent by the bot
        if message.author == client.user:
            return
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-24
      • 2023-04-10
      • 2020-08-30
      • 2020-10-04
      • 1970-01-01
      • 1970-01-01
      • 2019-05-05
      • 2020-06-20
      相关资源
      最近更新 更多