Skip to content
Snippets Groups Projects
Unverified Commit 83ca233c authored by dnns01's avatar dnns01 Committed by GitHub
Browse files

Merge pull request #1 from SebastianSpeitel/patch-1

improve(leaderboard): close file handles
parents dbb3380e b2fa9b67
No related branches found
No related tags found
No related merge requests found
......@@ -11,13 +11,13 @@ class Leaderboard(commands.Cog):
def load(self):
""" Load highscores from json file """
highscore_file = open("highscores.json", mode="r")
return json.load(highscore_file)
with open("highscores.json", mode="r") as highscore_file:
return json.load(highscore_file)
def save(self):
""" Save highscores to json file """
highscore_file = open("highscores.json", mode="w")
json.dump(self.highscores, highscore_file)
with open("highscores.json", mode="w") as highscore_file:
json.dump(self.highscores, highscore_file)
@commands.command(name="highscore")
async def cmd_highscore(self, ctx, score: int):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment