Хотел подружить один API с Discord, но выдаёт ошибку, когда ввожу команду ">>profile {ник игрока}". Ошибка:
Traceback (most recent call last):
File "C:\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\Артем\Desktop\VimeBot.py", line 16, in profile
await ctx.send(f"""```Ник: {str(profile['username'])}
TypeError: string indices must be integers
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Python39\lib\site-packages\discord\ext\commands\bot.py", line 902, in invoke
await ctx.command.invoke(ctx)
File "C:\Python39\lib\site-packages\discord\ext\commands\core.py", line 864, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Python39\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: string indices must be integers
Функция, которая отвечает за эту команду:
async def profile(ctx, arg1):
profile = requests.get(f"https://api.vimeworld.ru/user/name/{arg1}").text
jsonprofile = json.loads(profile)
await ctx.send(f"""```Ник: {str(profile['username'])}
ID: {profile['id']}```""")