Skip to content

Commit

Permalink
Added DeleteAllReactions, changed API reaction methods
Browse files Browse the repository at this point in the history
  • Loading branch information
diamondburned committed Jan 23, 2020
1 parent c6155d6 commit ce5f15f
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions api/message_reaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ func (c *Client) React(
return c.FastRequest("PUT", msgURL)
}

// Unreact removes own's reaction from the message.
func (c *Client) Unreact(chID, msgID discord.Snowflake, emoji EmojiAPI) error {
return c.DeleteUserReaction(chID, msgID, 0, emoji)
}

// Reactions returns all reactions. It will paginate automatically.
func (c *Client) Reactions(
channelID, messageID discord.Snowflake,
Expand Down Expand Up @@ -101,34 +106,30 @@ func (c *Client) ReactionsRange(
}

// DeleteReaction requires MANAGE_MESSAGES if not @me.
func (c *Client) DeleteReaction(
func (c *Client) DeleteUserReaction(
chID, msgID, userID discord.Snowflake, emoji EmojiAPI) error {

var user = "@me"
if userID > 0 {
user = userID.String()
}

var msgURL = EndpointChannels + chID.String() +
"/messages/" + msgID.String() +
"/reactions/" + emoji + "/" + user

return c.FastRequest("DELETE", msgURL)
return c.FastRequest("DELETE", EndpointChannels+chID.String()+
"/messages/"+msgID.String()+
"/reactions/"+emoji+"/"+user)
}

func (c *Client) DeleteOwnReaction(
// DeleteReactions equires MANAGE_MESSAGE.
func (c *Client) DeleteReactions(
chID, msgID discord.Snowflake, emoji EmojiAPI) error {

return c.DeleteReaction(chID, msgID, 0, emoji)
return c.FastRequest("DELETE", EndpointChannels+chID.String()+
"/messages/"+msgID.String()+
"/reactions/"+emoji)
}

// DeleteAllReactions equires MANAGE_MESSAGE.
func (c *Client) DeleteAllReactions(
chID, msgID discord.Snowflake, emoji EmojiAPI) error {

var msgURL = EndpointChannels + chID.String() +
"/messages/" + msgID.String() +
"/reactions/" + emoji

return c.FastRequest("DELETE", msgURL)
func (c *Client) DeleteAllReactions(chID, msgID discord.Snowflake) error {
return c.FastRequest("DELETE", EndpointChannels+chID.String()+
"/messages/"+msgID.String()+"/reactions/")
}

0 comments on commit ce5f15f

Please sign in to comment.