From 78a76ecb4201bacc4daee3ab5ae45bd07429c8f6 Mon Sep 17 00:00:00 2001 From: diamondburned Date: Wed, 16 Dec 2020 14:51:00 -0800 Subject: [PATCH] Discord: Revert "APIEmoji shouldn't be path-encoded" This reverts commit dae2a0ffc13546ebba0645617d9dd88142ef6122. --- api/message_reaction.go | 8 ++++---- discord/emoji.go | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/api/message_reaction.go b/api/message_reaction.go index 4ffc234..f902e20 100644 --- a/api/message_reaction.go +++ b/api/message_reaction.go @@ -21,7 +21,7 @@ func (c *Client) React( "PUT", EndpointChannels+channelID.String()+ "/messages/"+messageID.String()+ - "/reactions/"+emoji.String()+"/@me", + "/reactions/"+emoji.PathString()+"/@me", ) } @@ -176,7 +176,7 @@ func (c *Client) reactionsRange( return users, c.RequestJSON( &users, "GET", EndpointChannels+channelID.String()+ "/messages/"+messageID.String()+ - "/reactions/"+emoji.String(), + "/reactions/"+emoji.PathString(), httputil.WithSchema(c, param), ) } @@ -200,7 +200,7 @@ func (c *Client) DeleteUserReaction( "DELETE", EndpointChannels+channelID.String()+ "/messages/"+messageID.String()+ - "/reactions/"+emoji.String()+"/"+user, + "/reactions/"+emoji.PathString()+"/"+user, ) } @@ -216,7 +216,7 @@ func (c *Client) DeleteReactions( "DELETE", EndpointChannels+channelID.String()+ "/messages/"+messageID.String()+ - "/reactions/"+emoji.String(), + "/reactions/"+emoji.PathString(), ) } diff --git a/discord/emoji.go b/discord/emoji.go index db18381..9a332ca 100644 --- a/discord/emoji.go +++ b/discord/emoji.go @@ -1,6 +1,7 @@ package discord import ( + "net/url" "strings" ) @@ -81,9 +82,9 @@ func NewCustomEmoji(id EmojiID, name string) APIEmoji { return APIEmoji(name + ":" + id.String()) } -// String converts the APIEmoji to a string. -func (e APIEmoji) String() string { - return string(e) +// PathString returns the APIEmoji as a path-encoded string. +func (e APIEmoji) PathString() string { + return url.PathEscape(string(e)) } // APIString returns a string usable for sending over to the API.