Skip to content
Advertisement

Make Discord.py Bot Only Work In Specific Channels

I was making a bot for my friend using discord.py and I wanted to make it so that it would only work in channel which include the word ticket, made by another bot named Ticket Toll

How can I do so?

Advertisement

Answer

Relevant docs on text channels

Unfortunately, Discord’s API does not keep track of who created the channel (which is why there’s no such thing as channel.author).

One solution would be to have Ticket Toll create channels in a category, and only give your bot permissions to view this category.

However, you can easily have the bot ignore messages if the channel doesn’t have “ticket” in the name, by checking channel.name. Here’s an example with the on_message event:

JavaScript

Or as a command:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement