From 363918ad4854358d7cb04d47c6d25c832c61074c Mon Sep 17 00:00:00 2001 From: mlnrDev Date: Fri, 18 Aug 2023 20:32:14 +0200 Subject: [PATCH] add GuildSubscriptionIntegration --- discord/integration.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/discord/integration.go b/discord/integration.go index f32929eab..c848cf4ef 100644 --- a/discord/integration.go +++ b/discord/integration.go @@ -77,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) } @@ -204,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() +}