diff --git a/discord/client.py b/discord/client.py index 99395ab68a..71a43d56bf 100644 --- a/discord/client.py +++ b/discord/client.py @@ -49,7 +49,7 @@ from . import utils from .activity import ActivityTypes, BaseActivity, create_activity -from .appinfo import AppInfo +from .appinfo import AppInfo, PartialAppInfo from .backoff import ExponentialBackoff from .channel import PartialMessageable, _threaded_channel_factory from .emoji import Emoji @@ -790,6 +790,30 @@ def users(self) -> List[User]: """List[:class:`~discord.User`]: Returns a list of all the users the bot can see.""" return list(self._connection._users.values()) + async def fetch_application(self, application_id: int, /) -> PartialAppInfo: + """|coro| + Retrieves a :class:`.PartialAppInfo` from an application ID. + + Parameters + ----------- + application_id: :class:`int` + The application ID to retrieve information from. + + Raises + ------- + NotFound + An application with this ID does not exist. + HTTPException + Retrieving the application failed. + + Returns + -------- + :class:`.PartialAppInfo` + The application information. + """ + data = await self.http.get_application(application_id) + return PartialAppInfo(state=self._connection, data=data) + def get_channel(self, id: int, /) -> Optional[Union[GuildChannel, Thread, PrivateChannel]]: """Returns a channel or thread with the given ID. diff --git a/discord/http.py b/discord/http.py index d1757000ce..24ec58ce69 100644 --- a/discord/http.py +++ b/discord/http.py @@ -2612,6 +2612,9 @@ def bulk_edit_guild_application_command_permissions( def application_info(self) -> Response[appinfo.AppInfo]: return self.request(Route("GET", "/oauth2/applications/@me")) + def get_application(self, application_id: Snowflake, /) -> Response[appinfo.PartialAppInfo]: + return self.request(Route('GET', '/applications/{application_id}/rpc', application_id=application_id)) + async def get_gateway(self, *, encoding: str = "json", zlib: bool = True) -> str: try: data = await self.request(Route("GET", "/gateway"))