from typing import Optional from .data import ( ProfilesData, UserProfile, DiscordProfileLink, TwitchProfileLink, Community, DiscordCommunityLink, TwitchCommunityLink, ) class ProfilesRegistry: VERSION = ProfilesData.VERSION def __init__(self, data: ProfilesData): self.data = data async def init(self): await self.data.init() async def get_profile(self, profileid: int) -> Optional[UserProfile]: return await UserProfile.fetch(profileid) async def get_profile_discord(self, userid: int) -> Optional[UserProfile]: link = await DiscordProfileLink.fetch(userid) if link: return await UserProfile.fetch(link.profileid) async def get_profile_twitch(self, userid: str) -> Optional[UserProfile]: userid = str(userid) link = await TwitchProfileLink.fetch(userid) if link: return await UserProfile.fetch(link.profileid) async def get_community(self, communityid: int) -> Optional[Community]: return await Community.fetch(communityid) async def get_community_discord(self, guildid: int) -> Optional[Community]: link = await DiscordCommunityLink.fetch(guildid) if link: return await Community.fetch(link.communityid) async def get_community_twitch(self, channelid: str) -> Optional[Community]: channelid = str(channelid) link = await TwitchCommunityLink.fetch(channelid) if link: return await Community.fetch(link.communityid)