🐛 games.json isn't written in await funcs

This commit is contained in:
NikolajDanger
2020-08-02 22:20:00 +02:00
parent b8628d2eb5
commit 3070213562
3 changed files with 24 additions and 23 deletions

View File

@ -87,16 +87,11 @@ async def fiar(channel,command,user):
winner = data["4 in a row games"][str(channel)]["winner"]
if winner != 0:
with open("resources/games/games.json","w") as f:
json.dump(data,f,indent=4)
addMoney(data["4 in a row games"][str(channel)]["players"][winner-1].lower(),20)
with open("resources/games/games.json", "r") as f:
data = json.load(f)
del data["4 in a row games"][str(channel)]
with open("resources/games/games.json","w") as f:
json.dump(data,f,indent=4)
deleteGame("4 in a row games",str(channel))
# Deletes a message
async def deleteMessage(imageLocation,channel):
@ -189,15 +184,7 @@ async def parseCommands(message,content):
if message.author.display_name == "Nikolaj":
await message.channel.send("Logging out...")
with open("resources/games/games.json","r") as f:
data = json.load(f)
data["trivia questions"] = {}
data["blackjack games"] = {}
data["4 in a row games"] = {}
with open("resources/games/games.json","w") as f:
json.dump(data,f,indent=4)
stopServer()
await client.logout()
else:
@ -441,12 +428,7 @@ async def parseCommands(message,content):
triviaCountPoints(str(message.channel))
with open("resources/games/games.json", "r") as f:
data = json.load(f)
del data["trivia questions"][str(message.channel)]
with open("resources/games/games.json", "w") as f:
json.dump(data,f,indent=4)
deleteGame("trivia questions",str(message.channel))
logThis("Time's up for the trivia question",str(message.channel))
await message.channel.send("Time's up The answer was \""+chr(correctAnswer)+") "+answers[correctAnswer-97]+"\". Anyone who answered that has gotten 1 GwendoBuck")

View File

@ -1,4 +1,4 @@
from .miscFuncs import helloFunc, cap, imageFunc, logThis, findWikiPage, makeFiles, replaceMultiple, emojiToNumber, fiarReactionTest
from .miscFuncs import helloFunc, cap, imageFunc, logThis, findWikiPage, makeFiles, replaceMultiple, emojiToNumber, fiarReactionTest, deleteGame, stopServer
from .swfuncs import *

View File

@ -254,4 +254,23 @@ def fiarReactionTest(channel,message,user):
logThis("It wasn't their turn")
return False, 0
else:
return False, 0
return False, 0
def stopServer():
with open("resources/games/games.json","r") as f:
data = json.load(f)
data["trivia questions"] = {}
data["blackjack games"] = {}
data["4 in a row games"] = {}
with open("resources/games/games.json","w") as f:
json.dump(data,f,indent=4)
def deleteGame(gameType,channel):
with open("resources/games/games.json", "r") as f:
data = json.load(f)
del data[gameType][channel]
with open("resources/games/games.json", "w") as f:
json.dump(data,f,indent=4)