Browse Source

Add support for sending message reply

Alexey 4 years ago
parent
commit
1b13267ba4
2 changed files with 21 additions and 0 deletions
  1. 10 0
      message.go
  2. 11 0
      restapi.go

+ 10 - 0
message.go

@@ -150,6 +150,7 @@ type MessageSend struct {
 	TTS             bool                    `json:"tts"`
 	Files           []*File                 `json:"-"`
 	AllowedMentions *MessageAllowedMentions `json:"allowed_mentions,omitempty"`
+	Reference       *MessageReference       `json:"message_reference,omitempty"`
 
 	// TODO: Remove this when compatibility is not required.
 	File *File `json:"-"`
@@ -371,6 +372,15 @@ type MessageReference struct {
 	GuildID   string `json:"guild_id"`
 }
 
+// Reference returns MessageReference of given message
+func (m *Message) Reference() *MessageReference {
+	return &MessageReference{
+		GuildID:   m.GuildID,
+		ChannelID: m.ChannelID,
+		MessageID: m.ID,
+	}
+}
+
 // ContentWithMentionsReplaced will replace all @<id> mentions with the
 // username of the mention.
 func (m *Message) ContentWithMentionsReplaced() (content string) {

+ 11 - 0
restapi.go

@@ -1629,6 +1629,17 @@ func (s *Session) ChannelMessageSendEmbed(channelID string, embed *MessageEmbed)
 	})
 }
 
+// ChannelMessageSendReply sends a message to the given channel with reference data.
+// channelID : The ID of a Channel.
+// content   : The message to send.
+// reference : The message reference to send.
+func (s *Session) ChannelMessageSendReply(channelID string, content string, reference *MessageReference) (*Message, error) {
+	return s.ChannelMessageSendComplex(channelID, &MessageSend{
+		Content:   content,
+		Reference: reference,
+	})
+}
+
 // ChannelMessageEdit edits an existing message, replacing it entirely with
 // the given content.
 // channelID  : The ID of a Channel