Skip to content

Commit

Permalink
Adding RPC endpoint support (Client.fetch_application) (#1536)
Browse files Browse the repository at this point in the history
* Implement app_commands_badge in flags.py

* Update discord/flags.py

Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>

* Fetch_application

* RPC endpoint

* Update discord/http.py

* Update discord/flags.py

* Fix

* move

* Update discord/client.py

* Update client.py

Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>
Co-authored-by: Lala Sabathil <aiko@aitsys.dev>
Co-authored-by: Lala Sabathil <lala@pycord.dev>
  • Loading branch information
4 people committed Jul 31, 2022
1 parent a2d5787 commit ea4452e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
26 changes: 25 additions & 1 deletion discord/client.py
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,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.
Expand Down
3 changes: 3 additions & 0 deletions discord/http.py
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

0 comments on commit ea4452e

Please sign in to comment.