forked from pothtonswer/discordmuffin
Added ChannelMessagesBulkDelete function.
Requires a channelID and a slice of messageIDs from the channel. If only on ID is in the slice calls ChannelMessageDelete() internally. If the slice of IDs is empty do nothing.
This commit is contained in:
parent
e435962b50
commit
35e6225f87
1 changed files with 24 additions and 0 deletions
24
restapi.go
24
restapi.go
|
@ -1107,6 +1107,30 @@ func (s *Session) ChannelMessageDelete(channelID, messageID string) (err error)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ChannelMessagesBulkDelete bulk deletes the messages from the channel for the provided messageIDs.
|
||||||
|
// If only one messageID is in the slice call channelMessageDelete funciton.
|
||||||
|
// If the slice is empty do nothing.
|
||||||
|
// channelID : The ID of the channel for the messages to delete.
|
||||||
|
// messages : The IDs of the messages to be deleted. A slice of string IDs.
|
||||||
|
func (s *Session) ChannelMessagesBulkDelete(channelID string, messages []string) (err error) {
|
||||||
|
|
||||||
|
if len(messages) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(messages) == 1 {
|
||||||
|
err = s.ChannelMessageDelete(channelID, messages[0])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
data := struct {
|
||||||
|
Messages []string `json:"messages"`
|
||||||
|
}{messages}
|
||||||
|
|
||||||
|
_, err = s.Request("POST", CHANNEL_MESSAGES_BULK_DELETE(channelID), data)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// ChannelFileSend sends a file to the given channel.
|
// ChannelFileSend sends a file to the given channel.
|
||||||
// channelID : The ID of a Channel.
|
// channelID : The ID of a Channel.
|
||||||
// io.Reader : A reader for the file contents.
|
// io.Reader : A reader for the file contents.
|
||||||
|
|
Loading…
Reference in a new issue