Check for non-existing files & init with default values

fixes #63
pull/72/head
Stijn De Clercq 2021-06-19 20:31:31 +02:00
parent 418dc41126
commit 7e5c4031c0
8 changed files with 67 additions and 1 deletions

View File

@ -0,0 +1,5 @@
{
"guessed": [],
"guesses": 0,
"word": ""
}

View File

@ -0,0 +1,9 @@
{
"interest": 0,
"lost": 0,
"poke": 0,
"prison": 0,
"birthdays": 0,
"channels": 0,
"remind": 0
}

View File

@ -0,0 +1,4 @@
{
"locked": false,
"until": -1
}

View File

@ -0,0 +1,4 @@
{
"lost": 0,
"today": 0
}

View File

@ -0,0 +1,19 @@
{
"cf": {
"h": 0,
"t": 0
},
"dice": {
"2": 0,
"5": 0,
"3": 0,
"6": 0,
"1": 0,
"4": 0
},
"rob": {
"robs_success": 0,
"robs_failed": 0,
"bail_paid": 0.0
}
}

View File

@ -0,0 +1,12 @@
{
"Algoritmen en Datastructuren 2": [],
"Communicatienetwerken": [],
"Computerarchitectuur": [],
"Functioneel Programmeren": [],
"Multimedia": [],
"Software Engineering Lab 1": [],
"Statistiek en Probabiliteit": [],
"Systeemprogrammeren": [],
"Webdevelopment": [],
"Wetenschappelijk Rekenen": []
}

View File

@ -1,5 +1,6 @@
from discord.ext import commands, ipc
from settings import HOST_IPC
from startup.init_files import check_all
import os
@ -22,8 +23,12 @@ class Didier(commands.Bot):
# Remove default help command
self.remove_command("help")
# Load all extensions
self.init_extensions()
# Check missing files
check_all()
def init_extensions(self):
# Load initial extensions
for ext in self._preload:

View File

@ -1,5 +1,13 @@
import json
from os import path
def check_all():
pass
files = ["hangman", "lastTasks", "locked", "lost", "stats", "ufora_notifications"]
for f in files:
if not path.isfile(path.join(f"files/{f}.json")):
with open(f"files/{f}.json", "w+") as new_file, open(f"files/default/{f}.json", "r") as default:
content = json.load(default)
json.dump(content, new_file)
print(f"Created missing file: files/{f}.json")