library

package
v0.0.0-...-cda6680 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GATEWAY string = "wss://gateway.discord.gg/?v=9&encoding=json"
	API     string = "https://discord.com/api/v9"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	ID      Snowflake  `json:"id"`
	GuildID *Snowflake `json:"guild_id"`
	Type    int        `json:"type"`
	Name    *string    `json:"name"`
}

type Guild

type Guild struct {
	ID          Snowflake      `json:"id"`
	Name        string         `json:"name"`
	Icon        *string        `json:"icon"`
	OwnerID     Snowflake      `json:"owner_id"`
	Channels    *[]Channel     `json:"channels"`
	Members     *[]GuildMember `json:"members"`
	Unavailable bool           `json:"unavailable"`
}

type GuildMember

type GuildMember struct {
	User     *User       `json:"user"`
	Nick     *string     `json:"nick"`
	Roles    []Snowflake `json:"roles"`
	JoinedAt string      `json:"joined_at"`
	Avatar   *string     `json:"avatar"`
}

type Heartbeat

type Heartbeat struct {
	Op   int    `json:"op"`
	Data *int64 `json:"d"`
}

type Hello

type Hello struct {
	Op   int `json:"op"`
	Data struct {
		Heartbeat_interval time.Duration `json:"heartbeat_interval"`
	} `json:"d"`
}

type Identify

type Identify struct {
	Op   int `json:"op"`
	Data struct {
		Token      string `json:"token"`
		Properties struct {
			Os      string `json:"os"`
			Browser string `json:"browser"`
			Device  string `json:"device"`
		} `json:"properties"`
		Intents int `json:"intents"`
	} `json:"d"`
}

type Message

type Message struct {
	ID        Snowflake  `json:"id"`
	ChannelID Snowflake  `json:"channel_id"`
	GuildID   *Snowflake `json:"guild_id"`
	Author    *User      `json:"author"`
	Content   string     `json:"content"`
}

type OPCODE

type OPCODE int

type Payload

type Payload struct {
	Op int             `json:"op"`
	D  json.RawMessage `json:"d"`
	S  int64           `json:"s"`
	T  string          `json:"t"`
}

Only used for receiving, sending is handled by the other structures

type PostMessage

type PostMessage struct {
	Content           string `json:"content"`
	Message_reference struct {
		Channel_id string `json:"channel_id"`
		Message_id string `json:"message_id"`
		Guild_id   string `json:"guild_id"`
	} `json:"message_reference"`
}

type Ready

type Ready struct {
	Version   int      `json:"v"`
	SessionID string   `json:"session_id"`
	Shard     []int    `json:"shard"`
	User      User     `json:"user"`
	Guilds    []*Guild `json:"guilds"`
}

type Snowflake

type Snowflake string

type SocketConnection

type SocketConnection struct {
	// contains filtered or unexported fields
}

func (*SocketConnection) AddHandler

func (sConn *SocketConnection) AddHandler(name string, f func(*Message, *PostMessage, string))

func (*SocketConnection) Close

func (sConn *SocketConnection) Close()

func (*SocketConnection) Open

func (sConn *SocketConnection) Open(t string)

type User

type User struct {
	ID            Snowflake `json:"id"`
	Username      string    `json:"username"`
	Discriminator string    `json:"discriminator"`
	Avatar        string    `json:"avatar"`
	Bot           bool      `json:"bot"`
	Email         string    `json:"email"`
}

Jump to

Keyboard shortcuts

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