forked from pothtonswer/discordmuffin
SendContent (#352)
* SendContent * Fixed error...? * Commented * Yep let's do that * Oops * Oki * Whatever you say, Travis... :< * Omit them empty structs
This commit is contained in:
parent
fea42d937a
commit
851e8d3581
2 changed files with 21 additions and 11 deletions
22
message.go
22
message.go
|
@ -31,18 +31,28 @@ type Message struct {
|
|||
Reactions []*MessageReactions `json:"reactions"`
|
||||
}
|
||||
|
||||
// MessageParams is used in MessageSend and MessageEdit to share common parameters.
|
||||
type MessageParams struct {
|
||||
Content *string `json:"content,omitempty"`
|
||||
Embed *MessageEmbed `json:"embed,omitempty"`
|
||||
}
|
||||
|
||||
// MessageSend stores all parameters you can send with ChannelMessageSendComplex.
|
||||
type MessageSend struct {
|
||||
Content string `json:"content"`
|
||||
Tts bool `json:"tts"`
|
||||
Embed *MessageEmbed `json:"embed"`
|
||||
Nonce string `json:"nonce"`
|
||||
MessageParams
|
||||
Tts bool `json:"tts"`
|
||||
}
|
||||
|
||||
// MessageEdit stores all parameters you can send with ChannelMessageSendComplex.
|
||||
type MessageEdit struct {
|
||||
Content string `json:"content"`
|
||||
Embed *MessageEmbed `json:"embed"`
|
||||
MessageParams
|
||||
}
|
||||
|
||||
// SetContent is the same as setting the variable Content,
|
||||
// except it doesn't take a pointer.
|
||||
// Only a conveniance function.
|
||||
func (m *MessageParams) SetContent(str string) {
|
||||
m.Content = &str
|
||||
}
|
||||
|
||||
// A MessageAttachment stores data for message attachments.
|
||||
|
|
10
restapi.go
10
restapi.go
|
@ -1285,7 +1285,7 @@ func (s *Session) ChannelMessageAck(channelID, messageID, lastToken string) (st
|
|||
// channelID : The ID of a Channel.
|
||||
// content : The message to send.
|
||||
func (s *Session) ChannelMessageSend(channelID string, content string) (*Message, error) {
|
||||
return s.ChannelMessageSendComplex(channelID, &MessageSend{Content: content})
|
||||
return s.ChannelMessageSendComplex(channelID, &MessageSend{MessageParams: MessageParams{Content: &content}})
|
||||
}
|
||||
|
||||
// ChannelMessageSendComplex sends a message to the given channel.
|
||||
|
@ -1309,14 +1309,14 @@ func (s *Session) ChannelMessageSendComplex(channelID string, data *MessageSend)
|
|||
// channelID : The ID of a Channel.
|
||||
// content : The message to send.
|
||||
func (s *Session) ChannelMessageSendTTS(channelID string, content string) (*Message, error) {
|
||||
return s.ChannelMessageSendComplex(channelID, &MessageSend{Content: content, Tts: true})
|
||||
return s.ChannelMessageSendComplex(channelID, &MessageSend{MessageParams: MessageParams{Content: &content}, Tts: true})
|
||||
}
|
||||
|
||||
// ChannelMessageSendEmbed sends a message to the given channel with embedded data.
|
||||
// channelID : The ID of a Channel.
|
||||
// embed : The embed data to send.
|
||||
func (s *Session) ChannelMessageSendEmbed(channelID string, embed *MessageEmbed) (*Message, error) {
|
||||
return s.ChannelMessageSendComplex(channelID, &MessageSend{Embed: embed})
|
||||
return s.ChannelMessageSendComplex(channelID, &MessageSend{MessageParams: MessageParams{Embed: embed}})
|
||||
}
|
||||
|
||||
// ChannelMessageEdit edits an existing message, replacing it entirely with
|
||||
|
@ -1325,7 +1325,7 @@ func (s *Session) ChannelMessageSendEmbed(channelID string, embed *MessageEmbed)
|
|||
// messageID : The ID of a Message
|
||||
// content : The contents of the message
|
||||
func (s *Session) ChannelMessageEdit(channelID, messageID, content string) (*Message, error) {
|
||||
return s.ChannelMessageEditComplex(channelID, messageID, &MessageEdit{Content: content})
|
||||
return s.ChannelMessageEditComplex(channelID, messageID, &MessageEdit{MessageParams: MessageParams{Content: &content}})
|
||||
}
|
||||
|
||||
// ChannelMessageEditComplex edits an existing message, replacing it entirely with
|
||||
|
@ -1352,7 +1352,7 @@ func (s *Session) ChannelMessageEditComplex(channelID, messageID string, data *M
|
|||
// messageID : The ID of a Message
|
||||
// embed : The embed data to send
|
||||
func (s *Session) ChannelMessageEditEmbed(channelID, messageID string, embed *MessageEmbed) (*Message, error) {
|
||||
return s.ChannelMessageEditComplex(channelID, messageID, &MessageEdit{Embed: embed})
|
||||
return s.ChannelMessageEditComplex(channelID, messageID, &MessageEdit{MessageParams: MessageParams{Embed: embed}})
|
||||
}
|
||||
|
||||
// ChannelMessageDelete deletes a message from the Channel.
|
||||
|
|
Loading…
Reference in a new issue