Search code examples
pythondiscorddiscord.py

Guild.create_text_channel() got multiple values for argument 'name'


I'm trying to create a bot that setups a server. However, after I setup the category names, I'm not able to append the channels to that category.

@has_permissions(administrator=True)
@client.command(name='setup')
async def setup(ctx):
    for channel in ctx.guild.channels:
        await channel.delete()
    for category in ctx.guild.categories:
        await category.delete()
    for category in server_types["categories"]:
        await ctx.guild.create_category(category)
    for channel in server_types["information"]:
        await ctx.guild.create_text_channel(channel, name='information')

This is my code.

{
    "categories":["information", "marketplace", "staff"],
    "information":["welcome", "faq", "announcements", "partnerships", "deals-and-promotions"],
    "marketplace":["general","purchase-info", "support", "bump"],
    "staff":["staff-chat", "bot-test", "Company Voice Chat"]

}

This is the JSON file from which I'm extracting the channel names as well as the categories.

Whenever I call the command, I get this error: Guild.create_text_channel() got multiple values for argument 'name'.

I do not understand why I'm getting this error because I'm only passing one value into the name parameter.


Solution

  • Try passing the category

    for channel in server_types["information"]:
        category = discord.utils.get(ctx.guild.channels, name='information')  # Better to pass an ID
        await ctx.guild.create_text_channel(name=channel, category=category)