aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/evergreen/duck_game.py
diff options
context:
space:
mode:
authorGravatar Cam Caswell <[email protected]>2021-07-08 18:06:58 -0400
committerGravatar Cam Caswell <[email protected]>2021-07-09 14:02:38 -0400
commitfa9bc560739fb180d6f207701256a366302d11c0 (patch)
treeefe420f5bed52e9bb7c80681f83249c125cd372d /bot/exts/evergreen/duck_game.py
parentMarginally improve documentation (diff)
Refactor edit_embed_with_image into static method
Diffstat (limited to 'bot/exts/evergreen/duck_game.py')
-rw-r--r--bot/exts/evergreen/duck_game.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/bot/exts/evergreen/duck_game.py b/bot/exts/evergreen/duck_game.py
index 99afc648..c7110ba8 100644
--- a/bot/exts/evergreen/duck_game.py
+++ b/bot/exts/evergreen/duck_game.py
@@ -68,13 +68,6 @@ def as_trinary(card: tuple[int]) -> int:
return int(''.join(str(x) for x in card), base=3)
-async def edit_embed_with_image(msg: discord.Message, embed: discord.Embed) -> discord.Message:
- """Edit an embed without the attached image going wonky."""
- attach_name = urlparse(embed.image.url).path.split("/")[-1]
- embed.set_image(url=f"attachment://{attach_name}")
- return await msg.edit(embed=embed)
-
-
class DuckGame:
"""A class for a single game."""
@@ -245,7 +238,7 @@ class DuckGamesDirector(commands.Cog):
if old_footer == discord.Embed.Empty:
old_footer = ""
game_embed.set_footer(text=f"{old_footer}\n{str(answer):12s} - {author.display_name}")
- await edit_embed_with_image(game.embed_msg, game_embed)
+ await self.edit_embed_with_image(game.embed_msg, game_embed)
async def end_game(self, game: DuckGame, end_message: str) -> None:
"""Edit the game embed to reflect the end of the game and mark the game as not running."""
@@ -275,7 +268,14 @@ class DuckGamesDirector(commands.Cog):
game_embed.set_footer(
text=f"{old_footer.rstrip()}\n\n{end_message} Here are the scores:\n{scoreboard}\n\n{missed_text}"
)
- await edit_embed_with_image(game.embed_msg, game_embed)
+ await self.edit_embed_with_image(game.embed_msg, game_embed)
+
+ @staticmethod
+ async def edit_embed_with_image(msg: discord.Message, embed: discord.Embed) -> discord.Message:
+ """Edit an embed without the attached image going wonky."""
+ attach_name = urlparse(embed.image.url).path.split("/")[-1]
+ embed.set_image(url=f"attachment://{attach_name}")
+ return await msg.edit(embed=embed)
def setup(bot: Bot) -> None: