api

package
v0.0.0-...-cc3410b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	API_VERSION     = "9"
	BROWSER         = "Firefox"
	BROWSER_VERSION = "111.0"
	CAPABILITIES    = 4093
	DEVICE          = "" // Discord's official client sends an empty string.
	OS              = "Windows"
	OS_VERSION      = "10"
	STATUS          = "offline" // https://discord.com/developers/docs/topics/gateway-events#update-presence-status-types
	USER_AGENT      = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/" + BROWSER_VERSION
)

Variables

View Source
var (
	JS_FILE_REGEX    = regexp.MustCompile(`([a-zA-z0-9]+)\.js`)
	BUILD_INFO_REGEX = regexp.MustCompile(`Build Number: "\)\.concat\("([0-9]{4,8})"`)
)

Functions

This section is empty.

Types

type Gateway

type Gateway struct {
	CloseChan         chan struct{}   // CloseChan is used as a signal to stop for the gateway's goroutines.
	Conn              *websocket.Conn // Conn represents a connection to the Discord WebSocket.
	GatewayURL        string          // GatewayURL contains the URL used when resuming after a disconnect.
	Handlers          *Handlers       // Handles for gateway events
	HeartbeatInterval time.Duration   // The interval the client should wait between sending heartbeats.
	LastSeq           float64         // LastSeq contains the last sequence number received by the client.
	SelfBot           *SelfBot        // SelfBot contains data relating to the self-bot.
	SessionID         string          // SessionID contains the ID of the gateway.
}

Gateway represents a Discord WebSocket connection.

func CreateGateway

func CreateGateway(selfBot *SelfBot) *Gateway

func (*Gateway) Connect

func (gateway *Gateway) Connect() error

type Handlers

type Handlers struct {
	OnHello         []func(*dasgo.Hello)
	OnMessageCreate []func(*dasgo.Message)
	OnReady         []func(*dasgo.Ready)
	OnReconnect     []func(*dasgo.Reconnect)
	// contains filtered or unexported fields
}

Handlers contains handlers for gateway events.

func (*Handlers) Add

func (handlers *Handlers) Add(event string, function any) error

type SelfBot

type SelfBot struct {
	AccentColor    float64       `mapstructure:"accent_color"`
	Avatar         string        `mapstructure:"avatar"`
	BannerColor    string        `mapstructure:"banner_color"`
	Bio            string        `mapstructure:"bio"`
	Desktop        bool          `mapstructure:"desktop"`
	Discriminator  string        `mapstructure:"discriminator"`
	DisplayName    string        `mapstructure:"display_name"`
	Email          string        `mapstructure:"email"`
	Flags          dasgo.BitFlag `mapstructure:"flags"`
	GlobalName     string        `mapstructure:"global_name"`
	ID             string        `mapstructure:"id"`
	MFAEnabled     bool          `mapstructure:"mfa_enabled"`
	Mobile         bool          `mapstructure:"mobile"`
	NSFWAllowed    bool          `mapstructure:"nsfw_allowed"`
	Phone          string        `mapstructure:"phone"`
	Premium        bool          `mapstructure:"premium"`
	PremiumType    float64       `mapstructure:"premium_type"`
	PublicFlags    dasgo.BitFlag `mapstructure:"public_flags"`
	PurchasedFlags dasgo.BitFlag `mapstructure:"purchased_flags"`
	Username       string        `mapstructure:"username"`
	Verified       bool          `mapstructure:"verified"`
	Token          string
}

Me represents the self-bot.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL