user

package
v0.0.0-...-8fd61c5 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: BSD-3-Clause Imports: 4 Imported by: 29

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Activity

type Activity struct {
	Name          string       `json:"name"`
	Type          ActivityType `json:"type"`
	Url           string       `json:"url,omitempty"`
	Timestamps    *Timestamps  `json:"timestamps,omitempty"`
	ApplicationId uint64       `json:"application_id,string,omitempty"`
	Details       string       `json:"details,omitempty"`
	State         string       `json:"state,omitempty"`
	// TODO: Figure out how to handle emoji w/o import cycle
	Party    *Party  `json:"party,omitempty"`
	Assets   *Asset  `json:"assets,omitempty"`
	Secret   *Secret `json:"secret,omitempty"`
	Instance bool    `json:"instance,omitempty"`
	Flags    int     `json:"flags,omitempty"` // TODO: Wrap this
}

type ActivityType

type ActivityType int
const (
	ActivityTypePlaying ActivityType = iota
	ActivityTypeStreaming
	ActivityTypeListening
	ActivityTypeWatching
	ActivityTypeCustom
	ActivityTypeCompeting
)

type Asset

type Asset struct {
	LargeImage string `json:"large_image,omitempty"`
	LargeText  string `json:"large_text,omitempty"`
	SmallImage string `json:"small_image,omitempty"`
	SmallText  string `json:"small_text,omitempty"`
}

type Avatar

type Avatar struct {
	Animated bool
	// contains filtered or unexported fields
}

func (Avatar) MarshalJSON

func (a Avatar) MarshalJSON() ([]byte, error)

func (*Avatar) String

func (a *Avatar) String() string

func (*Avatar) UnmarshalJSON

func (a *Avatar) UnmarshalJSON(data []byte) error

type CachedUser

type CachedUser struct {
	Username   string  `json:"username"`
	GlobalName *string `json:"global_name"`
	Avatar     string  `json:"avatar"`
	Bot        bool    `json:"bot"`
}

func (*CachedUser) ToUser

func (u *CachedUser) ToUser(userId uint64) User

type ClientStatus

type ClientStatus struct {
	Desktop ClientStatusType `json:"desktop"`
	Mobile  ClientStatusType `json:"mobile"`
	Web     ClientStatusType `json:"web"`
}

type ClientStatusType

type ClientStatusType string
const (
	ClientStatusTypeOnline       ClientStatusType = "online"
	ClientStatusTypeIdle         ClientStatusType = "idle"
	ClientStatusTypeDoNotDisturb ClientStatusType = "dnd"
	ClientStatusTypeInvisible    ClientStatusType = "invisible"
	ClientStatusTypeOffline      ClientStatusType = "offline"
)

type Discriminator

type Discriminator uint16

Jsoniter does not like leading zeroes on ints

func (Discriminator) MarshalJSON

func (d Discriminator) MarshalJSON() ([]byte, error)

func (*Discriminator) UnmarshalJSON

func (d *Discriminator) UnmarshalJSON(b []byte) error

type Party

type Party struct {
	Id   string `json:"id,omitempty"`
	Size []int  `json:"size,omitempty"`
}

func (*Party) GetCurrentSize

func (p *Party) GetCurrentSize() int

func (*Party) GetMaxSize

func (p *Party) GetMaxSize() int

type Presence

type Presence struct {
	User         User                    `json:"user"`
	Roles        utils.Uint64StringSlice `json:"roles"`
	Game         Activity                `json:"name"`
	GuildId      uint64                  `json:"guild_id,string"`
	Status       string                  `json:"status"`
	Activities   []Activity              `json:"activities"`
	ClientStatus ClientStatus            `json:"client_status"`
	PremiumSince *time.Time              `json:"premium_since"`
	Nick         string                  `json:"nick"`
}

type Secret

type Secret struct {
	Join     string `json:"join,omitempty"`
	Spectate string `json:"spectate,omitempty"`
	Match    string `json:"match,omitempty"`
}

type Timestamps

type Timestamps struct {
	Start uint64 `json:"start,omitempty"`
	End   uint64 `json:"end,omitempty"`
}

uses millis since unix epoch

type UpdateStatus

type UpdateStatus struct {
	Since  int              `json:"since"` // time since client went idle (unix epoch millis)
	Game   Activity         `json:"game,omitempty"`
	Status ClientStatusType `json:"status"`
	Afk    bool             `json:"afk"`
}

func BuildStatus

func BuildStatus(activityType ActivityType, status string) UpdateStatus

type User

type User struct {
	Id         uint64  `json:"id,string"`
	Username   string  `json:"username"`
	GlobalName *string `json:"global_name"`
	Avatar     Avatar  `json:"avatar"`
	Bot        bool    `json:"bot"`
}

func (*User) AvatarUrl

func (u *User) AvatarUrl(size int) string

shortcut, ignores errors

func (*User) EffectiveName

func (u *User) EffectiveName() string

func (*User) Mention

func (u *User) Mention() string

func (*User) ToCachedUser

func (u *User) ToCachedUser() CachedUser

Jump to

Keyboard shortcuts

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