Support embed messages.

This commit is contained in:
Chris Rhodes 2016-11-13 21:51:57 -08:00
parent b7c7e60fd5
commit 717c8f2538

View file

@ -1228,6 +1228,28 @@ func (s *Session) ChannelMessageSendTTS(channelID string, content string) (st *M
return s.channelMessageSend(channelID, content, true) return s.channelMessageSend(channelID, content, true)
} }
// ChannelMessageSendEmbed sends a message to the given channel with embedded data (bot only).
// channelID : The ID of a Channel.
// embed : The embed data to send.
func (s *Session) ChannelMessageSendEmbed(channelID string, embed *MessageEmbed) (st *Message, err error) {
if embed != nil && embed.Type == "" {
embed.Type = "rich"
}
data := struct {
Embed *MessageEmbed `json:"embed"`
}{embed}
// Send the message to the given channel
response, err := s.RequestWithBucketID("POST", EndpointChannelMessages(channelID), data, EndpointChannelMessages(channelID))
if err != nil {
return
}
err = unmarshal(response, &st)
return
}
// ChannelMessageEdit edits an existing message, replacing it entirely with // ChannelMessageEdit edits an existing message, replacing it entirely with
// the given content. // the given content.
// channeld : The ID of a Channel // channeld : The ID of a Channel
@ -1680,8 +1702,6 @@ func (s *Session) WebhookExecute(webhookID, token string, wait bool, data *Webho
uri += "?wait=true" uri += "?wait=true"
} }
fmt.Println(uri)
_, err = s.RequestWithBucketID("POST", uri, data, EndpointWebhookToken("", "")) _, err = s.RequestWithBucketID("POST", uri, data, EndpointWebhookToken("", ""))
return return
@ -1759,8 +1779,6 @@ func (s *Session) relationshipCreate(userID string, relationshipType int) (err e
Type int `json:"type"` Type int `json:"type"`
}{relationshipType} }{relationshipType}
fmt.Println("Data: " + fmt.Sprintf("%v", data))
_, err = s.RequestWithBucketID("PUT", EndpointRelationship(userID), data, EndpointRelationships()) _, err = s.RequestWithBucketID("PUT", EndpointRelationship(userID), data, EndpointRelationships())
return return
} }