How do I find out the category id? (discord.py)

How to find out the id of the category by its name, for example: the category is called "Main" and it is necessary that after the category was created, the id of this channel was written to the osnid variable in order to then create a chat in it, I tried to write the id by the name of the category, I created it like this:

await ctx.guild.create_text_channel(f"правила",overwrites=None, category="Основеное", reason=None)

But it gave an error that there should be an id attribute I tried to make OSNid = id (input ( " :::")) after creating a category, the user was required to enter the category id, and in the command for creating a text channel was entered instead of the name OSNid, but it did not work out, it wrote that atrebut str and it is necessary to id

Code:

@bot.command()
async def uncrash(ctx):
    author = ctx.message.author

    await ctx.guild.create_category("TEST", overwrites=None, reason=None)
    OSNid = int(input ("::: "))
    await ctx.guild.create_text_channel(f"TEST1", overwrites=None,category=f"{OSNid}", reason=None)
    await ctx.guild.create_text_channel(f"TEST2", overwrites=None,category=f"{OSNid}", reason=None)
    await ctx.guild.create_text_channel(f"TEST3", overwrites=None,category=f"{OSNid}", reason=None)
    await ctx.guild.create_text_channel(f"TEST4", overwrites=None,category=f"{OSNid}", reason=None)
    await ctx.guild.create_text_channel(f"TEST5", overwrites=None,category=f"{OSNid}", reason=None)
    await ctx.guild.create_text_channel(f"TEST6", overwrites=None,category=f"{OSNid}", reason=None)
    await ctx.guild.create_text_channel(f"TEST7", overwrites=None,category=f"{OSNid}", reason=None)
    await ctx.guild.create_text_channel(f"TEST8", overwrites=None,category=f"{OSNid}", reason=None)
Author: Selasi, 2021-01-12

2 answers

Create_category will return CategoryChannel which has a method for creating text channels.

category = await ctx.guild.create_category("TEST", overwrites=None, reason=None)
await category.create_text_channel(f"TEST1", overwrites=None, reason=None)
 1
Author: eri, 2021-01-23 09:11:17

And so?

@bot.command()
async def uncrash(ctx):
    author = ctx.message.author

    category = await ctx.guild.create_category("TEST", overwrites=None, reason=None)
    await ctx.guild.create_text_channel(f"TEST1", overwrites=None, category=category, reason=None)
 1
Author: gil9red, 2021-01-12 19:33:13