简体   繁体   中英

Make a category on a server with a BOT inside the discord.py API

I am new to Python (and, of course to discord.py), and I didn't really find any documentation on websites or on the official Discord for this question.

I was wondering if there is any function inside discord.py that would create a category on a server ( client.get_server('295959610043531264') )

Thanks a lot ;)

You can create categories and channel simple with this code.

the command: !new category admin-chat

@client.command()
async def new(ctx, arg1, arg2):
    guild = ctx.message.guild
    if arg1 == "channel":
        await guild.create_text_channel(arg2)

    elif arg1 == "category":
        await ctx.guild.create_category(arg2)

You can only create categories with the rewrite version of discord.py ( 1.0.0a )

Here is the documentation for it.

This would be an example of how I would do it with the commands extension:

@bot.command()
async def create_category(ctx, *, name):
    await ctx.guild.create_category(name)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM