Skip to content

Commit

Permalink
encode emojis
Browse files Browse the repository at this point in the history
  • Loading branch information
bsian03 committed Nov 8, 2024
1 parent 3a19c10 commit 4fb4c2e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ import (
"crypto/tls"
"encoding/json"
"errors"
"github.com/sirupsen/logrus"
"io"
"io/ioutil"
"math"
"net"
"net/http"
"net/url"
"strconv"
"strings"
"time"

"github.com/sirupsen/logrus"
)

var client *http.Client
Expand Down Expand Up @@ -213,6 +215,15 @@ func GetBotUser(token string) (*BotUserResponse, error) {
}

func doDiscordReq(ctx context.Context, path string, method string, body io.ReadCloser, header http.Header, query string) (*http.Response, error) {
route := GetMetricsPath(path)
if route == "/channels/!/messages/!/reactions/!/!" {
segs := strings.Split(path, "/")
unescaped, _ := url.PathUnescape(segs[7])
if segs[7] == unescaped {
segs[7] = url.PathEscape(segs[7])
}
path = strings.Join(segs, "/")
}
discordReq, err := http.NewRequestWithContext(ctx, method, "https://discord.com"+path+"?"+query, body)
if err != nil {
return nil, err
Expand All @@ -229,7 +240,6 @@ func doDiscordReq(ctx context.Context, path string, method string, body io.ReadC
}

if err == nil {
route := GetMetricsPath(path)
status := discordResp.Status
method := discordResp.Request.Method
elapsed := time.Since(startTime).Seconds()
Expand Down

0 comments on commit 4fb4c2e

Please sign in to comment.