From c215f8b366a3b91ce5e8792a73b3c3cf5ed40fba Mon Sep 17 00:00:00 2001 From: Paillat Date: Fri, 23 Dec 2022 15:09:54 +0100 Subject: [PATCH] tempfix the mentions shit --- code/cogs/chat.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/code/cogs/chat.py b/code/cogs/chat.py index ac1ca98..5dfa9df 100644 --- a/code/cogs/chat.py +++ b/code/cogs/chat.py @@ -140,19 +140,21 @@ async def on_message_process(message: discord.Message, self: Chat): #get the channel id from the database c.execute("SELECT channel_id FROM data WHERE guild_id = ?", (message.guild.id,)) for msg in messages: - mentions = re.findall(r"<@!?\d+>", msg.content) + content = msg.content + mentions = re.findall(r"<@!?\d+>", content) #then replace each mention with the name of the user for mention in mentions: #get the user id - id = mention[2:-1] + uid = mention[2:-1] #get the user - user = await self.bot.fetch_user(id) + user = await self.bot.fetch_user(uid) #replace the mention with the name - msg.content = msg.content.replace(mention, user + f"<@{id}>") + content = content.replace(mention, f"{user.name}#{user.discriminator}:<@{uid}>") + content = content + "\nSYSTEM: Mentions have been replaced with name#discriminator:id. Botator uses only the mention, not the name or the discriminator. The discriminator is only used to prevent name clashes." #get the gmt time the message was sent gmt_time = message.created_at.strftime("%Y-%m-%d %H:%M:%S") ##print(msg.content) - prompt += f"{msg.author} ({gmt_time} GMT-0): {msg.content}\n" + prompt += f"{msg.author} ({gmt_time} GMT-0): {content}\n" ##print(prompt) #get the prompt_prefix from the database #check if the bot is in pretend mode