diff --git a/discord/appinfo.py b/discord/appinfo.py index d977727a8..c9659cbcc 100644 --- a/discord/appinfo.py +++ b/discord/appinfo.py @@ -73,7 +73,7 @@ class ApplicationBot(User): grant flow to join. """ - __slots__ = ('public', 'require_code_grant') + __slots__ = ('application', 'public', 'require_code_grant') def __init__(self, *, data, state: ConnectionState, application: Application): super().__init__(state=state, data=data) @@ -81,7 +81,7 @@ class ApplicationBot(User): self.public: bool = data['public'] self.require_code_grant: bool = data['require_code_grant'] - async def reset_token(self) -> None: + async def reset_token(self) -> str: """|coro| Resets the bot's token. diff --git a/discord/client.py b/discord/client.py index f9b28cd2d..e350fee9d 100644 --- a/discord/client.py +++ b/discord/client.py @@ -2681,6 +2681,65 @@ class Client: data = await state.http.get_partial_application(app_id) return PartialApplication(state=state, data=data) + async def fetch_public_application(self, app_id: int, /) -> PartialApplication: + """|coro| + + Retrieves the public application with the given ID. + + .. versionadded:: 2.0 + + Parameters + ----------- + app_id: :class:`int` + The ID of the public application to fetch. + + Raises + ------- + NotFound + The public application was not found. + HTTPException + Retrieving the public application failed. + + Returns + -------- + :class:`.PartialApplication` + The retrieved application. + """ + state = self._connection + data = await state.http.get_public_application(app_id) + return PartialApplication(state=state, data=data) + + async def fetch_public_applications(self, *app_ids: int) -> List[PartialApplication]: + r"""|coro| + + Retrieves a list of public applications. Only found applications are returned. + + .. versionadded:: 2.0 + + Parameters + ----------- + \*app_ids: :class:`int` + The IDs of the public applications to fetch. + + Raises + ------- + TypeError + Less than 1 ID was passed. + HTTPException + Retrieving the applications failed. + + Returns + ------- + List[:class:`.PartialApplication`] + The public applications. + """ + if not app_ids: + raise TypeError('fetch_public_applications() takes at least 1 argument (0 given)') + + state = self._connection + data = await state.http.get_public_applications(app_ids) + return [PartialApplication(state=state, data=d) for d in data] + async def teams(self) -> List[Team]: """|coro| diff --git a/discord/http.py b/discord/http.py index e735e43de..be3fba08b 100644 --- a/discord/http.py +++ b/discord/http.py @@ -2260,6 +2260,12 @@ class HTTPClient: def get_partial_application(self, app_id: Snowflake) -> Response[appinfo.PartialAppInfo]: return self.request(Route('GET', '/oauth2/applications/{app_id}/rpc', app_id=app_id)) + def get_public_application(self, app_id: Snowflake) -> Response[appinfo.PartialAppInfo]: + return self.request(Route('GET', '/applications/{app_id}/public', app_id=app_id)) + + def get_public_applications(self, app_ids: Sequence[Snowflake]) -> Response[List[appinfo.PartialAppInfo]]: + return self.request(Route('GET', '/applications/public'), params={'application_ids': app_ids}) + def create_app(self, name: str): payload = {'name': name}