Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have set up the basic template for a python discord bot. Please tell me what code I can use to create a new text-channel when the user types channel + (the channel name). Sorry if this is a silly question to ask. Because the only resources are not helping me.

What I have tried:

Please help I feel stupid for asking this but please do it any way.
Posted
Updated 18-Jan-21 19:13pm

Please have a look at the documentation: API Reference — discord.py 1.5.0a documentation[^]

Creating a basic channel in create_text_channel section:
JavaScript
channel = await guild.create_text_channel('cool-channel')
 
Share this answer
 
Comments
[no name] 4-Sep-20 8:19am    
The code I have is:

import discord
client = discord.Client()
@client.event
async def on_message(message):
if message.content == "!create":
channel = await guild.create_text_channel('cool-channel')

client.run(my token)

But it still produces an error. What am I coding wrong? Sorry if my python is bad.
Sandeep Mewara 4-Sep-20 8:26am    
No one would be able hlep like this. Please pick a sample app and tutorial from web to learn and see how it is.
mehdi god 19-Jul-22 4:10am    
Permission channel
Crafty Hawk 7-Apr-23 11:48am    
If you still need help... Can you post the error that shows?
About the comment of yours about the following code:

Python
import discord
client = discord.Client()
@client.event
async def on_message(message):
if message.content == "!create":
channel = await guild.create_text_channel('cool-channel')

client.run(my token)


You need to have
guild.create_text_channel as
message.guild.create_text_channel

Hope that works
 
Share this answer
 
Comments
Western Enforcement 20-Jul-21 18:13pm    
This code contains lots of errors. Also, there could be an easier way rather than trigger it from an event. Use the @client.command() event.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900