aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Shambo Chowdhury <[email protected]>2024-06-28 22:46:44 +0530
committerGravatar Shambo Chowdhury <[email protected]>2024-06-28 22:46:44 +0530
commit9d58aa15d25cb72513e26a220b02499a9b007725 (patch)
tree2be5d8e55342d6ca8378a791e4337add767dc5d0
parentUpdate bot/exts/moderation/modlog.py (diff)
removed gather_reply()
- gather_reply() can be resource intensive for big servers as it will iterate through all the message every time a user deletes any message which has replies to it. - removed content and channel in `In reply to:` section as some messages containing `[` or `]` can create interference with the `[](url)`
-rw-r--r--bot/exts/moderation/modlog.py39
1 files changed, 2 insertions, 37 deletions
diff --git a/bot/exts/moderation/modlog.py b/bot/exts/moderation/modlog.py
index 2ce516afb..014cb6c34 100644
--- a/bot/exts/moderation/modlog.py
+++ b/bot/exts/moderation/modlog.py
@@ -532,40 +532,13 @@ class ModLog(Cog, name="ModLog"):
if isinstance(resolved_message, discord.Message):
jump_url = resolved_message.jump_url
- if resolved_message.channel.category:
- resolved_message_text = (
- f"{resolved_message.author} in "
- f"{resolved_message.channel.category}/#{resolved_message.channel.name}:"
- )
- else:
- resolved_message_text = (
- f"{resolved_message.author} in "
- f"#{resolved_message.channel.name}:"
- )
-
- #Shorten the message content if necessary
- if len(resolved_message.clean_content) > 10:
- resolved_clean_content = resolved_message.clean_content[:10] + "..."
- else:
- resolved_clean_content = resolved_message.clean_content
+ author = resolved_message.author.mention
reference_line = (
- f"**In reply to:** [{resolved_message_text}]({jump_url}) {resolved_clean_content}\n"
+ f"**In reply to:** {author} [Jump to message]({jump_url})\n"
)
response = reference_line + response
- # If the message is a parent messages and has replies to it, add the replies to the response
- replies = await self.gather_replies(message)
- if replies:
- reply_lines: str = ""
- for reply in replies:
- content = reply.clean_content
- if len(content) > 10:
- content = content[:10] + "..."
- reply_lines += f"\n- {format_user(reply.author)}[Jump to message]({reply.jump_url}) {content}"
-
- response += f"**Replies:** {reply_lines}\n"
-
if message.attachments:
# Prepend the message metadata with the number of attachments
response = f"**Attachments:** {len(message.attachments)}\n" + response
@@ -592,14 +565,6 @@ class ModLog(Cog, name="ModLog"):
channel_id=Channels.message_log
)
- async def gather_replies(self, message: discord.Message) -> list[Message]:
- """Gather replies to the given message."""
- replies = []
- async for msg in message.channel.history(after=message.created_at, limit=10):
- if msg.reference and msg.reference.message_id == message.id:
- replies.append(msg)
- return replies
-
async def log_uncached_deleted_message(self, event: discord.RawMessageDeleteEvent) -> None:
"""
Log the message's details to message change log.