Skip to content

Commit 92aa8f2

Browse files
authored
Add more friendly error when corrected message is too long (#886)
* Add more friendly error when corrected message is too long * Add maximum line count * Remove unit tests * Update correct.py
1 parent f0e14b0 commit 92aa8f2

2 files changed

Lines changed: 17 additions & 191 deletions

File tree

techsupport_bot/commands/correct.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,25 @@ async def correct_command(
5555
updated_message = self.prepare_message(
5656
message_to_correct.content, to_replace, replacement
5757
)
58+
59+
updated_message += " :white_check_mark:"
60+
61+
if len(updated_message) > 4096:
62+
await auxiliary.send_deny_embed(
63+
message="The corrected message is too long to send", channel=ctx.channel
64+
)
65+
return
66+
67+
if updated_message.count("\n") > 15:
68+
await auxiliary.send_deny_embed(
69+
message="The corrected message has too many lines to send",
70+
channel=ctx.channel,
71+
)
72+
return
73+
5874
embed = auxiliary.generate_basic_embed(
5975
title="Correction!",
60-
description=f"{updated_message} :white_check_mark:",
76+
description=updated_message,
6177
color=discord.Color.green(),
6278
)
6379
await ctx.send(

techsupport_bot/tests/commands_tests/test_extensions_correct.py

Lines changed: 0 additions & 190 deletions
This file was deleted.

0 commit comments

Comments
 (0)