Бот в Discord Python почему то не видит id в json
Команда бота такова чтобы вырабатывать текст из json файла если там есть id этого пользователя.
@bot.command()
async def myprofile_parody(ctx):
with open("prefix2.json", "r") as read_file:
author = ctx.message.author
YourId = author.id
data33 = json.load(read_file)
data_length33 = len(data33)
await ctx.send(data33[YourId])
В файле prefix2.json используется id пользователя.
Но когда я ввожу команду у меня выводится ошибка
Traceback (most recent call last):
File "/home/runner/GrowlingClientsideMp3/venv/lib/python3.10/site-packages/discord/ext/commands/core.py", line 229, in wrapped
ret = await coro(*args, **kwargs)
File "/home/runner/GrowlingClientsideMp3/main.py", line 63, in myprofile_parody
await ctx.send(data33[YourId])
KeyError: 937028529130995783
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/runner/GrowlingClientsideMp3/venv/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 1349, in invoke
await ctx.command.invoke(ctx)
File "/home/runner/GrowlingClientsideMp3/venv/lib/python3.10/site-packages/discord/ext/commands/core.py", line 1023, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "/home/runner/GrowlingClientsideMp3/venv/lib/python3.10/site-packages/discord/ext/commands/core.py", line 238, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: 937028529130995783
Сам Json
{
"937028529130995783": "TVOFFicial1"
}