0

I am trying to create a command that creates a text channel. However, its not working. It doesn't even show an error. I am using Discord.py Rewrite.

Here is the code I've tried:

@client.command()
async def addcha(ctx, channel : discord.TextChannel):
   await ctx.guild.create_text_channel(channel=None)
   await ctx.send(f"A new channel called {channel} was made")

1 Answer 1

1

await ctx.guild.create_text_channel(channel=None)

Guild.create_text_channel doesn't have a channel kwarg, so not sure what you're trying to do here. Further, I don't think you can use a converter to cast your argument to a TextChannel that doesn't exist yet. You just have to pass in the name of the channel.

@client.command()
async def addcha(ctx, channel_name):
    await ctx.guild.create_text_channel(channel_name)
    await ctx.send(f"A new channel called {channel_name} was made")

More info on what you can do when creating a TextChannel in the relevant API Docs.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.