Fixed ontime calculation
This commit is contained in:
parent
9658a5c238
commit
96b54fdbc9
@ -7,7 +7,6 @@ from cpl_core.database.context import DatabaseContextABC
|
|||||||
from cpl_core.logging import LoggerABC
|
from cpl_core.logging import LoggerABC
|
||||||
from cpl_discord.events import OnVoiceStateUpdateABC
|
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_core.helper.event_checks import EventChecks
|
||||||
from bot_data.abc.known_user_repository_abc import KnownUserRepositoryABC
|
from bot_data.abc.known_user_repository_abc import KnownUserRepositoryABC
|
||||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||||
@ -34,7 +33,6 @@ class BaseOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC):
|
|||||||
users: UserRepositoryABC,
|
users: UserRepositoryABC,
|
||||||
user_joins: UserJoinedServerRepositoryABC,
|
user_joins: UserJoinedServerRepositoryABC,
|
||||||
user_joins_vc: UserJoinedVoiceChannelRepositoryABC,
|
user_joins_vc: UserJoinedVoiceChannelRepositoryABC,
|
||||||
client_utils: ClientUtilsABC,
|
|
||||||
db: DatabaseContextABC,
|
db: DatabaseContextABC,
|
||||||
):
|
):
|
||||||
OnVoiceStateUpdateABC.__init__(self)
|
OnVoiceStateUpdateABC.__init__(self)
|
||||||
@ -46,7 +44,6 @@ class BaseOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC):
|
|||||||
self._users = users
|
self._users = users
|
||||||
self._user_joins = user_joins
|
self._user_joins = user_joins
|
||||||
self._user_joins_vc = user_joins_vc
|
self._user_joins_vc = user_joins_vc
|
||||||
self._client_utils = client_utils
|
|
||||||
self._db = db
|
self._db = db
|
||||||
|
|
||||||
self._logger.info(__name__, f"Module {type(self)} loaded")
|
self._logger.info(__name__, f"Module {type(self)} loaded")
|
||||||
@ -76,7 +73,7 @@ class BaseOnVoiceStateUpdateEvent(OnVoiceStateUpdateABC):
|
|||||||
join.leaved_on = datetime.now()
|
join.leaved_on = datetime.now()
|
||||||
|
|
||||||
# ontime as hours
|
# 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
|
old_xp = user.xp
|
||||||
user.xp += round(ontime * settings.xp_per_ontime_hour)
|
user.xp += round(ontime * settings.xp_per_ontime_hour)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user