diff --git a/royalpack/stars/__init__.py b/royalpack/stars/__init__.py index 209efcfa..a5f71714 100644 --- a/royalpack/stars/__init__.py +++ b/royalpack/stars/__init__.py @@ -6,6 +6,7 @@ from .api_diario_get import ApiDiarioGetStar from .api_discord_cv import ApiDiscordCvStar from .api_wiki_get import ApiWikiGetStar from .api_wiki_list import ApiUserListStar +from .api_discord_play import ApiDiscordPlayStar # Enter the PageStars of your Pack here! available_page_stars = [ @@ -16,6 +17,7 @@ available_page_stars = [ ApiDiscordCvStar, ApiWikiGetStar, ApiUserListStar, + ApiDiscordPlayStar, ] # Enter the ExceptionStars of your Pack here! diff --git a/royalpack/stars/api_discord_play.py b/royalpack/stars/api_discord_play.py new file mode 100644 index 00000000..fc29674b --- /dev/null +++ b/royalpack/stars/api_discord_play.py @@ -0,0 +1,18 @@ +from typing import * +from starlette.requests import Request +from starlette.responses import * +from royalnet.constellation import * +from royalnet.utils import * + + +class ApiDiscordPlayStar(PageStar): + path = "/api/discord/play" + + async def page(self, request: Request) -> JSONResponse: + url = request.query_params.get("url", "") + try: + guild_id: Optional[int] = int(request.path_params.get("guild_id", None)) + except (ValueError, TypeError): + guild_id = None + response = await self.interface.call_herald_event("discord", "discord_play", url=url, guild_id=guild_id) + return JSONResponse(response)