Browse Source

adds message fields

Sebastian Winkler 5 years ago
parent
commit
cb8dd746bc
1 changed files with 70 additions and 0 deletions
  1. 70 0
      message.go

+ 70 - 0
message.go

@@ -93,6 +93,31 @@ type Message struct {
 
 	// The webhook ID of the message, if it was generated by a webhook
 	WebhookID string `json:"webhook_id"`
+
+	// Member properties for this message's author,
+	// contains only partial information
+	Member *Member `json:"member"`
+
+	// Channels specifically mentioned in this message
+	// Not all channel mentions in a message will appear in mention_channels.
+	// Only textual channels that are visible to everyone in a lurkable guild will ever be included.
+	// Only crossposted messages (via Channel Following) currently include mention_channels at all.
+	// If no mentions in the message meet these requirements, this field will not be sent.
+	MentionChannels []*Channel `json:"mention_channels"`
+
+	// Is sent with Rich Presence-related chat embeds
+	Activity *MessageActivity `json:"activity"`
+
+	// Is sent with Rich Presence-related chat embeds
+	Application *MessageApplication `json:"application"`
+
+	// MessageReference contains reference data sent with crossposted messages
+	MessageReference *MessageReference `json:"message_reference"`
+
+	// 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.
+	Flags int `json:"flags"`
 }
 
 // File stores info about files you e.g. send in messages.
@@ -233,6 +258,51 @@ type MessageReactions struct {
 	Emoji *Emoji `json:"emoji"`
 }
 
+// MessageActivity is sent with Rich Presence-related chat embeds
+type MessageActivity struct {
+	Type    MessageActivityType `json:"type"`
+	PartyID string              `json:"party_id"`
+}
+
+// MessageActivityType is the type of message activity
+type MessageActivityType int
+
+const (
+	MessageActivityTypeJoin = iota + 1
+	MessageActivityTypeSpectate
+	MessageActivityTypeListen
+	MessageActivityTypeJoinRequest
+)
+
+// MessageFlag describes an extra feature of the message
+type MessageFlag int
+
+// Constants for the different bit offsets of Message Flags
+const (
+	// This message has been published to subscribed channels (via Channel Following)
+	MessageFlagCrossposted = 1 << iota
+	// This message originated from a message in another channel (via Channel Following)
+	MessageFlagIsCrosspost
+	// Do not include any embeds when serializing this message
+	MessageFlagSuppressEmbeds
+)
+
+// MessageApplication is sent with Rich Presence-related chat embeds
+type MessageApplication struct {
+	ID          string `json:"id"`
+	CoverImage  string `json:"cover_image"`
+	Description string `json:"description"`
+	Icon        string `json:"icon"`
+	Name        string `json:"name"`
+}
+
+// MessageReference contains reference data sent with crossposted messages
+type MessageReference struct {
+	MessageID string `json:"message_id"`
+	ChannelID string `json:"channel_id"`
+	GuildID   string `json:"guild_id"`
+}
+
 // ContentWithMentionsReplaced will replace all @<id> mentions with the
 // username of the mention.
 func (m *Message) ContentWithMentionsReplaced() (content string) {