diff --git a/message.go b/message.go index f4b20fe..4858938 100644 --- a/message.go +++ b/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 @ mentions with the // username of the mention. func (m *Message) ContentWithMentionsReplaced() (content string) { diff --git a/restapi.go b/restapi.go index 9432194..b088711 100644 --- a/restapi.go +++ b/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