I am making a discord ModMail bot and I have made it so that a channel is opened when somebody dms the bot but what is happening is that every single time somebody DMs the bot, it opens another channel. For example, if i had a conversation where I send 10 messages to the bot; 10 different channels would be opened. Does anybody know how I can make it send to the existing one? I have tried using checks but I am not sure how I would implement them. Here is my code:
async def on_message(message):
if message.author.id == client.user.id:
return
if message.author != message.author.bot:
await message.add_reaction('✅')
if not message.guild:
guild = client.get_guild(guild)
c = None
for channel in guild.text_channels: # check every channel
if channel.name == "❗ticket-{message.author.id}":
c = channel # channel found, stop looking
break
if c is None: # if no channel was found
c = await guild.create_text_channel('❗ticket-{message.author.id}')
embed = Embed(color=discord.Color.orange())
embed.add_field(name="**????ModMail Support????**",
value=f"User Mention: {message.author.mention}\nUsername: **{message.author}**\nUser-ID: **{message.author.id}**\n\n__**Content**__\n{message.content}")
await c.send(embed=embed)
Many thanks in advance! :)