Skip to content

Commit d4002eb

Browse files
committed
Abbreviate codeblock instructions; remove ability to dismiss the instructions with emoji.
The more concise instructions are intended to be easier to read and increase the rate of followthru. That the instructions cannot be dismissed is intended to make them harder to ignore.
1 parent 41d15cc commit d4002eb

File tree

2 files changed

+8
-25
lines changed

2 files changed

+8
-25
lines changed

bot/exts/info/codeblock/_cog.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ class CodeBlockCog(Cog, name="Code Block"):
4343
When an issue is detected, an embed is sent containing specific instructions on fixing what
4444
is wrong. If the user edits their message to fix the code block, the instructions will be
4545
removed. If they fail to fix the code block with an edit, the instructions will be updated to
46-
show what is still incorrect after the user's edit. The embed can be manually deleted with a
47-
reaction. Otherwise, it will automatically be removed after 5 minutes.
46+
show what is still incorrect after the user's edit. Otherwise, it will automatically be removed after 5 minutes.
4847
4948
The cog only detects messages in whitelisted channels. Channels may also have a cooldown on the
5049
instructions being sent. Note all help channels are also whitelisted with cooldowns enabled.
@@ -64,7 +63,7 @@ def __init__(self, bot: Bot):
6463
@staticmethod
6564
def create_embed(instructions: str) -> discord.Embed:
6665
"""Return an embed which displays code block formatting `instructions`."""
67-
return discord.Embed(description=instructions)
66+
return discord.Embed(description=instructions, title="Please edit your message to use a code block")
6867

6968
async def get_sent_instructions(self, payload: RawMessageUpdateEvent) -> Message | None:
7069
"""
@@ -114,7 +113,7 @@ async def send_instructions(self, message: discord.Message, instructions: str) -
114113
bot_message = await message.channel.send(f"Hey {message.author.mention}!", embed=embed)
115114
self.codeblock_message_ids[message.id] = bot_message.id
116115

117-
scheduling.create_task(wait_for_deletion(bot_message, (message.author.id,)))
116+
scheduling.create_task(wait_for_deletion(bot_message, tuple(), attach_emojis=False))
118117

119118
# Increase amount of codeblock correction in stats
120119
self.bot.stats.incr("codeblock_corrections")

bot/exts/info/codeblock/_instructions.py

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ def _get_bad_ticks_message(code_block: _parsing.CodeBlock) -> str | None:
3737

3838
valid_ticks = f"\\{_parsing.BACKTICK}" * 3
3939
instructions = (
40-
"It looks like you are trying to paste code into this channel.\n\n"
41-
"You seem to be using the wrong symbols to indicate where the code block should start. "
42-
f"The correct symbols would be {valid_ticks}, not `{code_block.tick * 3}`."
40+
"You are using the wrong character instead of backticks. "
41+
f"Use {valid_ticks}, not `{code_block.tick * 3}`."
4342
)
4443

4544
log.trace("Check if the bad ticks code block also has issues with the language specifier.")
@@ -59,8 +58,6 @@ def _get_bad_ticks_message(code_block: _parsing.CodeBlock) -> str | None:
5958
instructions += "\n\nFurthermore, " + addition_msg[0].lower() + addition_msg[1:]
6059
else:
6160
log.trace("No issues with the language specifier found.")
62-
example_blocks = _get_example(code_block.language)
63-
instructions += f"\n\n**Here is an example of how it should look:**\n{example_blocks}"
6461

6562
return instructions
6663

@@ -71,13 +68,7 @@ def _get_no_ticks_message(content: str) -> str | None:
7168

7269
if _parsing.is_python_code(content):
7370
example_blocks = _get_example("py")
74-
return (
75-
"It looks like you're trying to paste code into this channel.\n\n"
76-
"Discord has support for Markdown, which allows you to post code with full "
77-
"syntax highlighting. Please use these whenever you paste code, as this "
78-
"helps improve the legibility and makes it easier for us to help you.\n\n"
79-
f"**To do this, use the following method:**\n{example_blocks}"
80-
)
71+
return example_blocks
8172
log.trace("Aborting missing code block instructions: content is not Python code.")
8273
return None
8374

@@ -135,12 +126,8 @@ def _get_no_lang_message(content: str) -> str | None:
135126
example_blocks = _get_example("py")
136127

137128
# Note that _get_bad_ticks_message expects the first line to have two newlines.
138-
return (
139-
"It looks like you pasted Python code without syntax highlighting.\n\n"
140-
"Please use syntax highlighting to improve the legibility of your code and make "
141-
"it easier for us to help you.\n\n"
142-
f"**To do this, use the following method:**\n{example_blocks}"
143-
)
129+
return f"Please add a `py` after the three backticks.\n\n{example_blocks}"
130+
144131
log.trace("Aborting missing language instructions: content is not Python code.")
145132
return None
146133

@@ -177,7 +164,4 @@ def get_instructions(content: str) -> str | None:
177164
if not instructions:
178165
instructions = _get_no_lang_message(block.content)
179166

180-
if instructions:
181-
instructions += "\nYou can **edit your original message** to correct your code block."
182-
183167
return instructions

0 commit comments

Comments
 (0)