discord

package
v0.0.0-...-c4845e7 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DiscordEpoch = 1420070400000

Variables

View Source
var (
	JS_FILE_REGEX    = regexp.MustCompile(`<script\s+src="([^"]+\.js)"\s+defer>\s*</script>`)
	BUILD_INFO_REGEX = regexp.MustCompile(`Build Number: \"\).concat\(\"(\d+)\"`)
	BUILD_HEADERS    = map[string]string{
		"Accept":             "*/*",
		"Accept-Language":    "en-GB,en-US;q=0.9,en;q=0.8",
		"Cache-Control":      "no-cache",
		"Pragma":             "no-cache",
		"Referer":            "https://discord.com/login",
		"Sec-Ch-Ua":          `"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"`,
		"Sec-Ch-Ua-Mobile":   "?0",
		"Sec-Ch-Ua-Platform": `"macOS"`,
		"Sec-Fetch-Dest":     "script",
		"Sec-Fetch-Mode":     "no-cors",
		"Sec-Fetch-Site":     "same-origin",
		"User-Agent":         "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
	}
)

Functions

func GenerateNonce

func GenerateNonce() string

func GenerateSessionID

func GenerateSessionID() string

func GenerateSuperProperties

func GenerateSuperProperties(gateway *Gateway) string

func TimeSnowflake

func TimeSnowflake(dt time.Time, high bool) int64

func UtcNow

func UtcNow() time.Time

Types

type Gateway

type Gateway struct {
	CloseChan         chan struct{}
	Closed            bool
	Config            *types.Config
	Connection        *websocket.Conn
	GatewayURL        string
	Handlers          Handlers
	LastSeq           int
	Selfbot           *Selfbot
	SessionID         string
	ClientBuildNumber string
	// contains filtered or unexported fields
}

func CreateGateway

func CreateGateway(selfbot *Selfbot, config *types.Config) *Gateway

func (*Gateway) Close

func (gateway *Gateway) Close() error

func (*Gateway) Connect

func (gateway *Gateway) Connect() error

func (*Gateway) GetMembers

func (gateway *Gateway) GetMembers(id string, ids []string) error

type Handlers

type Handlers struct {
	OnReady             []func(data *types.ReadyEventData)
	OnMessageCreate     []func(data *types.MessageEventData)
	OnMessageUpdate     []func(data *types.MessageEventData)
	OnGuildMembersChunk []func(data *types.GuildMembersChunkEventData)
	OnReconnect         []func()

	OnInvalidated []func()
	// contains filtered or unexported fields
}

func (*Handlers) Add

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

type Selfbot

type Selfbot struct {
	Token string
	User  types.User
}

Jump to

Keyboard shortcuts

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