rpcfetch

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Dispatch indicates an event was dispatched.
	Dispatch = iota
	// Heartbeat is fired periodically by the client to keep the connection alive.
	Heartbeat
	// Identify starts a new session during the initial handshake.
	Identify
	// PresenceUpdate update the client's presence.
	PresenceUpdate
	// VoiceStateUpdate is used to join/leave or move between voice channels.
	VoiceStateUpdate
	// Resume a previous session that was disconnected.
	Resume
	// Reconnect indicates you should attempt to reconnect and resume immediately.
	Reconnect
	// RequestGuildMembers requests information about offline guild members in a large guild.
	RequestGuildMembers
	// InvalidSession indicates that the session has been invalidated. You should reconnect and identify/resume accordingly.
	InvalidSession
	// Hello is sent immediately after connecting, contains the heartbeat_interval to use.
	Hello
	// HeartbeatACK is sent in response to receiving a heartbeat to acknowledge that it has been received.
	HeartbeatACK
)

Variables

View Source
var (
	ErrAgain = errors.New("operation not performed")
)
View Source
var (
	ErrNonce = errors.New("nonce mismatch")
)

Functions

func Raw

func Raw[T any](d *Client, opcode uint32, payload any) (uint32, T, error)

Raw wraps around the Raw method to provide generic json parsing

Types

type Activity

type Activity struct {
	// State is the user's current party status, or text used for a custom status
	State string `json:"state,omitempty"`
	// Details is what the player is currently doing
	Details string `json:"details,omitempty"`
	// Timestamps are Unix timestamps for start and/or end of the game
	Timestamps *ActivityTimestamps `json:"timestamps,omitempty"`
	// Assets are images for the presence and their hover texts
	Assets *ActivityAssets `json:"assets,omitempty"`
	// Party is information for the current party of the player
	Party *ActivityParty `json:"party,omitempty"`
	// Secrets for Rich Presence joining and spectating
	Secrets *ActivitySecrets `json:"secrets,omitempty"`
	// Instance is whether or not the activity is an instanced game session
	Instance bool `json:"instance,omitempty"`
}

type ActivityAssets

type ActivityAssets struct {
	// LargeImage is the large image asset
	LargeImage string `json:"large_image,omitempty"`
	// LargeText is the text displayed when hovering over the large image of the activity
	LargeText string `json:"large_text,omitempty"`
	// SmallImage is the small image asset
	SmallImage string `json:"small_image,omitempty"`
	// SmallText is the text displayed when hovering over the small image of the activity
	SmallText string `json:"small_text,omitempty"`
}

type ActivityParty

type ActivityParty struct {
	// ID of the party
	ID string `json:"id,omitempty"`
	// Size is used to show the party's current and maximum size
	Size *[2]int `json:"size,omitempty"`
}

type ActivitySecrets

type ActivitySecrets struct {
	// Join is the secret for joining a party
	Join string `json:"join,omitempty"`
	// Spectate is the secret for spectating a game
	Spectate string `json:"spectate,omitempty"`
	// Match is the secret for a specific instanced match
	Match string `json:"match,omitempty"`
}

type ActivityTimestamps

type ActivityTimestamps struct {
	// Start is the Unix time (in milliseconds) of when the activity started
	Start *int64 `json:"start,omitempty"`
	// End is the Unix time (in milliseconds) of when the activity ends
	End *int64 `json:"end,omitempty"`
}

type Client

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

func New

func New(id string) *Client

New sets up and returns the reference to a new Client

func (*Client) Close

func (d *Client) Close() error

Close the client, this is required before exit

func (*Client) Config

func (d *Client) Config() (Config, bool)

Config returns the Client Config nil-safely

func (*Client) ID

func (d *Client) ID() string

ID returns the Client Application ID nil-safely

func (*Client) Raw

func (d *Client) Raw(opcode uint32, payload any) (uint32, []byte, error)

Raw writes a raw payload to Discord and returns the response opcode and payload

func (*Client) SetActivity

func (d *Client) SetActivity(act *Activity) (string, error)

func (*Client) User

func (d *Client) User() (User, bool)

User returns the Client User nil-safely

type Command

type Command[A any] struct {
	// Arguments are command arguments, present in commands sent to the server
	Arguments A `json:"args,omitempty"`
	// contains filtered or unexported fields
}

type Config

type Config struct {
	APIEndpoint string `json:"api_endpoint"`
	CDNHost     string `json:"cdn_host"`
	Environment string `json:"environment"`
}

type ReadyData

type ReadyData struct {
	Config  Config `json:"config"`
	User    User   `json:"user"`
	Version int    `json:"v"`
}

type Response

type Response[D any] struct {
	// Data is the event data, present in responses from the server
	Data D `json:"data,omitempty"`
	// contains filtered or unexported fields
}

type User

type User struct {
	Avatar        string `json:"avatar"`
	Discriminator string `json:"discriminator"`
	Flags         int    `json:"flags"`
	ID            string `json:"id"`
	PremiumType   int    `json:"premium_type"`
	Username      string `json:"username"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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