Skip to content

Commit

Permalink
Add more safety around message reference misuse
Browse files Browse the repository at this point in the history
  • Loading branch information
CarsonHoffman authored and jccit committed Sep 14, 2021
1 parent 1e0f0c5 commit f39d983
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion message.go
Expand Up @@ -120,7 +120,9 @@ type Message struct {
// Is sent with Rich Presence-related chat embeds
Application *MessageApplication `json:"application"`

// MessageReference contains reference data sent with crossposted messages
// MessageReference contains reference data sent with crossposted or reply messages.
// This does not contain the reference *to* this message; this is for when *this* message references another.
// To generate a reference to this message, use (*Message).Reference().
MessageReference *MessageReference `json:"message_reference"`

// The flags of the message, which describe extra features of a message.
Expand Down
3 changes: 3 additions & 0 deletions restapi.go
Expand Up @@ -1612,6 +1612,9 @@ func (s *Session) ChannelMessageSendEmbed(channelID string, embed *MessageEmbed)
// content : The message to send.
// reference : The message reference to send.
func (s *Session) ChannelMessageSendReply(channelID string, content string, reference *MessageReference) (*Message, error) {
if reference == nil {
return nil, fmt.Errorf("reply attempted with nil message reference")
}
return s.ChannelMessageSendComplex(channelID, &MessageSend{
Content: content,
Reference: reference,
Expand Down

0 comments on commit f39d983

Please sign in to comment.