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

App Premium implementation #9453

Merged
merged 63 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
3d1157c
Initial app premium implementation
Luc1412 Jun 17, 2023
1a24f72
Fix typing for sku
Luc1412 Jun 17, 2023
37906ad
Fix entitlement params being not always in the response
Luc1412 Jun 17, 2023
4b7bc95
add missing import for sku in the __init__
Luc1412 Jun 17, 2023
7212689
reformat with black
Luc1412 Jun 17, 2023
2bc8e32
Handle missing application id for new sku related method to ensure ty…
Luc1412 Jun 17, 2023
bcefd8f
Use snowflake list instead of List[Snowflake]
Luc1412 Jun 17, 2023
ae2fb78
Change Client.entitlements to an async iterator
Luc1412 Jun 18, 2023
9604b2e
Fix datetime type check in entitlement iterator
Luc1412 Jun 18, 2023
aead217
Fix exclude_ended boolean not being converted to int
Luc1412 Jun 18, 2023
f70abdf
Fix entitlement event documentation
Luc1412 Jun 18, 2023
e8fa2e2
Move __all__ in sku.py to the right position
Luc1412 Jul 5, 2023
b87d8db
Update branch
Luc1412 Jul 5, 2023
2bd16dd
add new enums to __all__
Luc1412 Jul 8, 2023
736f738
rename sku function to fetch_skus to better represent it's return type
Luc1412 Jul 8, 2023
166d841
Add user_id arg for Client.entitlements()
Luc1412 Jul 20, 2023
7b55573
Rename server_subscription to guild_subscription.
Luc1412 Jul 27, 2023
c972611
update branch
Luc1412 Aug 10, 2023
90337f3
Merge branch 'Rapptz:master' into app-premium
Luc1412 Aug 12, 2023
0266db4
Merge branch 'Rapptz:master' into app-premium
Luc1412 Sep 23, 2023
d81bca4
Update SKU and Entitlement Cogs according to the released docs
Luc1412 Sep 26, 2023
7eb7f74
Implement methods to create and delete test entitlements
Luc1412 Sep 26, 2023
274c8ef
Merge remote-tracking branch 'origin/app-premium' into app-premium
Luc1412 Sep 26, 2023
5dc8cc6
Fix imports
Luc1412 Sep 26, 2023
cefe476
Add exception documentation for creating and deleting test entitlements
Luc1412 Sep 28, 2023
4d95533
Expand __all__ from sku.py to making it future-proof
Luc1412 Sep 28, 2023
5b57a3a
Improve SKU and Entitlement descriptions to better explain what they …
Luc1412 Sep 28, 2023
09b9aa4
Sort Entitlement related events to retain the alphabetic order
Luc1412 Sep 28, 2023
714dd3d
Add SKU and Entitlement
Luc1412 Sep 28, 2023
5ecc138
Fix references in docstrings
Luc1412 Sep 28, 2023
b0f2ee6
Improve code according to review
Luc1412 Sep 29, 2023
f577e1c
Add missing version added to fetch_skus
Luc1412 Sep 30, 2023
e41a525
Add return section for fetch_entitlement
Luc1412 Sep 30, 2023
0a4cbe7
Adjust entitlements() for the parameter changes
Luc1412 Sep 30, 2023
bd0e6f3
Move function to delete entitlements into Entitlement
Luc1412 Sep 30, 2023
c1cc5d7
Add user util to Entitlement
Luc1412 Sep 30, 2023
b06349f
Merge branch 'master' into app-premium
Luc1412 Sep 30, 2023
5adb19e
Fix docstrings
Luc1412 Sep 30, 2023
1e73dfa
Add check if user_id of entitlement is null for user() property
Luc1412 Sep 30, 2023
9ca1250
Add EntitlementOwnerType enum for creating a new test entitlement
Luc1412 Sep 30, 2023
20964e0
Change owner_id to owner snowflake when creating test entitlements
Luc1412 Sep 30, 2023
5373b42
Format code with black and cleanup unused imports
Luc1412 Sep 30, 2023
419b564
Merge branch 'Rapptz:master' into app-premium
Luc1412 Sep 30, 2023
0489dee
Remove unused undocumented attrs from Entitlement
Luc1412 Oct 2, 2023
b0e300e
Add created_at properties to SKU and Entitlement
Luc1412 Oct 2, 2023
a2dc390
Add is_expired to Entitlement
Luc1412 Oct 5, 2023
10ab0f9
Change Client.create_entitlement to use a SKU snowflake instead of an ID
Luc1412 Oct 5, 2023
e522e3a
Merge remote-tracking branch 'origin/app-premium' into app-premium
Luc1412 Oct 5, 2023
8e6414c
Fix invalid type for create_entitlement owner param
Luc1412 Oct 5, 2023
0624fb3
Merge branch 'Rapptz:master' into app-premium
Luc1412 Oct 5, 2023
c86624d
Handle ends_at being None in is_expired
Luc1412 Oct 5, 2023
d85f394
Apply suggestions from code review
Luc1412 Oct 8, 2023
0b7d088
Add missing headers for sku.py and types/sku.py
Luc1412 Oct 8, 2023
0d0110c
Add SKUFlags to __all__
Luc1412 Oct 8, 2023
1699d94
Cleanup types according to docs
Luc1412 Oct 8, 2023
48be5fe
Raname EntitlementType to EntitlementOwnerType
Luc1412 Oct 8, 2023
6aa6050
Merge remote-tracking branch 'origin/app-premium' into app-premium
Luc1412 Oct 8, 2023
a9ca0d7
Update discord/flags.py
Luc1412 Oct 8, 2023
931d02d
Update Entitlement according to docs changes
Luc1412 Oct 8, 2023
1910a1f
Merge remote-tracking branch 'origin/app-premium' into app-premium
Luc1412 Oct 8, 2023
fe00387
Format code with black
Luc1412 Oct 8, 2023
7490ed2
Update check for Client.entitlements which still used MISSING instead…
Luc1412 Oct 15, 2023
da9e548
Apply suggestions from code review
Luc1412 Oct 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions discord/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2834,7 +2834,7 @@ async def _after_strategy(retrieve: int, after: Optional[Snowflake], limit: Opti

async def create_entitlement(
self,
sku_id: int,
sku: Snowflake,
owner: Snowflake,
owner_type: EntitlementOwnerType,
) -> None:
Expand All @@ -2846,8 +2846,8 @@ async def create_entitlement(

Parameters
-----------
sku_id: :class:`int`
The ID of the SKU to create the entitlement for.
sku: :class:`~discord.abc.Snowflake`
The SKU to create the entitlement for.
owner: Optional[:class:`~discord.abc.Snowflake`]
The ID of the owner.
owner_type: :class:`.EntitlementOwnerType`
Expand Down
4 changes: 4 additions & 0 deletions discord/sku.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ def created_at(self) -> datetime:
""":class:`datetime.datetime`: Returns the entitlement's creation time in UTC."""
return utils.snowflake_time(self.id)

def is_expired(self) -> bool:
""":class:`bool`: Returns ``True`` if the entitlement is expired."""
return utils.utcnow() >= self.ends_at
Luc1412 marked this conversation as resolved.
Show resolved Hide resolved

async def delete(self) -> None:
"""|coro|

Expand Down