diff --git a/Gwendolyn.py b/Gwendolyn.py index c46ac22..54e4f62 100644 --- a/Gwendolyn.py +++ b/Gwendolyn.py @@ -575,11 +575,20 @@ async def parseCommands(message,content): # Runs a game of four in a row elif content.startswith("fourinarow"): - response, showImage = parseFourInARow(content.replace("fourinarow",""),str(message.channel),message.author.display_name) + response, showImage, deleteImage = parseFourInARow(content.replace("fourinarow",""),str(message.channel),message.author.display_name) await message.channel.send(response) logThis(response,str(message.channel)) if showImage: - await message.channel.send(file = discord.File("resources/games/4InARowBoards/board"+str(message.channel)+".png")) + if deleteImage: + try: + with open("resources/games/oldImages/fourInARow"+str(message.channel), "r") as f: + oldImage = await message.channel.fetch_message(int(f.read())) + await oldImage.delete() + except: + oldImage = "" + oldImage = await message.channel.send(file = discord.File("resources/games/4InARowBoards/board"+str(message.channel)+".png")) + with open("resources/games/oldImages/fourInARow"+str(message.channel), "w") as f: + f.write(str(oldImage.id)) # Not a command else: diff --git a/funcs/games/fourInARow.py b/funcs/games/fourInARow.py index ae770a7..b3a46a2 100644 --- a/funcs/games/fourInARow.py +++ b/funcs/games/fourInARow.py @@ -59,8 +59,8 @@ def parseFourInARow(command, channel, user): elif command.startswith(" place"): commands = command.split(" ") try: - return placePiece(channel,int(commands[2]),int(commands[3])-1) + return placePiece(channel,int(commands[2]),int(commands[3])-1), True except: - return "I didn't quite get that", False + return "I didn't quite get that", False, True else: - return "I didn't get that", False \ No newline at end of file + return "I didn't get that", False, True \ No newline at end of file