Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding RPC endpoint support (Client.fetch_application) #1536

Merged
merged 11 commits into from
Jul 31, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion discord/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -790,6 +790,27 @@ 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.

Expand Down
3 changes: 3 additions & 0 deletions discord/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down