Documentation ¶
Index ¶
Constants ¶
View Source
const ( // Revolts API RevoltAPI = "https://api.revolt.chat/" // The staging API, used by the official apps etc, default RevoltAPIStaging = "https://app.revolt.chat/api/" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Request ¶
type Request[T any] struct { Method Method Path string Json any Headers map[string]string Cookies []http.Cookie // Initial response, if any InitialResp *T // contains filtered or unexported fields }
A request to the API
func (Request[T]) NoContent ¶
func (r Request[T]) NoContent(config *RestConfig) error
Discards the content as long as the response is OK otherwise error is returned
func (Request[T]) Request ¶
func (r Request[T]) Request(config *RestConfig) (*http.Response, error)
Makes a request to the API
func (Request[T]) With ¶
func (r Request[T]) With(config *RestConfig) (*T, error)
Executes the request and unmarshals the response body if the response is OK otherwise returns error
type RequestData ¶
type RequestData struct { Method Method Path string Json any Headers map[string]string Config *RestConfig }
Request data from API, but not generic so can be used in OnMarshal and other functions
In addition to typical Request data, this also contains config.Config
type RestConfig ¶
type RestConfig struct { // The URL of the API APIUrl string // Timeout for requests Timeout time.Duration // Logger to use, will be autofilled if not provided Logger *zap.Logger // Session token for requests SessionToken *auth.Token // Ratelimiter Ratelimiter *ratelimits.RateLimiter // Max tries for requests MaxRestRetries int // On ratelimit function OnRatelimit func(*types.RateLimit) // Whether or not to retry on ratelimit RetryOnRatelimit bool // Pester client Pester *pester.Client // Functions to run upon successful marshal OnMarshal []func(r *RequestData, v any) error SharedState *state.State // Disable rest caching DisableRestCaching bool }
func DefaultRestConfig ¶
func DefaultRestConfig() RestConfig
DefaultRestConfig is the default configuration for the client
Directories ¶
Path | Synopsis |
---|---|
Ratelimits impl from https://github.com/bwmarrin/discordgo/blob/master/ratelimit.go
|
Ratelimits impl from https://github.com/bwmarrin/discordgo/blob/master/ratelimit.go |
+interactions <in docs but its actually reactions>
|
+interactions <in docs but its actually reactions> |
Click to show internal directories.
Click to hide internal directories.