Skip to content

Commit

Permalink
Remove custom unmarshaller for EventMessageUpdate
Browse files Browse the repository at this point in the history
the timestamp is now properly sent on edits: discord/discord-api-docs#7017
  • Loading branch information
sebm253 committed Jul 20, 2024
1 parent e70ebbc commit e13fad5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
15 changes: 7 additions & 8 deletions discord/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,13 @@ 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"`
// Note: for message update events, this field is populated by the creation of the ID during unmarshalling
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"`
Expand Down
11 changes: 0 additions & 11 deletions gateway/gateway_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,17 +488,6 @@ type EventMessageUpdate struct {
discord.Message
}

func (e *EventMessageUpdate) UnmarshalJSON(data []byte) error {
type eventMessageUpdate EventMessageUpdate
var v eventMessageUpdate
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*e = EventMessageUpdate(v)
e.CreatedAt = e.ID.Time()
return nil
}

func (EventMessageUpdate) messageData() {}
func (EventMessageUpdate) eventData() {}

Expand Down

0 comments on commit e13fad5

Please # to comment.