From 0c93df47bcbd2cbd7456c518ed3db2dba70281f7 Mon Sep 17 00:00:00 2001 From: AlexandroBD <79316328+lol219@users.noreply.github.com> Date: Sat, 30 Jul 2022 19:34:09 +0100 Subject: [PATCH 01/10] Implement app_commands_badge in flags.py --- discord/flags.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/discord/flags.py b/discord/flags.py index 77ee96e142..98296194eb 100644 --- a/discord/flags.py +++ b/discord/flags.py @@ -281,6 +281,13 @@ def join_notification_replies(self): .. versionadded:: 2.0 """ 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 the bot's profile. + .. versionadded:: 2.0 + """ + return 1 << 23 @fill_with_flags() From 798330ae93d64727ed8409f60e295f7ed7555ddd Mon Sep 17 00:00:00 2001 From: AlexandroBD <79316328+lol219@users.noreply.github.com> Date: Sat, 30 Jul 2022 20:08:58 +0100 Subject: [PATCH 02/10] Update discord/flags.py Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> --- discord/flags.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/discord/flags.py b/discord/flags.py index 98296194eb..090d16e803 100644 --- a/discord/flags.py +++ b/discord/flags.py @@ -281,11 +281,13 @@ def join_notification_replies(self): .. versionadded:: 2.0 """ 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 the bot's profile. - .. versionadded:: 2.0 + command. This shows up as a badge in the bot's profile. + + .. versionadded:: 2.1 """ return 1 << 23 From 24b8ea887f8254705c7da9a2407ca2d571ff4581 Mon Sep 17 00:00:00 2001 From: AlexandroBD <79316328+lol219@users.noreply.github.com> Date: Sat, 30 Jul 2022 20:45:56 +0100 Subject: [PATCH 03/10] Fetch_application --- discord/client.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/discord/client.py b/discord/client.py index 99395ab68a..6992c19b84 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 @@ -482,6 +482,26 @@ async def before_identify_hook(self, shard_id: Optional[int], *, initial: bool = await asyncio.sleep(5.0) # login state management + 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| From 89f01d4b7353133d0505ebd2336b442df21d7ddf Mon Sep 17 00:00:00 2001 From: AlexandroBD <79316328+lol219@users.noreply.github.com> Date: Sat, 30 Jul 2022 20:54:20 +0100 Subject: [PATCH 04/10] RPC endpoint --- discord/http.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/discord/http.py b/discord/http.py index d1757000ce..b9aec61af7 100644 --- a/discord/http.py +++ b/discord/http.py @@ -811,7 +811,8 @@ def pin_message(self, channel_id: Snowflake, message_id: Snowflake, reason: Opti message_id=message_id, ) 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)) def unpin_message( self, channel_id: Snowflake, message_id: Snowflake, reason: Optional[str] = None ) -> Response[None]: From a37cbed98238f44c679255cfdb77946f6d1ac607 Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Sat, 30 Jul 2022 21:58:59 +0200 Subject: [PATCH 05/10] Update discord/http.py --- discord/http.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/discord/http.py b/discord/http.py index b9aec61af7..b2cdfa9244 100644 --- a/discord/http.py +++ b/discord/http.py @@ -811,8 +811,10 @@ def pin_message(self, channel_id: Snowflake, message_id: Snowflake, reason: Opti message_id=message_id, ) 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)) + def unpin_message( self, channel_id: Snowflake, message_id: Snowflake, reason: Optional[str] = None ) -> Response[None]: From bee335783e42cf6f3d58228b00d0988b48c625e3 Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Sat, 30 Jul 2022 21:59:51 +0200 Subject: [PATCH 06/10] Update discord/flags.py --- discord/flags.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/discord/flags.py b/discord/flags.py index 090d16e803..77ee96e142 100644 --- a/discord/flags.py +++ b/discord/flags.py @@ -282,15 +282,6 @@ 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 - @fill_with_flags() class MessageFlags(BaseFlags): From 5f279d9e57a14bb2c8a5078f22e50638f65b6383 Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Sat, 30 Jul 2022 22:07:09 +0200 Subject: [PATCH 07/10] Fix --- discord/http.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/discord/http.py b/discord/http.py index b2cdfa9244..24ec58ce69 100644 --- a/discord/http.py +++ b/discord/http.py @@ -812,9 +812,6 @@ 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)) - def unpin_message( self, channel_id: Snowflake, message_id: Snowflake, reason: Optional[str] = None ) -> Response[None]: @@ -2615,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")) From 08d3c01a7d99c922fd1648c312cdab6e87f08259 Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Sat, 30 Jul 2022 22:10:00 +0200 Subject: [PATCH 08/10] move --- discord/client.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/discord/client.py b/discord/client.py index 6992c19b84..a8fa3f77a4 100644 --- a/discord/client.py +++ b/discord/client.py @@ -482,27 +482,6 @@ async def before_identify_hook(self, shard_id: Optional[int], *, initial: bool = await asyncio.sleep(5.0) # login state management - 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| @@ -810,6 +789,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. From ade820be4a6085c032619d603a0291538c209032 Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Sat, 30 Jul 2022 22:10:20 +0200 Subject: [PATCH 09/10] Update discord/client.py --- discord/client.py | 1 + 1 file changed, 1 insertion(+) diff --git a/discord/client.py b/discord/client.py index a8fa3f77a4..67f2a17faf 100644 --- a/discord/client.py +++ b/discord/client.py @@ -482,6 +482,7 @@ async def before_identify_hook(self, shard_id: Optional[int], *, initial: bool = await asyncio.sleep(5.0) # login state management + async def login(self, token: str) -> None: """|coro| From fd969a4920dc66d03413ed7ee4746373a9f3ac91 Mon Sep 17 00:00:00 2001 From: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Date: Sun, 31 Jul 2022 13:41:21 +0300 Subject: [PATCH 10/10] Update client.py --- discord/client.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/discord/client.py b/discord/client.py index 67f2a17faf..71a43d56bf 100644 --- a/discord/client.py +++ b/discord/client.py @@ -793,16 +793,19 @@ def users(self) -> List[User]: 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`