From 27363522d3150ea031c1bf8b5995e602702f9177 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Thu, 30 Mar 2023 14:29:31 +0200 Subject: [PATCH] Fixed xp input #285 --- kdb-bot/src/bot_graphql/mutations/user_mutation.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kdb-bot/src/bot_graphql/mutations/user_mutation.py b/kdb-bot/src/bot_graphql/mutations/user_mutation.py index 44ef7070..9cd71438 100644 --- a/kdb-bot/src/bot_graphql/mutations/user_mutation.py +++ b/kdb-bot/src/bot_graphql/mutations/user_mutation.py @@ -37,12 +37,13 @@ class UserMutation(QueryABC): user = self._users.get_user_by_id(input["id"]) self._can_user_mutate_data(user.server, UserRoleEnum.moderator) + new_xp = None if "levelId" in input: level = self._levels.get_level_by_id(input["levelId"]) if user.level.id != level.id: - user.xp = level.min_xp - else: - user.xp = input["xp"] if "xp" in input else user.xp + new_xp = level.min_xp + + user.xp = new_xp if new_xp is not None else input["xp"] if "xp" in input else user.xp self._users.update_user(user) self._db.save_changes()