A
A
AdvoKappa2020-06-04 19:39:29
Python
AdvoKappa, 2020-06-04 19:39:29

TypeError: '>' not supported between instances of 'str' and 'int', what should I do?

@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


the error is this:
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'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2020-06-04
@AdvoKappa

Do not compare number with string.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question