This commit is contained in:
jona605a
2020-08-04 12:36:24 +02:00
6 changed files with 36 additions and 33 deletions

View File

@ -14,7 +14,7 @@ async def deleteMessage(imageLocation,channel):
await oldImage.delete()
except:
oldImage = ""
return oldImage
# Runs Hex
@ -23,7 +23,7 @@ async def runhex(channel,command,user):
response, showImage, deleteImage, gameDone, gwendoTurn = parseHex(command,str(channel),user)
except:
logThis("Error parsing command (error code 1510)")
await channel.send(response)
logThis(response,str(channel))
if showImage:
@ -49,7 +49,7 @@ async def runhex(channel,command,user):
else:
with open("resources/games/oldImages/hex"+str(channel), "w") as f:
f.write(str(oldImage.id))
if gameDone:
with open("resources/games/games.json", "r") as f:
data = json.load(f)
@ -77,7 +77,7 @@ async def fiar(channel,command,user):
response, showImage, deleteImage, gameDone, gwendoTurn = parseFourInARow(command,str(channel),user)
except:
logThis("Error parsing command (error code 1410)")
await channel.send(response)
logThis(response,str(channel))
if showImage:
@ -106,7 +106,7 @@ async def fiar(channel,command,user):
reactions = ["1","2","3","4","5","6","7"]
for reaction in reactions:
await oldImage.add_reaction(reaction)
except:
logThis("Image deleted before I could react to all of them")
@ -130,7 +130,7 @@ async def fiar(channel,command,user):
try:
with open("resources/games/oldImages/fourInARow"+str(channel), "r") as f:
oldImage = await channel.fetch_message(int(f.read()))
await oldImage.delete()
except:
logThis("The old image was already deleted")
@ -161,7 +161,7 @@ async def blackjackLoop(channel,gameRound,gameID):
oldImage = await channel.send(file = discord.File("resources/games/blackjackTables/blackjackTable"+str(channel)+".png"))
with open("resources/games/oldImages/blackjack"+str(channel), "w") as f:
f.write(str(oldImage.id))
try:
if allStanding:
await asyncio.sleep(5)
@ -169,10 +169,10 @@ async def blackjackLoop(channel,gameRound,gameID):
await asyncio.sleep(120)
except:
logThis("Loop "+str(gameRound)+" interrupted (error code 1321)")
with open("resources/games/games.json", "r") as f:
data = json.load(f)
if str(channel) in data["blackjack games"]:
realRound = data["blackjack games"][str(channel)]["round"]
realGameID = data["blackjack games"][str(channel)]["id"]
@ -191,4 +191,3 @@ async def blackjackLoop(channel,gameRound,gameID):
logThis("Ending loop on round "+str(gameRound),str(channel))
else:
logThis("Ending loop on round "+str(gameRound),str(channel))