@AdvoKappa

TypeError: '>' not supported between instances of 'str' and 'int', что делать?

@bot.command(pass_context = True)
async def Test(ctx):
    if 'coins' > 15500:
        coins = users[str(user.id)]['coins']

    with open('users.json', 'r') as f:
        users = json.load(f)

    await add_coins(users, message.author, 50000)

    with open('users.json','w') as f:
        json.dump(users, f)

async def add_coins(users, user, coin):
    users[str(user.id)]['coins'] += coin


ошибка такова:
Traceback (most recent call last):
  File "C:\Users\stas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\bot.py", line 892, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\stas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 797, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\stas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 92, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: '>' not supported between instances of 'str' and 'int'
  • Вопрос задан
  • 1389 просмотров
Решения вопроса 1
sergey-gornostaev
@sergey-gornostaev Куратор тега Python
Седой и строгий
Не сравнивать число со строкой.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы