From b0e272bbd8f1c0011f377e2c721652a19101f99e Mon Sep 17 00:00:00 2001 From: Snipy7374 <100313469+Snipy7374@users.noreply.github.com> Date: Sun, 24 Nov 2024 16:43:43 +0100 Subject: [PATCH] feat: implement new entitlement endpoint --- changelog/1249.feature.rst | 2 ++ disnake/client.py | 30 ++++++++++++++++++++++++++++++ disnake/http.py | 12 ++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 changelog/1249.feature.rst diff --git a/changelog/1249.feature.rst b/changelog/1249.feature.rst new file mode 100644 index 0000000000..2cb1f104ee --- /dev/null +++ b/changelog/1249.feature.rst @@ -0,0 +1,2 @@ +- Add the new ``exclude_deleted``` argument to :meth:`.Client.entitlements`. +- Add the new :meth:`.Client.fetch_entitlement` method. diff --git a/disnake/client.py b/disnake/client.py index 7dcf3e6810..876445d5bb 100644 --- a/disnake/client.py +++ b/disnake/client.py @@ -3216,6 +3216,36 @@ def entitlements( oldest_first=oldest_first, ) + async def fetch_entitlement(self, /, entitlement_id: int) -> Entitlement: + """|coro| + + Retrieves a :class:`.Entitlement` for the given ID. + + .. note:: + + This method is an API call. To get the entitlements of the invoking user/guild + in interactions, consider using :attr:`.Interaction.entitlements`. + + .. versionadded:: 2.10 + + Parameters + ---------- + entitlement_id: :class:`int` + The ID of the entitlement to retrieve. + + Raises + ------ + HTTPException + Retrieving the entitlement failed. + + Returns + ------- + :class:`.Entitlement` + The retrieved entitlement. + """ + data = await self.http.get_entitlement(self.application_id, entitlement_id=entitlement_id) + return Entitlement(data=data, state=self._connection) + async def create_entitlement( self, sku: Snowflake, owner: Union[abc.User, Guild] ) -> Entitlement: diff --git a/disnake/http.py b/disnake/http.py index 53e0006968..f477204dd3 100644 --- a/disnake/http.py +++ b/disnake/http.py @@ -2383,6 +2383,18 @@ def get_entitlements( ) return self.request(r, params=params) + def get_entitlement( + self, application_id: Snowflake, *, entitlement_id: int + ) -> Response[entitlement.Entitlement]: + return self.request( + Route( + "GET", + "/applications/{application_id}/entitlements/{entitlement_id}", + application_id=application_id, + entitlement_id=entitlement_id, + ) + ) + def create_test_entitlement( self, application_id: Snowflake,