I’m having a problem opening a JSON file, because it says that is doesn’t exists but, it does, it is in the same directory, here, you can see it:
But even though they are in the same folder, it says that it doesn’t exist:
Here is the code where outputs the error:
with open('warn.json', 'r', encoding='utf-8') as f:
guilds_dict = json.load(f)
if str(id) in guilds_dict:
guilds_dict[str(id)] += warns
else:
guilds_dict[str(id)] = warns
>Solution :
Try to use:
with open('/root/Nasgar/NasgarBot/cogs/moderation/warn.json', 'r', encoding='utf-8') as f:
guilds_dict = json.load(f)
if str(id) in guilds_dict:
guilds_dict[str(id)] += warns
else:
guilds_dict[str(id)] = warns
This should work.

