@client.event
async def on_message(message: discord.Message, *args):
await client.process_commands(message)
if message.author.bot == True:
pass
else:
if len(args) >= 10:
cursor.execute(f"UPDATE users SET xp = xp + 100 WHERE id = {message.author.id}")
connection.commit()
exp = cursor.execute(f"SELECT xp FROM users WHERE id = {message.author.id}").fetchone()
lvl = cursor.execute(f"SELECT lvl FROM users WHERE id = {message.author.id}").fetchone()
if lvl < 10:
if exp % 10000 == 0:
cursor.execute(f"UPDATE users SET lvl = lvl + 1 WHERE id = {message.author.id}")
connection.commit()
else:
pass
elif lvl < 20 and lvl >= 10:
if exp % 20000 == 0:
cursor.execute(f"UPDATE users SET lvl = lvl + 1 WHERE id = {message.author.id}")
connection.commit()
else:
pass
elif lvl < 100 and lvl >= 20:
if exp % 40000 == 0:
cursor.execute(f"UPDATE users SET lvl = lvl + 1 WHERE id = {message.author.id}")
connection.commit()
else:
pass
elif lvl < 300 and lvl >= 100:
if exp % 80000 == 0:
cursor.execute(f"UPDATE users SET lvl = lvl + 1 WHERE id = {message.author.id}")
connection.commit()
else:
pass
elif lvl < 700 and lvl >= 300:
if exp % 160000 == 0:
cursor.execute(f"UPDATE users SET lvl = lvl + 1 WHERE id = {message.author.id}")
connection.commit()
else:
pass
elif lvl < 1000 and lvl >= 700:
if exp % 320000 == 0:
cursor.execute(f"UPDATE users SET lvl = lvl + 1 WHERE id = {message.author.id}")
connection.commit()
else:
pass
conditions = [
{
'min_lvl': 0,
'max_lvl': 10,
'exp': 10000
},
{
'min_lvl': 10,
'max_lvl': 20,
'exp': 20000
},
]
for _cond in conditions:
if lvl < _cond['max_lvl'] and lvl >= _cond['min_lvl'] and exp % _cond['exp'] == 0:
cursor.execute(f"UPDATE users SET lvl = lvl + 1 WHERE id = {message.author.id}")
connection.commit()
break
if a == 5:
do_smth()
else:
if a > 10:
func()
else:
func2()
do_smth() if a == 5 else func() if a > 10 else func2()