aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-05-07 19:18:47 -0700
committerGravatar MarkKoz <[email protected]>2020-06-13 11:21:08 -0700
commitae0f29ee8680c75d59eefa2f1563f6c906539aa9 (patch)
tree18b77791168db8237524285f36d49c113485bcd0
parentCode block: use regex to parse incorrect languages (diff)
Code block: add function to create the instructions embed
While it may be simple now, if the embed needs to changed later, it won't need to be done in multiple places since everything can rely on this function to create the embed.
-rw-r--r--bot/cogs/codeblock/cog.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/bot/cogs/codeblock/cog.py b/bot/cogs/codeblock/cog.py
index 38daa7974..ca787b181 100644
--- a/bot/cogs/codeblock/cog.py
+++ b/bot/cogs/codeblock/cog.py
@@ -3,7 +3,7 @@ import time
from typing import Optional
import discord
-from discord import Embed, Message, RawMessageUpdateEvent
+from discord import Message, RawMessageUpdateEvent
from discord.ext.commands import Bot, Cog
from bot.cogs.token_remover import TokenRemover
@@ -33,6 +33,11 @@ class CodeBlockCog(Cog, name="Code Block"):
# Stores improperly formatted Python codeblock message ids and the corresponding bot message
self.codeblock_message_ids = {}
+ @staticmethod
+ def create_embed(instructions: str) -> discord.Embed:
+ """Return an embed which displays code block formatting `instructions`."""
+ return discord.Embed(description=instructions)
+
async def get_sent_instructions(self, payload: RawMessageUpdateEvent) -> Optional[Message]:
"""
Return the bot's sent instructions message associated with a user's message `payload`.
@@ -84,7 +89,7 @@ class CodeBlockCog(Cog, name="Code Block"):
"""
log.trace("Sending an embed with code block formatting instructions.")
- embed = Embed(description=instructions)
+ embed = self.create_embed(instructions)
bot_message = await message.channel.send(f"Hey {message.author.mention}!", embed=embed)
self.codeblock_message_ids[message.id] = bot_message.id