Discord: Revert "APIEmoji shouldn't be path-encoded"

This reverts commit dae2a0ffc1.
This commit is contained in:
diamondburned 2020-12-16 14:51:00 -08:00
parent dae2a0ffc1
commit 78a76ecb42
2 changed files with 8 additions and 7 deletions

View File

@ -21,7 +21,7 @@ func (c *Client) React(
"PUT", "PUT",
EndpointChannels+channelID.String()+ EndpointChannels+channelID.String()+
"/messages/"+messageID.String()+ "/messages/"+messageID.String()+
"/reactions/"+emoji.String()+"/@me", "/reactions/"+emoji.PathString()+"/@me",
) )
} }
@ -176,7 +176,7 @@ func (c *Client) reactionsRange(
return users, c.RequestJSON( return users, c.RequestJSON(
&users, "GET", EndpointChannels+channelID.String()+ &users, "GET", EndpointChannels+channelID.String()+
"/messages/"+messageID.String()+ "/messages/"+messageID.String()+
"/reactions/"+emoji.String(), "/reactions/"+emoji.PathString(),
httputil.WithSchema(c, param), httputil.WithSchema(c, param),
) )
} }
@ -200,7 +200,7 @@ func (c *Client) DeleteUserReaction(
"DELETE", "DELETE",
EndpointChannels+channelID.String()+ EndpointChannels+channelID.String()+
"/messages/"+messageID.String()+ "/messages/"+messageID.String()+
"/reactions/"+emoji.String()+"/"+user, "/reactions/"+emoji.PathString()+"/"+user,
) )
} }
@ -216,7 +216,7 @@ func (c *Client) DeleteReactions(
"DELETE", "DELETE",
EndpointChannels+channelID.String()+ EndpointChannels+channelID.String()+
"/messages/"+messageID.String()+ "/messages/"+messageID.String()+
"/reactions/"+emoji.String(), "/reactions/"+emoji.PathString(),
) )
} }

View File

@ -1,6 +1,7 @@
package discord package discord
import ( import (
"net/url"
"strings" "strings"
) )
@ -81,9 +82,9 @@ func NewCustomEmoji(id EmojiID, name string) APIEmoji {
return APIEmoji(name + ":" + id.String()) return APIEmoji(name + ":" + id.String())
} }
// String converts the APIEmoji to a string. // PathString returns the APIEmoji as a path-encoded string.
func (e APIEmoji) String() string { func (e APIEmoji) PathString() string {
return string(e) return url.PathEscape(string(e))
} }
// APIString returns a string usable for sending over to the API. // APIString returns a string usable for sending over to the API.