Прописываю код с сайтов и гайдов, но выдает ошибку при попытке активировать этот код
File "C:\Hibiki_Bot(!hb)\Hibiki.py", line 217, in on_message
users = json.load(f)
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
import discord
import json
from discord import utils
from discord.ext import commands
from discord.ext.commands import Bot
import config
import asyncio
import os
intents = discord.Intents.default()
intents.members = True
bot = discord.Client(intents=intents)
Bot = commands.Bot(command_prefix="!hbk ", intents=intents)
os.chdir(r'C:\Hibiki_Bot(!hb)')</blockquote>
@Bot.event
async def on_message(message):
with open('usersdata.json', 'r') as f:
users = json.load(f)
await update_data(users, message.author)
await add_exp(users, message.author, 1)
await level_up(users, message.author, message.channel)
with open('usersdata.json', 'w') as f:
json.dump(users, f)
async def update_data(users, user):
if not user.id in users:
users[user.id] = {}
users[user.id]['exper'] = 0
users[user.id]['level'] = 1
async def add_exp(users, user, exp):
users[user.id]['exper'] += exp
async def level_up(users,user,exp):
exper = users[user.id]['exper']
lvl_start = users[user.id]['level']
lvl_end = int(exper ** (1/4) )
if lvl_start < lvl_end:
await Bot.send_message(channel, '{}LvL up to level{}'.format(user.mention, lvl_end))
users[user.id]['level'] = lvl_end
Весь код ошибки
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\HP-pc\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\client.py", line 333, in _run_event
await coro(*args, **kwargs)
File "C:\Hibiki_Bot(!hb)\Hibiki.py", line 217, in on_message
users = json.load(f)
File "C:\Users\HP-pc\AppData\Local\Programs\Python\Python37\lib\json\__init__.py", line 296, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "C:\Users\HP-pc\AppData\Local\Programs\Python\Python37\lib\json\__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "C:\Users\HP-pc\AppData\Local\Programs\Python\Python37\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\HP-pc\AppData\Local\Programs\Python\Python37\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Заранее спасибо