Skip to content

Commit

Permalink
Add query params to channels.GetReactions (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebm253 committed May 16, 2024
1 parent 6e679fd commit fbf9a5d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
7 changes: 7 additions & 0 deletions discord/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,13 @@ type ReactionCountDetails struct {
Normal int `json:"normal"`
}

type MessageReactionType int

const (
MessageReactionTypeNormal MessageReactionType = iota
MessageReactionTypeBurst
)

// MessageActivityType is the type of MessageActivity https://com/developers/docs/resources/channel#message-object-message-activity-types
type MessageActivityType int

Expand Down
15 changes: 12 additions & 3 deletions rest/channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type Channels interface {
BulkDeleteMessages(channelID snowflake.ID, messageIDs []snowflake.ID, opts ...RequestOpt) error
CrosspostMessage(channelID snowflake.ID, messageID snowflake.ID, opts ...RequestOpt) (*discord.Message, error)

GetReactions(channelID snowflake.ID, messageID snowflake.ID, emoji string, opts ...RequestOpt) ([]discord.User, error)
GetReactions(channelID snowflake.ID, messageID snowflake.ID, emoji string, reactionType discord.MessageReactionType, after int, limit int, opts ...RequestOpt) ([]discord.User, error)
AddReaction(channelID snowflake.ID, messageID snowflake.ID, emoji string, opts ...RequestOpt) error
RemoveOwnReaction(channelID snowflake.ID, messageID snowflake.ID, emoji string, opts ...RequestOpt) error
RemoveUserReaction(channelID snowflake.ID, messageID snowflake.ID, emoji string, userID snowflake.ID, opts ...RequestOpt) error
Expand Down Expand Up @@ -184,8 +184,17 @@ func (s *channelImpl) CrosspostMessage(channelID snowflake.ID, messageID snowfla
return
}

func (s *channelImpl) GetReactions(channelID snowflake.ID, messageID snowflake.ID, emoji string, opts ...RequestOpt) (users []discord.User, err error) {
err = s.client.Do(GetReactions.Compile(nil, channelID, messageID, emoji), nil, &users, opts...)
func (s *channelImpl) GetReactions(channelID snowflake.ID, messageID snowflake.ID, emoji string, reactionType discord.MessageReactionType, after int, limit int, opts ...RequestOpt) (users []discord.User, err error) {
values := discord.QueryValues{
"type": reactionType,
}
if after != 0 {
values["after"] = after
}
if limit != 0 {
values["limit"] = limit
}
err = s.client.Do(GetReactions.Compile(values, channelID, messageID, emoji), nil, &users, opts...)
return
}

Expand Down

0 comments on commit fbf9a5d

Please sign in to comment.