Answer the question
In order to leave comments, you need to log in
Why does the bot think that a larger value is a smaller one?
The code:
@bot.command()
async def Купить(message):
with open('coins.json', 'r') as f:
users = json.load(f)
with open('coins.json','w') as f:
json.dump(users, f)
await update_data(users, message.author)
await add_coins(users, message.author, 50000)
await coinss(message, users, message.author)
async def update_data(users, user):
if not str(user.id) in users:
users[str(user.id)] = {}
users[str(user.id)]['coins'] = 0
users[str(user.id)]['coinss'] = 0
async def add_coins(users, user, coin):
users[str(user.id)]['coins'] += coin
async def coinss(message, users, user):
users[str(user.id)]['coinss'] += 15000
coins = users[str(user.id)]['coins']
coinss = users[str(user.id)]['coinss']
if 'coins' > 'coinss':
await message.channel.send('Да')
else:
await message.channel.send('Нет')
{"293396418834464768": {"coins": 50000, "coinss": 15000}}
Answer the question
In order to leave comments, you need to log in
Because you are comparing two strings, not numbers:
'coins' > 'coinss'
>>> 'coins' > 'coinss'
False
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question