Profile schema and discord hook

This commit is contained in:
2025-08-25 23:23:41 +10:00
parent fc3bdcbb5c
commit 5fa0df66f5
8 changed files with 307 additions and 0 deletions

46
profiles/profiles.py Normal file
View File

@@ -0,0 +1,46 @@
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]:
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]:
link = await TwitchCommunityLink.fetch(channelid)
if link:
return await Community.fetch(link.communityid)