Skip to content

Commit

Permalink
fix struct for message snapshots (botlabs-gg#1735)
Browse files Browse the repository at this point in the history
* fix struct for message snapshots

* fix struct for message snapshots

---------

Co-authored-by: Ashish <ashishjh-bst@users.noreply.github.com>
  • Loading branch information
ashishjh-bst and ashishjh-bst authored Oct 4, 2024
1 parent 807cbed commit 0b7aabd
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/discordgo/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ type Message struct {
ReferencedMessage *Message `json:"referenced_message"`

// The messages associated with the message_reference when message_reference type is FORWARD
// NOTE: This field is only returned for messages with a type of
MessageSnapshots []*Message `json:"message_snapshots"`
MessageSnapshots []*MessageSnapshot `json:"message_snapshots"`

// Is sent when the message is a response to an Interaction, without an existing message.
// This means responses to message component interactions do not include this property,
Expand All @@ -166,10 +165,16 @@ type Message struct {
Activity *MessageActivity `json:"activity"`
}

type MessageSnapshot struct {
Message *Message `json:"message"`
}

func (m *Message) GetMessageContents() []string {
contents := []string{m.Content}
for _, s := range m.MessageSnapshots {
contents = append(contents, s.Content)
if s.Message != nil && len(s.Message.Content) > 0 {
contents = append(contents, s.Message.Content)
}
}
return contents
}
Expand Down

0 comments on commit 0b7aabd

Please sign in to comment.