Browse Source

More printfs

LEGOlord208 7 years ago
parent
commit
2079ab8efb
3 changed files with 15 additions and 12 deletions
  1. 11 8
      restapi.go
  2. 1 2
      types.go
  3. 3 2
      voice.go

+ 11 - 8
restapi.go

@@ -87,7 +87,7 @@ func (s *Session) request(method, urlStr, contentType string, b []byte, bucketID
 
 
 	req.Header.Set("Content-Type", contentType)
 	req.Header.Set("Content-Type", contentType)
 	// TODO: Make a configurable static variable.
 	// TODO: Make a configurable static variable.
-	req.Header.Set("User-Agent", fmt.Sprintf("DiscordBot (https://github.com/bwmarrin/discordgo, v%s)", VERSION))
+	req.Header.Set("User-Agent", "DiscordBot (https://github.com/bwmarrin/discordgo, v"+VERSION)
 
 
 	if s.Debug {
 	if s.Debug {
 		for k, v := range req.Header {
 		for k, v := range req.Header {
@@ -247,7 +247,7 @@ func (s *Session) Register(username string) (token string, err error) {
 // even use.
 // even use.
 func (s *Session) Logout() (err error) {
 func (s *Session) Logout() (err error) {
 
 
-	//  _, err = s.Request("POST", LOGOUT, fmt.Sprintf(`{"token": "%s"}`, s.Token))
+	//  _, err = s.Request("POST", LOGOUT, `{"token": "` + s.Token + `"}`)
 
 
 	if s.Token == "" {
 	if s.Token == "" {
 		return
 		return
@@ -410,7 +410,7 @@ func (s *Session) UserGuilds(limit int, beforeID, afterID string) (st []*UserGui
 	uri := EndpointUserGuilds("@me")
 	uri := EndpointUserGuilds("@me")
 
 
 	if len(v) > 0 {
 	if len(v) > 0 {
-		uri = fmt.Sprintf("%s?%s", uri, v.Encode())
+		uri += "?" + v.Encode()
 	}
 	}
 
 
 	body, err := s.RequestWithBucketID("GET", uri, nil, EndpointUserGuilds(""))
 	body, err := s.RequestWithBucketID("GET", uri, nil, EndpointUserGuilds(""))
@@ -733,7 +733,7 @@ func (s *Session) GuildMembers(guildID string, after string, limit int) (st []*M
 	}
 	}
 
 
 	if len(v) > 0 {
 	if len(v) > 0 {
-		uri = fmt.Sprintf("%s?%s", uri, v.Encode())
+		uri += "?" + v.Encode()
 	}
 	}
 
 
 	body, err := s.RequestWithBucketID("GET", uri, nil, EndpointGuildMembers(guildID))
 	body, err := s.RequestWithBucketID("GET", uri, nil, EndpointGuildMembers(guildID))
@@ -1018,7 +1018,7 @@ func (s *Session) GuildPruneCount(guildID string, days uint32) (count uint32, er
 		Pruned uint32 `json:"pruned"`
 		Pruned uint32 `json:"pruned"`
 	}{}
 	}{}
 
 
-	uri := EndpointGuildPrune(guildID) + fmt.Sprintf("?days=%d", days)
+	uri := EndpointGuildPrune(guildID) + "?days=" + days
 	body, err := s.RequestWithBucketID("GET", uri, nil, EndpointGuildPrune(guildID))
 	body, err := s.RequestWithBucketID("GET", uri, nil, EndpointGuildPrune(guildID))
 
 
 	err = unmarshal(body, &p)
 	err = unmarshal(body, &p)
@@ -1281,7 +1281,7 @@ func (s *Session) ChannelMessages(channelID string, limit int, beforeID, afterID
 		v.Set("around", aroundID)
 		v.Set("around", aroundID)
 	}
 	}
 	if len(v) > 0 {
 	if len(v) > 0 {
-		uri = fmt.Sprintf("%s?%s", uri, v.Encode())
+		uri += "?" + v.Encode()
 	}
 	}
 
 
 	body, err := s.RequestWithBucketID("GET", uri, nil, EndpointChannelMessages(channelID))
 	body, err := s.RequestWithBucketID("GET", uri, nil, EndpointChannelMessages(channelID))
@@ -1382,7 +1382,10 @@ func (s *Session) ChannelMessageSendComplex(channelID string, data *MessageSend)
 
 
 		for i, file := range files {
 		for i, file := range files {
 			h := make(textproto.MIMEHeader)
 			h := make(textproto.MIMEHeader)
-			h.Set("Content-Disposition", fmt.Sprintf(`form-data; name="file%d"; filename="%s"`, i, quoteEscaper.Replace(file.Name)))
+			h.Set("Content-Disposition",
+				`form-data; name="file`+strconv.Itoa(i)+
+					`"; filename="`+quoteEscaper.Replace(file.Name)+
+					`"`)
 			contentType := file.ContentType
 			contentType := file.ContentType
 			if contentType == "" {
 			if contentType == "" {
 				contentType = "application/octet-stream"
 				contentType = "application/octet-stream"
@@ -1943,7 +1946,7 @@ func (s *Session) MessageReactions(channelID, messageID, emojiID string, limit i
 	}
 	}
 
 
 	if len(v) > 0 {
 	if len(v) > 0 {
-		uri = fmt.Sprintf("%s?%s", uri, v.Encode())
+		uri += "?" + v.Encode()
 	}
 	}
 
 
 	body, err := s.RequestWithBucketID("GET", uri, nil, EndpointMessageReaction(channelID, "", "", ""))
 	body, err := s.RequestWithBucketID("GET", uri, nil, EndpointMessageReaction(channelID, "", "", ""))

+ 1 - 2
types.go

@@ -11,7 +11,6 @@ package discordgo
 
 
 import (
 import (
 	"encoding/json"
 	"encoding/json"
-	"fmt"
 	"net/http"
 	"net/http"
 	"time"
 	"time"
 )
 )
@@ -54,5 +53,5 @@ func newRestError(req *http.Request, resp *http.Response, body []byte) *RESTErro
 }
 }
 
 
 func (r RESTError) Error() string {
 func (r RESTError) Error() string {
-	return fmt.Sprintf("HTTP %s, %s", r.Response.Status, r.ResponseBody)
+	return "HTTP " + r.Response.Status + ", " + r.ResponseBody
 }
 }

+ 3 - 2
voice.go

@@ -16,6 +16,7 @@ import (
 	"log"
 	"log"
 	"net"
 	"net"
 	"runtime"
 	"runtime"
+	"strconv"
 	"strings"
 	"strings"
 	"sync"
 	"sync"
 	"time"
 	"time"
@@ -301,7 +302,7 @@ func (v *VoiceConnection) open() (err error) {
 	}
 	}
 
 
 	// Connect to VoiceConnection Websocket
 	// Connect to VoiceConnection Websocket
-	vg := fmt.Sprintf("wss://%s", strings.TrimSuffix(v.endpoint, ":80"))
+	vg := "wss://" + strings.TrimSuffix(v.endpoint, ":80")
 	v.log(LogInformational, "connecting to voice endpoint %s", vg)
 	v.log(LogInformational, "connecting to voice endpoint %s", vg)
 	v.wsConn, _, err = websocket.DefaultDialer.Dial(vg, nil)
 	v.wsConn, _, err = websocket.DefaultDialer.Dial(vg, nil)
 	if err != nil {
 	if err != nil {
@@ -544,7 +545,7 @@ func (v *VoiceConnection) udpOpen() (err error) {
 		return fmt.Errorf("empty endpoint")
 		return fmt.Errorf("empty endpoint")
 	}
 	}
 
 
-	host := fmt.Sprintf("%s:%d", strings.TrimSuffix(v.endpoint, ":80"), v.op2.Port)
+	host := strings.TrimSuffix(v.endpoint, ":80") + ":" + strconv.Itoa(v.op2.Port)
 	addr, err := net.ResolveUDPAddr("udp", host)
 	addr, err := net.ResolveUDPAddr("udp", host)
 	if err != nil {
 	if err != nil {
 		v.log(LogWarning, "error resolving udp host %s, %s", host, err)
 		v.log(LogWarning, "error resolving udp host %s, %s", host, err)