Browse Source

add interaction field to message struct (#1112)

* add message interaction field and struct

* Update message.go

Co-authored-by: Fedor Lapshin <fe.lap.prog@gmail.com>

* Update message.go

Co-authored-by: Fedor Lapshin <fe.lap.prog@gmail.com>

* Update message.go

Co-authored-by: Fedor Lapshin <fe.lap.prog@gmail.com>

* add notice when member is present

* correct comment

Co-authored-by: Fedor Lapshin <fe.lap.prog@gmail.com>
ToπSenpai 3 years ago
parent
commit
ca264d70ff
1 changed files with 16 additions and 0 deletions
  1. 16 0
      message.go

+ 16 - 0
message.go

@@ -135,6 +135,11 @@ type Message struct {
 	// If the field exists but is null, the referenced message was deleted.
 	ReferencedMessage *Message `json:"referenced_message"`
 
+	// 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,
+	// instead including a MessageReference, as components exist on preexisting messages.
+	Interaction *MessageInteraction `json:"interaction"`
+
 	// The flags of the message, which describe extra features of a message.
 	// This is a combination of bit masks; the presence of a certain permission can
 	// be checked by performing a bitwise AND between this int and the flag.
@@ -523,3 +528,14 @@ func (m *Message) ContentWithMoreMentionsReplaced(s *Session) (content string, e
 	})
 	return
 }
+
+// MessageInteraction contains information about the application command interaction which generated the message.
+type MessageInteraction struct {
+	ID   string          `json:"id"`
+	Type InteractionType `json:"type"`
+	Name string          `json:"name"`
+	User *User           `json:"user"`
+
+	// Member is only present when the interaction is from a guild.
+	Member *Member `json:"member"`
+}