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

Add Entitlements / SKUs #1552

Merged
merged 29 commits into from
Dec 8, 2024
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f004123
add entitlement struct
jhoffi Aug 2, 2024
2e7eb30
add entitlements field to interaction struct
jhoffi Aug 2, 2024
4bbe559
add event handler for entitlements
jhoffi Aug 2, 2024
84ecf01
add description to Entitlement struct & type
jhoffi Aug 2, 2024
6725cb4
properly format changes in entitlement and events
jhoffi Aug 2, 2024
ccb5a90
format entitlement with gofmt
jhoffi Aug 2, 2024
7ad7e1b
move entitlement to structs
jhoffi Aug 2, 2024
87c3490
add subscription id to entitlement struct and add omitempty
jhoffi Aug 2, 2024
9620435
add endpoints
jhoffi Aug 2, 2024
38a1aff
add comments to EntitlementTest and EntitlementOwnerType
jhoffi Aug 2, 2024
efb7d7e
add sku struct
jhoffi Aug 2, 2024
351f5e9
add skus
jhoffi Aug 2, 2024
7bf00e8
fix typo
jhoffi Aug 2, 2024
d2057dc
rename skuid in entitlement struct
jhoffi Aug 2, 2024
b7ed8b8
add comments to SKUFlags
jhoffi Aug 2, 2024
5b3da13
change entitlement timestamps to time.Time
jhoffi Aug 2, 2024
34c29b0
rename skuid in entitlement-test struct
jhoffi Aug 3, 2024
6eb85e1
add documentation
jhoffi Aug 3, 2024
faf1279
remove undocumented subscriptionID field in entitlement struct
jhoffi Aug 3, 2024
887cdb3
add documentation
jhoffi Aug 3, 2024
20d5f76
update documentation
jhoffi Aug 14, 2024
54287e3
change order of EntitlementType values
jhoffi Aug 14, 2024
7cf6c73
move optional entitlement filter options into a separate struct
jhoffi Aug 15, 2024
2c97651
add premium button component
jhoffi Oct 5, 2024
e9b116e
add subscriptions
jhoffi Oct 5, 2024
d9d9f4b
optimize optional fields in entitlement struct
jhoffi Oct 5, 2024
621e4ad
Add documentation
jhoffi Oct 5, 2024
f81b609
typo
jhoffi Oct 5, 2024
347e932
remove unneccessary pointers
jhoffi Oct 15, 2024
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
Prev Previous commit
Next Next commit
move entitlement to structs
jhoffi committed Aug 2, 2024
commit 7ad7e1b9ed451222569e9d09812559a6350f3229
54 changes: 0 additions & 54 deletions entitlement.go

This file was deleted.

53 changes: 53 additions & 0 deletions structs.go
Original file line number Diff line number Diff line change
@@ -2389,6 +2389,59 @@ type Poll struct {
Expiry *time.Time `json:"expiry,omitempty"`
}

// EntitlementType is the type of entitlement (see EntitlementType* consts)
// https://discord.com/developers/docs/monetization/entitlements#entitlement-object-entitlement-types
type EntitlementType int

// Valid EntitlementType values
const (
EntitlementTypePurchase = 1
EntitlementTypePremiumSubscription = 2
EntitlementTypeDeveloperGift = 3
EntitlementTypeTestModePurchase = 4
EntitlementTypeFreePurchase = 5
EntitlementTypeUserGift = 6
EntitlementTypeApplicationSubscription = 8
EntitlementTypePremiumPurchase = 7
)

// Entitlement represents that a user or guild has access to a premium offering
// in your application.
type Entitlement struct {
// The ID of the entitlement
ID string `json:"id"`

// The ID of the SKU
SkuID string `json:"sku_id"`

// The ID of the parent application
ApplicationID string `json:"application_id"`

// The ID of the user that is granted access to the entitlement's sku
UserID string `json:"user_id"`

// The type of entitlement
Type EntitlementType `json:"type"`

// The entitlement was deleted
Deleted bool `json:"deleted"`

// The start date at which the entitlement is valid.
// Not present when using test entitlements.
StartsAt string `json:"starts_at"`

// The date at which the entitlement is no longer valid.
// Not present when using test entitlements.
EndsAt string `json:"ends_at"`

// The ID of the guild that is granted access to the entitlement's sku.
GuildID string `json:"guild_id"`

// Whether or not the entitlement has been consumed.
// Only available for consumable items.
Consumed bool `json:"consumed"`
}

// Constants for the different bit offsets of text channel permissions
const (
// Deprecated: PermissionReadMessages has been replaced with PermissionViewChannel for text and voice channels