A-0.3 - Basismodul #36

Merged
edraft merged 48 commits from 0.3 into Alpha 2021-12-27 18:17:42 +01:00
Showing only changes of commit 10ba511158 - Show all commits

View File

@ -19,6 +19,7 @@ from gismo_data.model.known_user import KnownUser
from gismo_data.model.server import Server
from gismo_data.model.user import User
from gismo_data.model.user_joined_server import UserJoinedServer
from gismo_data.model.user_joined_voice_channel import UserJoinedVoiceChannel
from gismo_data.service.user_repository_service import ServerRepositoryABC
from modules_core.abc.events.on_ready_abc import OnReadyABC
from modules_core.abc.module_abc import ModuleABC
@ -281,6 +282,25 @@ class Database(ModuleABC, OnReadyABC):
# todo: maybe add XP
self._db_context.save_changes()
for u in guild.members:
if u.bot:
self._logger.trace(__name__, f'User {u.id} is ignored, because its a bot')
continue
m: discord.Member = u
if m.voice is None:
continue
user = self._users.find_user_by_discord_id_and_server_id(u.id, server.server_id)
if user is None:
self._logger.fatal(__name__, f'User not found in database: {u.id}')
join = UserJoinedVoiceChannel(user, m.voice.channel.id, datetime.now())
self._user_joins_vc.add_user_joined_voice_channel(join)
self._db_context.save_changes()
self._logger.warn(__name__, f'VS {m.voice}')
except Exception as e:
self._logger.error(__name__, f'Cannot get UserJoinedVoiceChannel', e)