Skip to content

Commit

Permalink
add GuildSubscriptionIntegration
Browse files Browse the repository at this point in the history
  • Loading branch information
sebm253 committed Aug 18, 2023
1 parent b041519 commit 363918a
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions discord/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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()
}

0 comments on commit 363918a

Please sign in to comment.