diff --git a/discord/guild.go b/discord/guild.go index a87272ca..879a2518 100644 --- a/discord/guild.go +++ b/discord/guild.go @@ -29,6 +29,8 @@ const ( SystemChannelFlagSuppressPremiumSubscriptions SystemChannelFlagSuppressGuildReminderNotifications SystemChannelFlagSuppressJoinNotificationReplies + SystemChannelFlagSuppressRoleSubscriptionPurchaseNotifications + SystemChannelFlagSuppressRoleSubscriptionPurchaseNotificationReplies ) // Add allows you to add multiple bits together, producing a new bit @@ -96,29 +98,32 @@ type GuildFeature string // Constants for GuildFeature const ( - GuildFeatureAnimatedBanner GuildFeature = "ANIMATED_BANNER" - GuildFeatureAnimatedIcon GuildFeature = "ANIMATED_ICON" - GuildFeatureAutoModeration GuildFeature = "AUTO_MODERATION" - GuildFeatureBanner GuildFeature = "BANNER" - GuildFeatureCommunity GuildFeature = "COMMUNITY" - GuildFeatureDeveloperSupportServer GuildFeature = "DEVELOPER_SUPPORT_SERVER" - GuildFeatureDiscoverable GuildFeature = "DISCOVERABLE" - GuildFeatureFeaturable GuildFeature = "FEATURABLE" - GuildFeatureInvitesDisabled GuildFeature = "INVITES_DISABLED" - GuildFeatureInviteSplash GuildFeature = "INVITE_SPLASH" - GuildFeatureMemberVerificationGateEnabled GuildFeature = "MEMBER_VERIFICATION_GATE_ENABLED" - GuildFeatureMonetizationEnabled GuildFeature = "MONETIZATION_ENABLED" - GuildFeatureMoreStickers GuildFeature = "MORE_STICKERS" - GuildFeatureNews GuildFeature = "NEWS" - GuildFeaturePartnered GuildFeature = "PARTNERED" - GuildFeaturePreviewEnabled GuildFeature = "PREVIEW_ENABLED" - GuildFeatureRaidAlertsDisabled GuildFeature = "RAID_ALERTS_DISABLED" - GuildFeatureRoleIcons GuildFeature = "ROLE_ICONS" - GuildFeatureTicketedEventsEnabled GuildFeature = "TICKETED_EVENTS_ENABLED" - GuildFeatureVanityURL GuildFeature = "VANITY_URL" - GuildFeatureVerified GuildFeature = "VERIFIED" - GuildFeatureVipRegions GuildFeature = "VIP_REGIONS" - GuildFeatureWelcomeScreenEnabled GuildFeature = "WELCOME_SCREEN_ENABLED" + GuildFeatureAnimatedBanner GuildFeature = "ANIMATED_BANNER" + GuildFeatureAnimatedIcon GuildFeature = "ANIMATED_ICON" + GuildFeatureAutoModeration GuildFeature = "AUTO_MODERATION" + GuildFeatureBanner GuildFeature = "BANNER" + GuildFeatureCommunity GuildFeature = "COMMUNITY" + GuildFeatureCreatorMonetizableProvisional GuildFeature = "CREATOR_MONETIZABLE_PROVISIONAL" + GuildFeatureCreatorStorePage GuildFeature = "CREATOR_STORE_PAGE" + GuildFeatureDeveloperSupportServer GuildFeature = "DEVELOPER_SUPPORT_SERVER" + GuildFeatureDiscoverable GuildFeature = "DISCOVERABLE" + GuildFeatureFeaturable GuildFeature = "FEATURABLE" + GuildFeatureInvitesDisabled GuildFeature = "INVITES_DISABLED" + GuildFeatureInviteSplash GuildFeature = "INVITE_SPLASH" + GuildFeatureMemberVerificationGateEnabled GuildFeature = "MEMBER_VERIFICATION_GATE_ENABLED" + GuildFeatureMoreStickers GuildFeature = "MORE_STICKERS" + GuildFeatureNews GuildFeature = "NEWS" + GuildFeaturePartnered GuildFeature = "PARTNERED" + GuildFeaturePreviewEnabled GuildFeature = "PREVIEW_ENABLED" + GuildFeatureRaidAlertsDisabled GuildFeature = "RAID_ALERTS_DISABLED" + GuildFeatureRoleIcons GuildFeature = "ROLE_ICONS" + GuildFeatureRoleSubscriptionsAvailableForPurchase GuildFeature = "ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE" + GuildFeatureRoleSubscriptionsEnabled GuildFeature = "ROLE_SUBSCRIPTIONS_ENABLED" + GuildFeatureTicketedEventsEnabled GuildFeature = "TICKETED_EVENTS_ENABLED" + GuildFeatureVanityURL GuildFeature = "VANITY_URL" + GuildFeatureVerified GuildFeature = "VERIFIED" + GuildFeatureVipRegions GuildFeature = "VIP_REGIONS" + GuildFeatureWelcomeScreenEnabled GuildFeature = "WELCOME_SCREEN_ENABLED" ) // Guild represents a discord Guild diff --git a/discord/integration.go b/discord/integration.go index 8ced9d14..cb216820 100644 --- a/discord/integration.go +++ b/discord/integration.go @@ -13,9 +13,10 @@ type IntegrationType string // All IntegrationType(s) const ( - IntegrationTypeTwitch IntegrationType = "twitch" - IntegrationTypeYouTube IntegrationType = "youtube" - IntegrationTypeBot IntegrationType = "discord" + IntegrationTypeTwitch IntegrationType = "twitch" + IntegrationTypeYouTube IntegrationType = "youtube" + IntegrationTypeBot IntegrationType = "discord" + IntegrationTypeGuildSubscription IntegrationType = "guild_subscription" ) // IntegrationAccount (https://discord.com/developers/docs/resources/guild#integration-account-object) @@ -76,6 +77,11 @@ func (i *UnmarshalIntegration) UnmarshalJSON(data []byte) error { err = json.Unmarshal(data, &v) integration = v + case IntegrationTypeGuildSubscription: + var v GuildSubscriptionIntegration + err = json.Unmarshal(data, &v) + integration = v + default: err = fmt.Errorf("unknown integration with type %s received", cType.Type) } @@ -203,3 +209,33 @@ func (i BotIntegration) ID() snowflake.ID { func (i BotIntegration) CreatedAt() time.Time { return i.IntegrationID.Time() } + +type GuildSubscriptionIntegration struct { + IntegrationID snowflake.ID `json:"id"` + Name string `json:"name"` + Enabled bool `json:"enabled"` + Account IntegrationAccount `json:"account"` +} + +func (i GuildSubscriptionIntegration) MarshalJSON() ([]byte, error) { + type subscriptionIntegration GuildSubscriptionIntegration + return json.Marshal(struct { + Type IntegrationType `json:"type"` + subscriptionIntegration + }{ + Type: i.Type(), + subscriptionIntegration: subscriptionIntegration(i), + }) +} + +func (GuildSubscriptionIntegration) Type() IntegrationType { + return IntegrationTypeGuildSubscription +} + +func (i GuildSubscriptionIntegration) ID() snowflake.ID { + return i.IntegrationID +} + +func (i GuildSubscriptionIntegration) CreatedAt() time.Time { + return i.IntegrationID.Time() +} diff --git a/discord/invite.go b/discord/invite.go index b8aaae5b..37c96324 100644 --- a/discord/invite.go +++ b/discord/invite.go @@ -13,6 +13,7 @@ type InviteTargetType int const ( InviteTargetTypeStream InviteTargetType = iota + 1 InviteTargetTypeEmbeddedApplication + InviteTargetTypeRoleSubscriptionsPurchase ) // Invite is a partial invite struct diff --git a/discord/message.go b/discord/message.go index b30a1a32..bc16b8f5 100644 --- a/discord/message.go +++ b/discord/message.go @@ -40,7 +40,7 @@ const ( MessageTypeGuildInviteReminder MessageTypeContextMenuCommand MessageTypeAutoModerationAction - _ + MessageTypeRoleSubscriptionPurchase MessageTypeInteractionPremiumUpsell MessageTypeStageStart MessageTypeStageEnd @@ -81,37 +81,38 @@ func MessageURL(guildID snowflake.ID, channelID snowflake.ID, messageID snowflak // Message is a struct for messages sent in discord text-based channels type Message struct { - ID snowflake.ID `json:"id"` - GuildID *snowflake.ID `json:"guild_id"` - Reactions []MessageReaction `json:"reactions"` - Attachments []Attachment `json:"attachments"` - TTS bool `json:"tts"` - Embeds []Embed `json:"embeds,omitempty"` - Components []ContainerComponent `json:"components,omitempty"` - CreatedAt time.Time `json:"timestamp"` - Mentions []User `json:"mentions"` - MentionEveryone bool `json:"mention_everyone"` - MentionRoles []snowflake.ID `json:"mention_roles"` - MentionChannels []Channel `json:"mention_channels"` - Pinned bool `json:"pinned"` - EditedTimestamp *time.Time `json:"edited_timestamp"` - Author User `json:"author"` - Member *Member `json:"member"` - Content string `json:"content,omitempty"` - ChannelID snowflake.ID `json:"channel_id"` - Type MessageType `json:"type"` - Flags MessageFlags `json:"flags"` - MessageReference *MessageReference `json:"message_reference,omitempty"` - Interaction *MessageInteraction `json:"interaction,omitempty"` - WebhookID *snowflake.ID `json:"webhook_id,omitempty"` - Activity *MessageActivity `json:"activity,omitempty"` - Application *MessageApplication `json:"application,omitempty"` - ApplicationID *snowflake.ID `json:"application_id,omitempty"` - StickerItems []MessageSticker `json:"sticker_items,omitempty"` - ReferencedMessage *Message `json:"referenced_message,omitempty"` - LastUpdated *time.Time `json:"last_updated,omitempty"` - Thread *MessageThread `json:"thread,omitempty"` - Position *int `json:"position,omitempty"` + ID snowflake.ID `json:"id"` + GuildID *snowflake.ID `json:"guild_id"` + Reactions []MessageReaction `json:"reactions"` + Attachments []Attachment `json:"attachments"` + TTS bool `json:"tts"` + Embeds []Embed `json:"embeds,omitempty"` + Components []ContainerComponent `json:"components,omitempty"` + CreatedAt time.Time `json:"timestamp"` + Mentions []User `json:"mentions"` + MentionEveryone bool `json:"mention_everyone"` + MentionRoles []snowflake.ID `json:"mention_roles"` + MentionChannels []Channel `json:"mention_channels"` + Pinned bool `json:"pinned"` + EditedTimestamp *time.Time `json:"edited_timestamp"` + Author User `json:"author"` + Member *Member `json:"member"` + Content string `json:"content,omitempty"` + ChannelID snowflake.ID `json:"channel_id"` + Type MessageType `json:"type"` + Flags MessageFlags `json:"flags"` + MessageReference *MessageReference `json:"message_reference,omitempty"` + Interaction *MessageInteraction `json:"interaction,omitempty"` + WebhookID *snowflake.ID `json:"webhook_id,omitempty"` + Activity *MessageActivity `json:"activity,omitempty"` + Application *MessageApplication `json:"application,omitempty"` + ApplicationID *snowflake.ID `json:"application_id,omitempty"` + StickerItems []MessageSticker `json:"sticker_items,omitempty"` + ReferencedMessage *Message `json:"referenced_message,omitempty"` + LastUpdated *time.Time `json:"last_updated,omitempty"` + Thread *MessageThread `json:"thread,omitempty"` + Position *int `json:"position,omitempty"` + RoleSubscriptionData *RoleSubscriptionData `json:"role_subscription_data,omitempty"` } func (m *Message) UnmarshalJSON(data []byte) error { @@ -439,3 +440,10 @@ func (f MessageFlags) Has(bits ...MessageFlags) bool { func (f MessageFlags) Missing(bits ...MessageFlags) bool { return flags.Missing(f, bits...) } + +type RoleSubscriptionData struct { + RoleSubscriptionListingID snowflake.ID `json:"role_subscription_listing_id"` + TierName string `json:"tier_name"` + TotalMonthsSubscribed int `json:"total_months_subscribed"` + IsRenewal bool `json:"is_renewal"` +} diff --git a/discord/role.go b/discord/role.go index ece6958e..9e29c35c 100644 --- a/discord/role.go +++ b/discord/role.go @@ -49,10 +49,12 @@ func (r Role) CreatedAt() time.Time { // RoleTag are tags a Role has type RoleTag struct { - BotID *snowflake.ID `json:"bot_id,omitempty"` - IntegrationID *snowflake.ID `json:"integration_id,omitempty"` - PremiumSubscriber bool `json:"premium_subscriber"` - GuildConnections bool `json:"guild_connections"` + BotID *snowflake.ID `json:"bot_id,omitempty"` + IntegrationID *snowflake.ID `json:"integration_id,omitempty"` + PremiumSubscriber bool `json:"premium_subscriber"` + SubscriptionListingID *snowflake.ID `json:"subscription_listing_id,omitempty"` + AvailableForPurchase bool `json:"available_for_purchase"` + GuildConnections bool `json:"guild_connections"` } type RoleFlags int