✨ Four in a row deletes old images
This commit is contained in:
13
Gwendolyn.py
13
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:
|
||||
|
@ -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
|
||||
return "I didn't get that", False, True
|
Reference in New Issue
Block a user