Answer the question
In order to leave comments, you need to log in
Why do two if comparison statements overlap?
@bot.command()
async def M1(message):
with open('coins.json', 'r') as f:
users = json.load(f)
await update_data(users, message.author)
await start(users, message.author, message)
async def start(users, user, message):
if users[str(user.id)]['coins'] > 3065000:
await update_data(users, message.author)
await delete_coins(users, message.author, 3065000)
await send(message)
else:
await message.channel.send('Недостаточно средств для покупки.')
with open('coins.json','w') as f:
json.dump(users, f)
async def update_data(users, user):
if not str(user.id) in users:
users[str(user.id)] = {}
users[str(user.id)]['coins'] = 0
async def delete_coins(users, user, coin):
users[str(user.id)]['coins'] -= coin
async def send(message):
await message.channel.send(f'Да')
@bot.command()
async def M2(message):
with open('coins.json', 'r') as f:
users = json.load(f)
await update_data(users, message.author)
await start(users, message.author, message)
async def start(users, user, message):
if users[str(user.id)]['coins'] > 2065000:
await update_data(users, message.author)
await delete_coins(users, message.author, 2065000)
await send(message)
else:
await message.channel.send('Недостаточно средств для покупки')
with open('coins.json','w') as f:
json.dump(users, f)
async def update_data(users, user):
if not str(user.id) in users:
users[str(user.id)] = {}
users[str(user.id)]['coins'] = 0
async def delete_coins(users, user, coin):
users[str(user.id)]['coins'] -= coin
async def send(message):
await message.channel.send(f'Да2')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question