Skip to content

Commit

Permalink
added some missing CreatedAt() time.Time methods
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Aug 16, 2022
1 parent ead63ed commit 7295dbe
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 3 deletions.
10 changes: 9 additions & 1 deletion discord/attachment.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package discord

import "github.com/disgoorg/snowflake/v2"
import (
"time"

"github.com/disgoorg/snowflake/v2"
)

//Attachment is used for files sent in a Message
type Attachment struct {
Expand All @@ -16,6 +20,10 @@ type Attachment struct {
Ephemeral bool `json:"ephemeral,omitempty"`
}

func (a Attachment) CreatedAt() time.Time {
return a.ID.Time()
}

type AttachmentUpdate interface {
attachmentUpdate()
}
Expand Down
10 changes: 9 additions & 1 deletion discord/auto_moderation.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package discord

import "github.com/disgoorg/snowflake/v2"
import (
"time"

"github.com/disgoorg/snowflake/v2"
)

type AutoModerationEventType int

Expand Down Expand Up @@ -62,6 +66,10 @@ type AutoModerationRule struct {
ExemptChannels []snowflake.ID `json:"exempt_channels"`
}

func (r AutoModerationRule) CreatedAt() time.Time {
return r.ID.Time()
}

type AutoModerationRuleCreate struct {
Name string `json:"name"`
EventType AutoModerationEventType `json:"event_type"`
Expand Down
4 changes: 4 additions & 0 deletions discord/guild_scheduled_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ type GuildScheduledEvent struct {
UserCount int `json:"user_count"`
}

func (e GuildScheduledEvent) CreatedAt() time.Time {
return e.ID.Time()
}

type GuildScheduledEventCreate struct {
ChannelID snowflake.ID `json:"channel_id,omitempty"`
EntityMetaData *EntityMetaData `json:"entity_metadata,omitempty"`
Expand Down
14 changes: 14 additions & 0 deletions discord/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package discord

import (
"fmt"
"time"

"github.com/disgoorg/disgo/json"
"github.com/disgoorg/snowflake/v2"
Expand Down Expand Up @@ -38,6 +39,7 @@ type Integration interface {
json.Marshaler
Type() IntegrationType
ID() snowflake.ID
CreatedAt() time.Time
}

type UnmarshalIntegration struct {
Expand Down Expand Up @@ -121,6 +123,10 @@ func (i TwitchIntegration) ID() snowflake.ID {
return i.IntegrationID
}

func (i TwitchIntegration) CreatedAt() time.Time {
return i.IntegrationID.Time()
}

type YouTubeIntegration struct {
IntegrationID snowflake.ID `json:"id"`
Name string `json:"name"`
Expand Down Expand Up @@ -155,6 +161,10 @@ func (i YouTubeIntegration) ID() snowflake.ID {
return i.IntegrationID
}

func (i YouTubeIntegration) CreatedAt() time.Time {
return i.IntegrationID.Time()
}

type BotIntegration struct {
IntegrationID snowflake.ID `json:"id"`
Name string `json:"name"`
Expand All @@ -181,3 +191,7 @@ func (BotIntegration) Type() IntegrationType {
func (i BotIntegration) ID() snowflake.ID {
return i.IntegrationID
}

func (i BotIntegration) CreatedAt() time.Time {
return i.IntegrationID.Time()
}
10 changes: 9 additions & 1 deletion discord/stage_instance.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package discord

import "github.com/disgoorg/snowflake/v2"
import (
"time"

"github.com/disgoorg/snowflake/v2"
)

type StagePrivacyLevel int

Expand All @@ -18,6 +22,10 @@ type StageInstance struct {
DiscoverableDisabled bool `json:"discoverable_disabled"`
}

func (e StageInstance) CreatedAt() time.Time {
return e.ID.Time()
}

type StageInstanceCreate struct {
ChannelID snowflake.ID `json:"channel_id"`
Topic string `json:"topic,omitempty"`
Expand Down

0 comments on commit 7295dbe

Please sign in to comment.