Skip to content

Commit 43fcae0

Browse files
authored
Fixes the hangman started by footer (#1389)
1 parent 17abbf8 commit 43fcae0

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

techsupport_bot/commands/hangman.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ async def start_game(
402402
return
403403

404404
# Create and send the initial game embed
405-
embed = await self.generate_game_embed(interaction, game)
405+
embed = await self.generate_game_embed(interaction, game, interaction.user)
406406
message = await interaction.channel.send(embed=embed)
407407
self.games[interaction.channel_id] = {
408408
"user": interaction.user,
@@ -456,7 +456,7 @@ async def guess(self: Self, ctx: commands.Context, letter: str) -> None:
456456
return
457457

458458
correct = game.guess(letter)
459-
embed = await self.generate_game_embed(ctx, game)
459+
embed = await self.generate_game_embed(ctx, game, game_data.get("user"))
460460
message = game_data.get("message")
461461
await message.edit(embed=embed)
462462

@@ -470,6 +470,7 @@ async def generate_game_embed(
470470
self: Self,
471471
ctx_or_interaction: discord.Interaction | commands.Context,
472472
game: HangmanGame,
473+
owner: discord.Member,
473474
) -> discord.Embed:
474475
"""
475476
Generates an embed representing the current state of the Hangman game.
@@ -481,6 +482,7 @@ async def generate_game_embed(
481482
game (HangmanGame): The current instance of the Hangman game, used to
482483
retrieve game state, including word state, remaining guesses, and the
483484
hangman drawing.
485+
owner (discord.Member): The owner of the game
484486
485487
Returns:
486488
discord.Embed: An embed displaying the current game state, including
@@ -529,13 +531,7 @@ async def generate_game_embed(
529531
inline=False,
530532
)
531533

532-
# Determine the game creator based on interaction type
533-
if isinstance(ctx_or_interaction, discord.Interaction):
534-
footer_text = f"Game started by {ctx_or_interaction.user}"
535-
elif isinstance(ctx_or_interaction, commands.Context):
536-
footer_text = f"Game started by {ctx_or_interaction.author}"
537-
else:
538-
footer_text = " "
534+
footer_text = f"Game started by {owner}"
539535

540536
embed.set_footer(text=footer_text)
541537
return embed
@@ -562,7 +558,9 @@ async def redraw(self: Self, ctx: commands.Context) -> None:
562558
except discord.errors.NotFound:
563559
pass
564560

565-
embed = await self.generate_game_embed(ctx, game_data.get("game"))
561+
embed = await self.generate_game_embed(
562+
ctx, game_data.get("game"), game_data.get("user")
563+
)
566564
new_message = await ctx.send(embed=embed)
567565
game_data["message"] = new_message
568566

@@ -659,6 +657,6 @@ async def add_guesses(
659657
)
660658

661659
# Update the game embed
662-
embed = await self.generate_game_embed(ctx, game)
660+
embed = await self.generate_game_embed(ctx, game, game_data.get("user"))
663661
message = game_data.get("message")
664662
await message.edit(embed=embed)

0 commit comments

Comments
 (0)