Entitlements

discord_http.entitlements module

class discord_http.entitlements.SKU(*, state, data)

Bases: PartialSKU

Represents a SKU (Stock Keeping Unit) object.

Parameters:
name: str

The name of the SKU.

slug: str

The slug of the SKU.

application_id: int

The ID of the application that owns the SKU.

property application: PartialUser

The application that owns the SKU.

property type: SKUType

The type of the SKU.

property flags: SKUFlags

The flags of the SKU.

async create_test_entitlement(*, owner_id, owner_type) → PartialEntitlements

Create an entitlement for testing purposes.

Parameters:
Return type:

PartialEntitlements

Returns:

The created entitlement.

property created_at: datetime

The datetime of the snowflake.

async fetch_subscription(subscription_id) → Subscription

Fetch a specific subscription for this SKU.

Parameters:

subscription_id (Snowflake | int) – The ID of the subscription to fetch

Return type:

Subscription

Returns:

The subscription

async fetch_subscriptions(user_id, *, before=None, after=None, limit=50) → list[Subscription]

Fetch the subscriptions for this SKU.

Parameters:
  • user_id (Snowflake | int) – The user ID to fetch subscriptions for. Required for bot-token requests (only optional when using an OAuth2 access token, which this library does not support).

  • before (Snowflake | int | None) – Consider only subscriptions before given ID

  • after (Snowflake | int | None) – Consider only subscriptions after given ID

  • limit (int) – The maximum amount of subscriptions to fetch (1-100)

Return type:

list[Subscription]

Returns:

The subscriptions for this SKU

get_partial_subscription(subscription_id) → PartialSubscription

Creates a partial subscription object under this SKU, without fetching it.

Parameters:

subscription_id (Snowflake | int) – The ID of the subscription

Return type:

PartialSubscription

Returns:

The partial subscription object

id: int

The ID of the snowflake.

class discord_http.entitlements.Entitlements(*, state, data)

Bases: PartialEntitlements

Represents an entitlement object.

Parameters:
deleted: bool

Whether the entitlement is deleted or not.

type: EntitlementType

The type of the entitlement.

user_id: int | None

The ID of the user that owns the entitlement, if the owner type is user.

guild_id: int | None

The guild ID that owns the entitlement, if the owner type is guild.

subscription_id: int | None

The subscription ID that the entitlement belongs to, if any.

application_id: int

The ID of the application that owns the entitlement.

sku_id: int

The ID of the SKU that the entitlement belongs to.

starts_at: datetime | None

The time the entitlement starts at, if any.

ends_at: datetime | None

The time the entitlement ends at, if any.

property application: PartialUser

The application that owns the entitlement.

property sku: PartialSKU

The SKU that the entitlement belongs to.

property user: PartialUser | None

The user that owns the entitlement, if the owner type is user.

property guild: Guild | PartialGuild | None

The guild the entitlement is in.

property subscription: PartialSubscription | None

The partial subscription this entitlement belongs to, if any.

is_consumed() → bool

Returns whether the entitlement is consumed or not.

Return type:

bool

async consume() → None

Mark the entitlement as consumed.

Return type:

None

property created_at: datetime

The datetime of the snowflake.

async delete_test_entitlement() → None

Deletes a test entitlement.

Return type:

None

async fetch() → Entitlements

Fetches the entitlement.

Return type:

Entitlements

id: int

The ID of the snowflake.

class discord_http.entitlements.PartialEntitlements(*, state, id)

Bases: PartialBase

Represents a partial entitlement object.

Parameters:
async fetch() → Entitlements

Fetches the entitlement.

Return type:

Entitlements

async consume() → None

Mark the entitlement as consumed.

Return type:

None

async delete_test_entitlement() → None

Deletes a test entitlement.

Return type:

None

property created_at: datetime

The datetime of the snowflake.

id: int

The ID of the snowflake.

class discord_http.entitlements.PartialSKU(*, state, id)

Bases: PartialBase

Represents a partial SKU object.

Parameters:
async create_test_entitlement(*, owner_id, owner_type) → PartialEntitlements

Create an entitlement for testing purposes.

Parameters:
Return type:

PartialEntitlements

Returns:

The created entitlement.

async fetch_subscriptions(user_id, *, before=None, after=None, limit=50) → list[Subscription]

Fetch the subscriptions for this SKU.

Parameters:
  • user_id (Snowflake | int) – The user ID to fetch subscriptions for. Required for bot-token requests (only optional when using an OAuth2 access token, which this library does not support).

  • before (Snowflake | int | None) – Consider only subscriptions before given ID

  • after (Snowflake | int | None) – Consider only subscriptions after given ID

  • limit (int) – The maximum amount of subscriptions to fetch (1-100)

Return type:

list[Subscription]

Returns:

The subscriptions for this SKU

async fetch_subscription(subscription_id) → Subscription

Fetch a specific subscription for this SKU.

Parameters:

subscription_id (Snowflake | int) – The ID of the subscription to fetch

Return type:

Subscription

Returns:

The subscription

get_partial_subscription(subscription_id) → PartialSubscription

Creates a partial subscription object under this SKU, without fetching it.

Parameters:

subscription_id (Snowflake | int) – The ID of the subscription

Return type:

PartialSubscription

Returns:

The partial subscription object

property created_at: datetime

The datetime of the snowflake.

id: int

The ID of the snowflake.

class discord_http.entitlements.PartialSubscription(*, state, sku_id, id)

Bases: PartialBase

Represents a partial subscription object.

Parameters:
property sku: PartialSKU

The SKU this subscription is being looked up through.

async fetch() → Subscription

Fetches the subscription.

Return type:

Subscription

property created_at: datetime

The datetime of the snowflake.

id: int

The ID of the snowflake.

class discord_http.entitlements.Subscription(*, state, data, sku_id=None)

Bases: PartialBase

Represents a subscription object.

Parameters:
user_id: int

The ID of the user subscribed to the SKU(s).

sku_ids: list[int]

The SKUs the user is subscribed to.

property created_at: datetime

The datetime of the snowflake.

id: int

The ID of the snowflake.

entitlement_ids: list[int]

The entitlements granted for this subscription.

renewal_sku_ids: list[int] | None

The SKUs the user will be subscribed to at renewal, if any.

current_period_start: datetime

The start of the current subscription period.

current_period_end: datetime

The end of the current subscription period.

canceled_at: datetime | None

The time the subscription was canceled, if any.

country: str | None

The ISO 3166-1 alpha-2 country code of the payment source, if any.

property skus: list[PartialSKU]

The partial SKU objects this subscription applies to.

property renewal_skus: list[PartialSKU]

The partial SKU objects the user will be subscribed to at renewal, if any.

property entitlements: list[PartialEntitlements]

The partial entitlement objects granted for this subscription.

property status: SubscriptionStatus

The status of the subscription.

property user: PartialUser

The user subscribed to the SKU(s).

async fetch() → Subscription

Fetches the latest version of this subscription.

Raises:

ValueError – If no SKU is known to route the request through (should not happen for a subscription that came from the API, which always includes sku_ids)

Return type:

Subscription