Merge pull request #626 from AtomGrafiks/master

Add pagination to MessageReactions
This commit is contained in:
Carson Hoffman 2019-12-26 20:42:56 -05:00 committed by GitHub
commit 525ac13aa7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2124,7 +2124,9 @@ func (s *Session) MessageReactionsRemoveAll(channelID, messageID string) error {
// messageID : The message ID. // messageID : The message ID.
// emojiID : Either the unicode emoji for the reaction, or a guild emoji identifier. // emojiID : Either the unicode emoji for the reaction, or a guild emoji identifier.
// limit : max number of users to return (max 100) // limit : max number of users to return (max 100)
func (s *Session) MessageReactions(channelID, messageID, emojiID string, limit int) (st []*User, err error) { // beforeID : If provided all reactions returned will be before given ID.
// afterID : If provided all reactions returned will be after given ID.
func (s *Session) MessageReactions(channelID, messageID, emojiID string, limit int, beforeID, afterID string) (st []*User, err error) {
// emoji such as #⃣ need to have # escaped // emoji such as #⃣ need to have # escaped
emojiID = strings.Replace(emojiID, "#", "%23", -1) emojiID = strings.Replace(emojiID, "#", "%23", -1)
uri := EndpointMessageReactions(channelID, messageID, emojiID) uri := EndpointMessageReactions(channelID, messageID, emojiID)
@ -2135,6 +2137,13 @@ func (s *Session) MessageReactions(channelID, messageID, emojiID string, limit i
v.Set("limit", strconv.Itoa(limit)) v.Set("limit", strconv.Itoa(limit))
} }
if afterID != "" {
v.Set("after", afterID)
}
if beforeID != "" {
v.Set("before", beforeID)
}
if len(v) > 0 { if len(v) > 0 {
uri += "?" + v.Encode() uri += "?" + v.Encode()
} }