Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/kernelbot/discord_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ async def leaderboard_name_autocomplete(


async def _send_split_log(thread: discord.Thread, partial_message: str, header: str, log: str):
if len(partial_message) + len(log) + len(header) < 1900:
if len(partial_message) + len(log) + len(header) < 1800:
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The length check on this line doesn't accurately account for the formatting overhead. The actual message will be partial_message + "\n\n## " + header + ":\n" + "```\n" + log + "```", which adds 14 extra characters (7 from the header formatting and 7 from the code block markers). The condition should be len(partial_message) + len(log) + len(header) + 14 < 1800 to accurately prevent messages from exceeding the limit.

Suggested change
if len(partial_message) + len(log) + len(header) < 1800:
if len(partial_message) + len(log) + len(header) + 14 < 1800:

Copilot uses AI. Check for mistakes.
partial_message += f"\n\n## {header}:\n"
partial_message += f"```\n{log}```"
return partial_message
Expand All @@ -120,7 +120,7 @@ async def _send_split_log(thread: discord.Thread, partial_message: str, header:
chunks = []
partial_message = ""
for line in lines:
if len(partial_message) + len(line) < 1900:
if len(partial_message) + len(line) < 1800:
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The length check doesn't account for the newline character that's added in line 124. The condition should be len(partial_message) + len(line) + 1 < 1800 to accurately represent the actual length after the newline is appended.

Suggested change
if len(partial_message) + len(line) < 1800:
if len(partial_message) + len(line) + 1 < 1800:

Copilot uses AI. Check for mistakes.
partial_message += line + "\n"
else:
if partial_message != "":
Expand All @@ -132,7 +132,7 @@ async def _send_split_log(thread: discord.Thread, partial_message: str, header:

# now, format the chunks
for i, chunk in enumerate(chunks):
partial_message = f"\n\n## {header} ({i+1}/{len(chunks)}):\n"
partial_message = f"\n\n## {header} ({i + 1}/{len(chunks)}):\n"
partial_message += f"```\n{limit_length(chunk, 1900)}```"
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The limit_length call still uses 1900 as the limit, which is inconsistent with the changed limits of 1800 in lines 111 and 123. This inconsistency could lead to messages exceeding the intended length limit. Consider updating this to 1800 to match the other changes, or adjust it to account for the header formatting overhead that's added in line 135.

Suggested change
partial_message += f"```\n{limit_length(chunk, 1900)}```"
partial_message += f"```\n{limit_length(chunk, 1800)}```"

Copilot uses AI. Check for mistakes.
await thread.send(partial_message, silent=True)

Expand Down
Loading