I'm python begineer and I made this code:
async def rejestracja(ctx):
# pobieranie
user_id = ctx.author.id
user_nickname = ctx.author.name # Użyj normalnego nicku
# otworzenie
with open("database.json", "r") as file:
data = json.load(file)
# sprawdzanie
if str(user_id) in data:
embed = discord.Embed(title="Błąd", description="Użytkownik już istnieje w bazie danych.", color=discord.Color.red())
await ctx.reply(embed=embed)
else:
# dodawanie
data[str(user_id)] = {"nickname": user_nickname, "value": 0}
with open("database.json", "w") as file:
json.dump(data, file, indent=4)
embed = discord.Embed(title="Rejestracja", description=f"Pomyślnie zarejestrowano użytkownika {user_nickname}!", color=discord.Color.green())
await ctx.reply(embed=embed)```
This code supposed to register user after usage to JSON and throw error if its already registered. But problem is im getting this error: `2024-07-10T11:54:04.744714496Z discord.ext.commands.errors.CommandInvokeError: Command raised an exception: JSONDecodeError: Expecting value: line 1 column 1 (char 0)[0m` and i dont know how do i fix it