如何让机器人忽略discord.py中的某些频道?

问题描述 投票:0回答:1

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

python-3.x discord discord.py
1个回答
2
投票

如果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
© www.soinside.com 2019 - 2024. All rights reserved.