A
A
Apache2020-12-12 19:31:34
Python
Apache, 2020-12-12 19:31:34

Can't create a channel in a specific category?

The channel is created as it should, but it is created at the very top, and I need it to be in a category. I can not find the necessary thing on the API. There is a category, but it is not clear what to transfer there.

The code
@bot.command()
async def create_channel(ctx):
    name = ""+ctx.message.author.name
    guild = ctx.message.guild
    await guild.create_voice_channel(name, position=3)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Nevzorov, 2020-12-13
@igor_89squad

categoryThe channel-category object is passed as an argument .

@bot.command()
async def cmdname(ctx):
    category = bot.get_channel(788488692362607662)  # ID категории
    await category.create_voice_channel(ctx.author.name)
    # ИЛИ
    await ctx.guild.create_voice_channel(ctx.author.name, category = category)

N
Nikita Kudrin, 2020-12-12
@HepkaPlay

@bot.command()
async def create_channel(ctx):
    name = ""+ctx.message.author.name
    guild = ctx.message.guild
    await guild.create_voice_channel(name, position=3, category=CATEGORY_ID)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question