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
22 changes: 21 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 @@ -482,6 +482,26 @@ async def before_identify_hook(self, shard_id: Optional[int], *, initial: bool =
await asyncio.sleep(5.0)

# login state management
Lulalaby marked this conversation as resolved.
Show resolved Hide resolved
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)

async def login(self, token: str) -> None:
"""|coro|
Expand Down
9 changes: 9 additions & 0 deletions discord/flags.py
Expand Up @@ -282,6 +282,15 @@ def join_notification_replies(self):
"""
return 8

@flag_value
def app_commands_badge(self):
""":class:`bool`: Returns ``True`` if the application has registered a global application
command. This shows up as a badge in the bot's profile.

.. versionadded:: 2.1
"""
return 1 << 23

Lulalaby marked this conversation as resolved.
Show resolved Hide resolved

@fill_with_flags()
class MessageFlags(BaseFlags):
Expand Down
3 changes: 3 additions & 0 deletions discord/http.py
Expand Up @@ -812,6 +812,9 @@ def pin_message(self, channel_id: Snowflake, message_id: Snowflake, reason: Opti
)
return self.request(r, reason=reason)

def get_application(self, application_id: Snowflake, /) -> Response[appinfo.PartialAppInfo]:
return self.request(Route('GET', '/applications/{application_id}/rpc', application_id=application_id))
Lulalaby marked this conversation as resolved.
Show resolved Hide resolved

def unpin_message(
self, channel_id: Snowflake, message_id: Snowflake, reason: Optional[str] = None
) -> Response[None]:
Expand Down