🐛 small change in order of operations

This commit is contained in:
NikolajDanger
2021-08-19 19:59:46 +02:00
parent b8a2f6022e
commit e0eab627fe
2 changed files with 16 additions and 23 deletions

View File

@ -92,11 +92,11 @@ class Hangman():
send_message = f"{ctx.author.display_name} started a game of hangman."
self.bot.log("Game started")
await ctx.send(send_message)
boards_path = "gwendolyn/resources/games/hangman_boards/"
file_path = f"{boards_path}hangman_board{game_id}.png"
image_message = await ctx.send(
send_message,
image_message = await ctx.channel.send(
file=discord.File(file_path)
)
@ -165,6 +165,10 @@ class Hangman():
The context of the command.
"""
for msg_id in messages:
msg = await ctx.channel.fetch_message(msg_id)
await msg.delete()
self.bot.log("Deleting old messages")
await ctx.channel.send("Hangman game stopped")
@ -172,10 +176,6 @@ class Hangman():
file_path = f"{boards_path}hangman_board{game_id}.png"
os.remove(file_path)
for msg_id in messages:
msg = await ctx.channel.fetch_message(msg_id)
await msg.delete()
async def guess(self, ctx: ComponentContext, guess: str, word: str,
guessed_letters: str, game_id: str, *messages: list[str]):
"""
@ -190,6 +190,9 @@ class Hangman():
guess: str
The guess.
"""
for msg_id in messages:
msg = await ctx.channel.fetch_message(msg_id)
await msg.delete()
misses = 0
guessed_letters += guess
@ -228,10 +231,10 @@ class Hangman():
if remaining_letters != []:
await ctx.channel.send(send_message)
boards_path = "gwendolyn/resources/games/hangman_boards/"
file_path = f"{boards_path}hangman_board{game_id}.png"
image_message = await ctx.channel.send(
send_message,
file=discord.File(file_path)
)
blank_message_one = await ctx.channel.send("_ _")
@ -291,11 +294,6 @@ class Hangman():
os.remove(file_path)
for msg_id in messages:
msg = await ctx.channel.fetch_message(msg_id)
await msg.delete()