[WIP] Added server dashboard #72

This commit is contained in:
2022-10-17 19:44:28 +02:00
parent a69c223a33
commit 2a97438417
15 changed files with 181 additions and 14 deletions

View File

@@ -57,3 +57,9 @@ class ServerController:
result = await self._discord_service.get_filtered_servers_async(dto)
result.result = result.result.select(lambda x: x.to_dict())
return jsonify(result.to_dict())
@Route.get(f'{BasePath}/get/<id>')
@Route.authorize
async def get_server_by_id(self, id: int) -> Response:
result = await self._discord_service.get_server_by_id_async(id)
return jsonify(result.to_dict())

View File

@@ -89,3 +89,10 @@ class DiscordService:
List(ServerDTO, result),
filtered_result.total_count
)
async def get_server_by_id_async(self, id: int) -> ServerDTO:
server = self._servers.get_server_by_id(id)
guild = self._bot.get_guild(server.discord_server_id)
server_dto = ServerTransformer.to_dto(server, guild.name, guild.member_count, guild.icon)
return server_dto