@bot.event
async def on_message(message):
if message.author == bot.user:
return
if isinstance(message.channel, DMChannel):
guild = bot.get_guild(guildID)
channels = await guild.fetch_channels()
channel = discord.utils.get(channels, name=message.author.id)
message1 = message.author
embedVar = discord.Embed(title= f'{message.author} has sent a new message', description = message.content,
color= 0xff0000)
category = discord.utils.get(guild.categories, id = category.id)
channel = await guild.create_text_channel(message.author.id, category=category, id = message.author.id)
embedMod = discord.Embed(title = 'Information for the mods', description = '!close- Closes the text channel'
'\n!DM- To DM the user anonymously', color = 0x00FF00)
if channel not in channels:
await guild.create_text_channel(message.author.id, category = category)
await channel.send(embed=embedMod)
if channel in channels:
pass
await channel.send(embed=embedVar)
await bot.process_commands(message)
I am making a bot where the user dms the bot for help and the bot creates a text channel in the guild under a specific category. The problem is every time a message is DMed to the bot, the bot creates a text channel for every message even if it is the same user. How do I make sure that the bot doesnt create a text channel with the same name if its already made and the other messages of the same user are sent to the channel..
catagory.channels
and checkif channel.topic == str(message.author.id)
– Guddi