Merge pull request 'Added check with -xp to get_level' (#357) from fix_get_level_with_negative_xp into support

Reviewed-on: sh-edraft.de/kd_discord_bot#357
Reviewed-by: Ebola-Chan <nick.jungmann@gmail.com>
This commit is contained in:
Sven Heidemann 2023-09-10 22:23:33 +02:00
commit dca939f025

View File

@ -40,6 +40,9 @@ class LevelService:
def get_level(self, user: User) -> Level:
levels_by_server = self._levels.get_levels_by_server_id(user.server.id)
if user.xp < 0:
return levels_by_server.order_by(lambda l: l.min_xp).first()
levels = levels_by_server.order_by(lambda l: l.min_xp).where(lambda l: user.xp >= l.min_xp)
if levels.count() == 0: