Fixed ontime calculation

This commit is contained in:
Sven Heidemann 2023-01-14 01:20:59 +01:00
parent 9658a5c238
commit 96b54fdbc9

View File

@ -7,7 +7,6 @@ from cpl_core.database.context import DatabaseContextABC
from cpl_core.logging import LoggerABC
from cpl_discord.events import OnVoiceStateUpdateABC
from bot_core.abc.client_utils_abc import ClientUtilsABC
from bot_core.helper.event_checks import EventChecks
from bot_data.abc.known_user_repository_abc import KnownUserRepositoryABC
from bot_data.abc.server_repository_abc import ServerRepositoryABC
@ -34,7 +33,6 @@ class BaseOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC):
users: UserRepositoryABC,
user_joins: UserJoinedServerRepositoryABC,
user_joins_vc: UserJoinedVoiceChannelRepositoryABC,
client_utils: ClientUtilsABC,
db: DatabaseContextABC,
):
OnVoiceStateUpdateABC.__init__(self)
@ -46,7 +44,6 @@ class BaseOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC):
self._users = users
self._user_joins = user_joins
self._user_joins_vc = user_joins_vc
self._client_utils = client_utils
self._db = db
self._logger.info(__name__, f"Module {type(self)} loaded")
@ -76,7 +73,7 @@ class BaseOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC):
join.leaved_on = datetime.now()
# ontime as hours
ontime = self._client_utils.get_ontime_for_user(user)
ontime = round((join.leaved_on - join.joined_on).total_seconds() / 3600, 2)
old_xp = user.xp
user.xp += round(ontime * settings.xp_per_ontime_hour)