forked from pothtonswer/discordmuffin
feat(MessageReference): add fail_if_not_exists (#1376)
* Add fail_if_not_exists to MessageReference * Add SoftReference function to Message --------- Co-authored-by: Fedor Lapshin <fe.lap.prog@gmail.com>
This commit is contained in:
parent
160605c9c3
commit
1252b71f38
1 changed files with 20 additions and 8 deletions
28
message.go
28
message.go
|
@ -461,20 +461,32 @@ type MessageApplication struct {
|
||||||
|
|
||||||
// MessageReference contains reference data sent with crossposted messages
|
// MessageReference contains reference data sent with crossposted messages
|
||||||
type MessageReference struct {
|
type MessageReference struct {
|
||||||
MessageID string `json:"message_id"`
|
MessageID string `json:"message_id"`
|
||||||
ChannelID string `json:"channel_id,omitempty"`
|
ChannelID string `json:"channel_id,omitempty"`
|
||||||
GuildID string `json:"guild_id,omitempty"`
|
GuildID string `json:"guild_id,omitempty"`
|
||||||
|
FailIfNotExists *bool `json:"fail_if_not_exists,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reference returns MessageReference of given message
|
func (m *Message) reference(failIfNotExists bool) *MessageReference {
|
||||||
func (m *Message) Reference() *MessageReference {
|
|
||||||
return &MessageReference{
|
return &MessageReference{
|
||||||
GuildID: m.GuildID,
|
GuildID: m.GuildID,
|
||||||
ChannelID: m.ChannelID,
|
ChannelID: m.ChannelID,
|
||||||
MessageID: m.ID,
|
MessageID: m.ID,
|
||||||
|
FailIfNotExists: &failIfNotExists,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reference returns a MessageReference of the given message.
|
||||||
|
func (m *Message) Reference() *MessageReference {
|
||||||
|
return m.reference(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SoftReference returns a MessageReference of the given message.
|
||||||
|
// If the message doesn't exist it will instead be sent as a non-reply message.
|
||||||
|
func (m *Message) SoftReference() *MessageReference {
|
||||||
|
return m.reference(false)
|
||||||
|
}
|
||||||
|
|
||||||
// ContentWithMentionsReplaced will replace all @<id> mentions with the
|
// ContentWithMentionsReplaced will replace all @<id> mentions with the
|
||||||
// username of the mention.
|
// username of the mention.
|
||||||
func (m *Message) ContentWithMentionsReplaced() (content string) {
|
func (m *Message) ContentWithMentionsReplaced() (content string) {
|
||||||
|
|
Loading…
Reference in a new issue