pythonpython-3.xdiscord.py

How to get a category by its id?


I am making a bot that creates channels. He must create channels in a certain category. I am using guild.create_text_channel(). I haven't found a way to do this in the documentation. Any help would be welcome.


Solution

  • You can use discord.utils.get for getting a category by it's id. Here is a usage of it:

    guild = discord.utils.get(client.guild.categories, id='put the id here without apostrophes')