Skip to content

Commit

Permalink
feat: update get entitlements to include the new exclude_deleted arg
Browse files Browse the repository at this point in the history
  • Loading branch information
Snipy7374 committed Nov 24, 2024
1 parent d95db29 commit 3d31182
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions disnake/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3147,6 +3147,7 @@ def entitlements(
guild: Optional[Snowflake] = None,
skus: Optional[Sequence[Snowflake]] = None,
exclude_ended: bool = False,
exclude_deleted: bool = False,
oldest_first: bool = False,
) -> EntitlementIterator:
"""Retrieves an :class:`.AsyncIterator` that enables receiving entitlements for the application.
Expand Down Expand Up @@ -3186,6 +3187,8 @@ def entitlements(
The SKUs for which entitlements are retrieved.
exclude_ended: :class:`bool`
Whether to exclude ended/expired entitlements. Defaults to ``False``.
exclude_deleted: :class:`bool`
Whether to exclude deleted entitlements. Defaults to ``False``.
oldest_first: :class:`bool`
If set to ``True``, return entries in oldest->newest order. Defaults to ``False``.
Expand All @@ -3209,6 +3212,7 @@ def entitlements(
guild_id=guild.id if guild is not None else None,
sku_ids=[sku.id for sku in skus] if skus else None,
exclude_ended=exclude_ended,
exclude_deleted=exclude_deleted,
oldest_first=oldest_first,
)

Expand Down
2 changes: 2 additions & 0 deletions disnake/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -2360,10 +2360,12 @@ def get_entitlements(
guild_id: Optional[Snowflake] = None,
sku_ids: Optional[SnowflakeList] = None,
exclude_ended: bool = False,
exclude_deleted: bool = False,
) -> Response[List[entitlement.Entitlement]]:
params: Dict[str, Any] = {
"limit": limit,
"exclude_ended": int(exclude_ended),
"exclude_deleted": int(exclude_deleted),
}
if before is not None:
params["before"] = before
Expand Down
4 changes: 4 additions & 0 deletions disnake/iterators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,7 @@ def __init__(
before: Optional[Union[Snowflake, datetime.datetime]] = None,
after: Optional[Union[Snowflake, datetime.datetime]] = None,
exclude_ended: bool = False,
exclude_deleted: bool = False,
oldest_first: bool = False,
) -> None:
if isinstance(before, datetime.datetime):
Expand All @@ -1059,6 +1060,7 @@ def __init__(
self.guild_id: Optional[int] = guild_id
self.sku_ids: Optional[List[int]] = sku_ids
self.exclude_ended: bool = exclude_ended
self.exclude_deleted: bool = exclude_deleted

self.state: ConnectionState = state
self.request = state.http.get_entitlements
Expand Down Expand Up @@ -1116,6 +1118,7 @@ async def _before_strategy(self, retrieve: int) -> List[EntitlementPayload]:
user_id=self.user_id,
guild_id=self.guild_id,
exclude_ended=self.exclude_ended,
exclude_deleted=self.exclude_deleted,
)

if len(data):
Expand All @@ -1133,6 +1136,7 @@ async def _after_strategy(self, retrieve: int) -> List[EntitlementPayload]:
user_id=self.user_id,
guild_id=self.guild_id,
exclude_ended=self.exclude_ended,
exclude_deleted=self.exclude_deleted,
)

if len(data):
Expand Down

0 comments on commit 3d31182

Please sign in to comment.