diff options
| author | 2020-04-13 22:56:35 -0700 | |
|---|---|---|
| committer | 2020-06-13 11:21:03 -0700 | |
| commit | fc5d7407dc0e52461c8940cf2eabb832e9c7a4a7 (patch) | |
| tree | eac983a24e3e94970ba3e34ecc66cc23161bbc08 | |
| parent | Code block: add helper function to send the embed (diff) | |
Code block: move final send/cooldown code outside the try-except
Reduces nesting for improved readability. The code would have never
thrown a syntax error in the manner expected anyway.
| -rw-r--r-- | bot/cogs/codeblock/cog.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/bot/cogs/codeblock/cog.py b/bot/cogs/codeblock/cog.py index a4cd743e4..312a7034e 100644 --- a/bot/cogs/codeblock/cog.py +++ b/bot/cogs/codeblock/cog.py @@ -328,21 +328,18 @@ class CodeBlockCog(Cog, name="Code Block"): "blocks. Sending the user some instructions.") else: log.trace("The code consists only of expressions, not sending instructions") - - if howto != "": - await self.send_guide_embed(msg, howto) - else: - return - - if msg.channel.id not in self.channel_whitelist: - self.channel_cooldowns[msg.channel.id] = time.time() - except SyntaxError: log.trace( f"{msg.author} posted in a help channel, and when we tried to parse it as Python code, " "ast.parse raised a SyntaxError. This probably just means it wasn't Python code. " f"The message that was posted was:\n\n{msg.content}\n\n" ) + return + + if howto: + await self.send_guide_embed(msg, howto) + if msg.channel.id not in self.channel_whitelist: + self.channel_cooldowns[msg.channel.id] = time.time() @Cog.listener() async def on_raw_message_edit(self, payload: RawMessageUpdateEvent) -> None: |