mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Add api_discord_play endpoint
This commit is contained in:
parent
a80e94bb83
commit
6514d56519
2 changed files with 20 additions and 0 deletions
|
@ -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!
|
||||
|
|
18
royalpack/stars/api_discord_play.py
Normal file
18
royalpack/stars/api_discord_play.py
Normal file
|
@ -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)
|
Loading…
Reference in a new issue