Skip to content

Commit

Permalink
feat: implement new entitlement endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Snipy7374 committed Nov 24, 2024
1 parent 3d31182 commit b0e272b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelog/1249.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Add the new ``exclude_deleted``` argument to :meth:`.Client.entitlements`.
- Add the new :meth:`.Client.fetch_entitlement` method.
30 changes: 30 additions & 0 deletions disnake/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions disnake/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b0e272b

Please sign in to comment.