mirror of
https://github.com/bwmarrin/discordgo.git
synced 2025-12-23 23:17:45 -05:00
feat(Session): expose request as RequestRaw (#1560)
This commit is contained in:
21
restapi.go
21
restapi.go
@@ -178,13 +178,14 @@ func (s *Session) RequestWithBucketID(method, urlStr string, data interface{}, b
|
||||
}
|
||||
}
|
||||
|
||||
return s.request(method, urlStr, "application/json", body, bucketID, 0, options...)
|
||||
return s.RequestRaw(method, urlStr, "application/json", body, bucketID, 0, options...)
|
||||
}
|
||||
|
||||
// request makes a (GET/POST/...) Requests to Discord REST API.
|
||||
// RequestRaw makes a (GET/POST/...) Requests to Discord REST API.
|
||||
// Preferably use the other Request* methods but this lets you send JSON directly if that's what you have.
|
||||
// Sequence is the sequence number, if it fails with a 502 it will
|
||||
// retry with sequence+1 until it either succeeds or sequence >= session.MaxRestRetries
|
||||
func (s *Session) request(method, urlStr, contentType string, b []byte, bucketID string, sequence int, options ...RequestOption) (response []byte, err error) {
|
||||
func (s *Session) RequestRaw(method, urlStr, contentType string, b []byte, bucketID string, sequence int, options ...RequestOption) (response []byte, err error) {
|
||||
if bucketID == "" {
|
||||
bucketID = strings.SplitN(urlStr, "?", 2)[0]
|
||||
}
|
||||
@@ -1012,7 +1013,7 @@ func (s *Session) GuildMemberRoleRemove(guildID, userID, roleID string, options
|
||||
// guildID : The ID of a Guild.
|
||||
func (s *Session) GuildChannels(guildID string, options ...RequestOption) (st []*Channel, err error) {
|
||||
|
||||
body, err := s.request("GET", EndpointGuildChannels(guildID), "", nil, EndpointGuildChannels(guildID), 0, options...)
|
||||
body, err := s.RequestRaw("GET", EndpointGuildChannels(guildID), "", nil, EndpointGuildChannels(guildID), 0, options...)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -1783,7 +1784,7 @@ func (s *Session) ChannelMessageSendComplex(channelID string, data *MessageSend,
|
||||
if encodeErr != nil {
|
||||
return st, encodeErr
|
||||
}
|
||||
response, err = s.request("POST", endpoint, contentType, body, endpoint, 0, options...)
|
||||
response, err = s.RequestRaw("POST", endpoint, contentType, body, endpoint, 0, options...)
|
||||
} else {
|
||||
response, err = s.RequestWithBucketID("POST", endpoint, data, endpoint, options...)
|
||||
}
|
||||
@@ -1895,7 +1896,7 @@ func (s *Session) ChannelMessageEditComplex(m *MessageEdit, options ...RequestOp
|
||||
if encodeErr != nil {
|
||||
return st, encodeErr
|
||||
}
|
||||
response, err = s.request("PATCH", endpoint, contentType, body, EndpointChannelMessage(m.Channel, ""), 0, options...)
|
||||
response, err = s.RequestRaw("PATCH", endpoint, contentType, body, EndpointChannelMessage(m.Channel, ""), 0, options...)
|
||||
} else {
|
||||
response, err = s.RequestWithBucketID("PATCH", endpoint, m, EndpointChannelMessage(m.Channel, ""), options...)
|
||||
}
|
||||
@@ -2432,7 +2433,7 @@ func (s *Session) webhookExecute(webhookID, token string, wait bool, threadID st
|
||||
return st, encodeErr
|
||||
}
|
||||
|
||||
response, err = s.request("POST", uri, contentType, body, uri, 0, options...)
|
||||
response, err = s.RequestRaw("POST", uri, contentType, body, uri, 0, options...)
|
||||
} else {
|
||||
response, err = s.RequestWithBucketID("POST", uri, data, uri, options...)
|
||||
}
|
||||
@@ -2492,7 +2493,7 @@ func (s *Session) WebhookMessageEdit(webhookID, token, messageID string, data *W
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response, err = s.request("PATCH", uri, contentType, body, uri, 0, options...)
|
||||
response, err = s.RequestRaw("PATCH", uri, contentType, body, uri, 0, options...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -2712,7 +2713,7 @@ func (s *Session) ForumThreadStartComplex(channelID string, threadData *ThreadSt
|
||||
return th, encodeErr
|
||||
}
|
||||
|
||||
response, err = s.request("POST", endpoint, contentType, body, endpoint, 0, options...)
|
||||
response, err = s.RequestRaw("POST", endpoint, contentType, body, endpoint, 0, options...)
|
||||
} else {
|
||||
response, err = s.RequestWithBucketID("POST", endpoint, data, endpoint, options...)
|
||||
}
|
||||
@@ -3142,7 +3143,7 @@ func (s *Session) InteractionRespond(interaction *Interaction, resp *Interaction
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = s.request("POST", endpoint, contentType, body, endpoint, 0, options...)
|
||||
_, err = s.RequestRaw("POST", endpoint, contentType, body, endpoint, 0, options...)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user