Added logic to load clients on_ready

This commit is contained in:
2021-12-01 20:49:58 +01:00
parent d27964372d
commit 026dfe0dfb
4 changed files with 82 additions and 9 deletions

View File

@@ -83,6 +83,25 @@ class ClientRepositoryService(ClientRepositoryABC):
self._servers.get_server_by_id(result[7]),
id=result[0]
)
def find_client_by_server_id(self, discord_id: int) -> Optional[Client]:
self._logger.trace(__name__, f'Send SQL command: {Client.get_select_by_server_id_string(discord_id)}')
result = self._context.select(Client.get_select_by_server_id_string(discord_id))
if result is None or len(result) == 0:
return None
result = result[0]
return Client(
result[1],
result[2],
result[3],
result[4],
result[5],
result[6],
self._servers.get_server_by_id(result[7]),
id=result[0]
)
def add_client(self, client: Client):
self._logger.trace(__name__, f'Send SQL command: {client.insert_string}')