Jason Dever
Jason Dever

Reputation: 47

How to make a bot ignore certain channels in discord.py?

I'm trying to make a bot that redirects members to a certain channel when they say certain keywords, but I don't want the bot to tell them to go in #commands if they're already in #commands. How do I make the bot ignore all messages in #commands?

Upvotes: 0

Views: 2887

Answers (1)

Anu6is
Anu6is

Reputation: 2658

Simply add a check to your on_message event to return if the message.channel.id is equal to the id of #commands.

@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

Upvotes: 2

Related Questions