Skip to content
Snippets Groups Projects
Unverified Commit b2fa9b67 authored by Sebastian Speitel's avatar Sebastian Speitel Committed by GitHub
Browse files

improve(leaderboard): close file handles

parent dbb3380e
No related branches found
No related tags found
1 merge request!1improve(leaderboard): close file handles
......@@ -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