Documentation
¶
Index ¶
- Variables
- func DataURI(contentType, base64EncodedData string) string
- func ImageDataURI(img []byte) string
- func InterceptSignal(signals []os.Signal, sessions ...*disgo.Session) error
- func NumOptions(options []*disgo.ApplicationCommandInteractionDataOption) int
- func OptionsToMap(optionMap map[string]*disgo.ApplicationCommandInteractionDataOption, ...) map[string]*disgo.ApplicationCommandInteractionDataOption
- func ReconnectOnUnexpectedDisconnection(bot *disgo.Client, s *disgo.Session, reconnectOnErr ...func(error) bool)
Constants ¶
This section is empty.
Variables ¶
var ( // ReconnectOnUnexpectedDisconnectionHandlers represents default handlers the user can pass to // ReconnectOnUnexpectedDisconnection() to reconnect the bot. // // Read https://github.com/switchupcb/disgo/discussions/82 for more information about each handler. ReconnectOnUnexpectedDisconnectionHandlers = []func(error) bool{ func(err error) bool { return strings.Contains(err.Error(), "failed to get reader: failed to read frame header: EOF") }, func(err error) bool { closeErr := new(websocket.CloseError) return errors.As(err, closeErr) && closeErr.Code == 1001 }, } // ReconnectOnUnexpectedDisconnectionWait represents the amount of time to wait before reconnecting // to the Discord Gateway in ReconnectOnUnexpectedDisconnection() [default: time.Second * 5]. ReconnectOnUnexpectedDisconnectionWait = time.Second * 5 )
Functions ¶
func DataURI ¶
DataURI returns a Data URI from the given HTTP Content Type Header and base64 encoded data.
func ImageDataURI ¶
ImageDataURI returns a Data URI from the given image data.
func InterceptSignal ¶
InterceptSignal blocks until the provided signals are intercepted.
Upon receiving a signal, the given sessions are gracefully disconnected.
func NumOptions ¶
func NumOptions(options []*disgo.ApplicationCommandInteractionDataOption) int
NumOptions determines the amount of options (and suboptions) in a given array of options.
func OptionsToMap ¶
func OptionsToMap( optionMap map[string]*disgo.ApplicationCommandInteractionDataOption, options []*disgo.ApplicationCommandInteractionDataOption, amount int, ) map[string]*disgo.ApplicationCommandInteractionDataOption
OptionsToMap parses an array of options and suboptions into an OptionMap.
func ReconnectOnUnexpectedDisconnection ¶ added in v1.10.21
func ReconnectOnUnexpectedDisconnection(bot *disgo.Client, s *disgo.Session, reconnectOnErr ...func(error) bool)
ReconnectOnUnexpectedDisconnection reconnects a session when it disconnects unexpectedly.
Use this function with `tools.ReconnectOnUnexpectedDisconnectionHandlers` or custom handlers (`func(error) bool`): The bot is reconnected when a single handler returns true.
WARNING: You are recommended to run this function on a goroutine.
Calling this function blocks the thread until the Session exits the connection loop.
Types ¶
This section is empty.