Documentation ¶
Index ¶
- func Do(ctx context.Context, e *endpoint.Endpoint, p *Payload) (*http.Response, error)
- func DoWithHeader(ctx context.Context, e *endpoint.Endpoint, p *Payload, h http.Header) (*http.Response, error)
- func MultipartFromFiles(payload MultipartPayload, files ...discord.File) ([]byte, string, error)
- func ReasonHeader(r string) http.Header
- type Client
- type MultipartPayload
- type Payload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Do ¶
Do is used to request endpoints that do not need authentication. If you need more control over headers you send, use DoWithHeader directly.
func DoWithHeader ¶
func DoWithHeader(ctx context.Context, e *endpoint.Endpoint, p *Payload, h http.Header) (*http.Response, error)
Do is used to request endpoints that do not need authentication. It is like DoWithHeader otherwise, except for rate limiting where it is more likely to result in 429's if abused.
func MultipartFromFiles ¶
MultipartFromFiles generate a multipart body given a payload and some files. It returns the raw generated body along the content type of this body.
func ReasonHeader ¶
ReasonHeader returns an HTTP header with the Audit Log reason set to r.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a client that can make HTTP requests to Discord's REST API.
func (*Client) Do ¶
Do is used to request Discord's HTTP endpoints. If you need more control over headers you send, use DoWithHeader directly.
func (*Client) DoWithHeader ¶
func (c *Client) DoWithHeader(ctx context.Context, e *endpoint.Endpoint, p *Payload, h http.Header) (*http.Response, error)
DoWithHeader sends an HTTP request and returns the response given an endpoint an optional payload and some headers. It adds the required Authorization header, Content-Type based on the given payload and also sets the User-Agent. It also takes care of rate limiting, using the client's built in rate limiter.
type MultipartPayload ¶
MultipartPayload defines a payload that can be used in a multipart upload.
type Payload ¶
type Payload struct {
// contains filtered or unexported fields
}
Payload is a payload that is sent to Discord's REST API.
func CustomPayload ¶
CustomPayload creates a new custom payload from raw bytes and a given content type.
func JSONPayload ¶
func JSONPayload(body json.RawMessage) *Payload
JSONPayload creates a new Payload from some raw JSON data.