Documentation ¶
Index ¶
- Constants
- func GlobalRateLimit(resp *http.Response) bool
- func GlobalRateLimitSafe(resp *http.Response, body *ratelimitBody) bool
- func RateLimited(resp *http.Response) bool
- func RatelimitChannel(id Snowflake) string
- func RatelimitChannelInvites(id Snowflake) string
- func RatelimitChannelMessages(id Snowflake) string
- func RatelimitChannelMessagesDelete(id Snowflake) string
- func RatelimitChannelPermissions(id Snowflake) string
- func RatelimitChannelPins(id Snowflake) string
- func RatelimitChannelRecipients(id Snowflake) string
- func RatelimitChannelTyping(id Snowflake) string
- func RatelimitChannelWebhooks(id Snowflake) string
- func RatelimitGuild(id Snowflake) string
- func RatelimitGuildAuditLogs(id Snowflake) string
- func RatelimitGuildBans(id Snowflake) string
- func RatelimitGuildChannels(id Snowflake) string
- func RatelimitGuildEmbed(id Snowflake) string
- func RatelimitGuildIntegrations(id Snowflake) string
- func RatelimitGuildInvites(id Snowflake) string
- func RatelimitGuildMembers(id Snowflake) string
- func RatelimitGuildPrune(id Snowflake) string
- func RatelimitGuildRegions(id Snowflake) string
- func RatelimitGuildRoles(id Snowflake) string
- func RatelimitGuildVanityURL(id Snowflake) string
- func RatelimitGuildWebhooks(id Snowflake) string
- func RatelimitUsers() string
- func RatelimitWebhook(id Snowflake) string
- func SupportsDiscordAPIVersion(version int) bool
- type Bucket
- type Client
- func (c *Client) Delete(req *Request) (resp *http.Response, body []byte, err error)
- func (c *Client) Get(req *Request) (resp *http.Response, body []byte, err error)
- func (c *Client) Patch(req *Request) (resp *http.Response, body []byte, err error)
- func (c *Client) Post(req *Request) (resp *http.Response, body []byte, err error)
- func (c *Client) Put(req *Request) (resp *http.Response, body []byte, err error)
- func (c *Client) RateLimiter() RateLimiter
- func (c *Client) Request(r *Request) (resp *http.Response, body []byte, err error)
- type Config
- type Deleter
- type Details
- type Getter
- type Patcher
- type Poster
- type Puter
- type RateLimit
- type RateLimitInfo
- type RateLimiter
- type Request
- type Requester
Constants ¶
View Source
const ( BaseURL = "https://discordapp.com/api" // Header AuthorizationFormat = "Bot %s" UserAgentFormat = "DiscordBot (%s, %s) %s" HTTPCodeRateLimit int = 429 ContentEncoding = "Content-Encoding" GZIPCompression = "gzip" )
View Source
const ( XRateLimitLimit = "X-RateLimit-Limit" XRateLimitRemaining = "X-RateLimit-Remaining" XRateLimitReset = "X-RateLimit-Reset" // is converted from seconds to milliseconds! XRateLimitGlobal = "X-RateLimit-Global" RateLimitRetryAfter = "Retry-After" GlobalRateLimiterKey = "" )
Variables ¶
This section is empty.
Functions ¶
func GlobalRateLimit ¶
GlobalRateLimit assumes that there will always be a header entry when a global rate limit kicks in
func GlobalRateLimitSafe ¶
func RateLimited ¶
func RatelimitChannelInvites ¶
func RatelimitChannelInvites(id Snowflake) string
func RatelimitChannelMessages ¶
func RatelimitChannelMessages(id Snowflake) string
func RatelimitChannelMessagesDelete ¶
func RatelimitChannelMessagesDelete(id Snowflake) string
func RatelimitChannelPermissions ¶
func RatelimitChannelPermissions(id Snowflake) string
func RatelimitChannelPins ¶
func RatelimitChannelPins(id Snowflake) string
func RatelimitChannelRecipients ¶
func RatelimitChannelRecipients(id Snowflake) string
func RatelimitChannelTyping ¶
func RatelimitChannelTyping(id Snowflake) string
func RatelimitChannelWebhooks ¶
func RatelimitChannelWebhooks(id Snowflake) string
func RatelimitGuild ¶
func RatelimitGuild(id Snowflake) string
func RatelimitGuildAuditLogs ¶
func RatelimitGuildAuditLogs(id Snowflake) string
func RatelimitGuildBans ¶
func RatelimitGuildBans(id Snowflake) string
func RatelimitGuildChannels ¶
func RatelimitGuildChannels(id Snowflake) string
func RatelimitGuildEmbed ¶
func RatelimitGuildEmbed(id Snowflake) string
func RatelimitGuildIntegrations ¶
func RatelimitGuildIntegrations(id Snowflake) string
func RatelimitGuildInvites ¶
func RatelimitGuildInvites(id Snowflake) string
func RatelimitGuildMembers ¶
func RatelimitGuildMembers(id Snowflake) string
func RatelimitGuildPrune ¶
func RatelimitGuildPrune(id Snowflake) string
func RatelimitGuildRegions ¶
func RatelimitGuildRegions(id Snowflake) string
func RatelimitGuildRoles ¶
func RatelimitGuildRoles(id Snowflake) string
func RatelimitGuildVanityURL ¶
func RatelimitGuildVanityURL(id Snowflake) string
func RatelimitGuildWebhooks ¶
func RatelimitGuildWebhooks(id Snowflake) string
func RatelimitUsers ¶
func RatelimitUsers() string
func RatelimitWebhook ¶
func RatelimitWebhook(id Snowflake) string
func SupportsDiscordAPIVersion ¶
SupportsDiscordAPIVersion check if a given discord api version is supported by this package.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) RateLimiter ¶
func (c *Client) RateLimiter() RateLimiter
type RateLimit ¶
type RateLimit struct {
// contains filtered or unexported fields
}
RateLimit TODO: a bucket is created for every request. Might want to delete them after a while. seriously. `/users/1` has the same ratelimiter as `/users/2` but any major endpoint prefix does not: `/channels/1` != `/channels/2`
func NewRateLimit ¶
func NewRateLimit() *RateLimit
func (*RateLimit) RateLimitTimeout ¶
func (*RateLimit) RateLimited ¶
func (*RateLimit) UpdateRegisters ¶
TODO: rewrite
type RateLimitInfo ¶
type RateLimitInfo struct { Message string `json:"message"` RetryAfter int64 `json:"retry_after"` Global bool `json:"global"` Limit int `json:"-"` Remaining int `json:"-"` Reset int64 `json:"-"` Empty bool `json:"-"` }
func ExtractRateLimitInfo ¶
func ExtractRateLimitInfo(resp *http.Response, body []byte) (info *RateLimitInfo, err error)
type RateLimiter ¶
type Requester ¶
type Requester interface { Request(req *Request) (resp *http.Response, body []byte, err error) Get(req *Request) (resp *http.Response, body []byte, err error) Post(req *Request) (resp *http.Response, body []byte, err error) Put(req *Request) (resp *http.Response, body []byte, err error) Patch(req *Request) (resp *http.Response, body []byte, err error) Delete(req *Request) (resp *http.Response, body []byte, err error) }
Click to show internal directories.
Click to hide internal directories.