Documentation ¶
Index ¶
- Constants
- Variables
- type Birthday
- type Color
- type CreateMemberData
- type EditMemberData
- type EditSystemData
- type Front
- type InvalidError
- type Member
- type Message
- type Privacy
- type ProxyTag
- type RequestOption
- type Session
- func (s *Session) Account(id Snowflake) (sys *System, err error)
- func (s *Session) CreateMember(data CreateMemberData) (m Member, err error)
- func (s *Session) DeleteMember(id string) (err error)
- func (s *Session) EditMember(id string, emd EditMemberData) (*Member, error)
- func (s *Session) EditSystem(psd EditSystemData) (sys *System, err error)
- func (s *Session) Fronters(id string) (f Front, err error)
- func (s *Session) Me(force bool) (sys *System, err error)
- func (s *Session) Member(id string) (m Member, err error)
- func (s *Session) Members(id string) ([]Member, error)
- func (s *Session) Message(id Snowflake) (m *Message, err error)
- func (s *Session) RegisterSwitch(ids ...string) (err error)
- func (s *Session) Request(method, endpoint string, opts ...RequestOption) (response []byte, err error)
- func (s *Session) RequestJSON(method, endpoint string, v interface{}, opts ...RequestOption) error
- func (s *Session) Switches(id string) (switches []Switch, err error)
- func (s *Session) SwitchesBefore(id string, before time.Time) (switches []Switch, err error)
- func (s *Session) System(id string) (sys *System, err error)
- type Snowflake
- type StatusError
- type Switch
- type System
Constants ¶
const ( ErrRateLimit = errors.Sentinel("pkgo: hit API rate limits") ErrBadRequest = errors.Sentinel("pkgo: 400 bad request") ErrNotFound = errors.Sentinel("pkgo: 404 not found") ErrAlreadyExists = errors.Sentinel("pkgo: 409 resource already exists") ErrUnprocessable = errors.Sentinel("pkgo: 422 unprocessable entity") )
Errors returned by Request
const ( ErrNoToken = errors.Sentinel("pkgo: no token in session, can't hit endpoints requiring authentication") ErrInvalidID = errors.Sentinel("pkgo: not a 5-character ID") ErrInvalidSnowflake = errors.Sentinel("pkgo: not a valid Discord snowflake") ErrMsgNotFound = errors.Sentinel("pkgo: message not found") ErrPrivacyInvalid = errors.Sentinel("pkgo: invalid privacy setting") )
Errors
Variables ¶
var ( // BaseURL is the API base url BaseURL = "https://api.pluralkit.me/v" // Version is the API version Version = "1" )
Functions ¶
This section is empty.
Types ¶
type Birthday ¶ added in v0.5.0
Birthday is a member's birthday
func ParseBirthday ¶ added in v0.5.0
ParseBirthday parses a birthday in yyyy-mm-dd or mm-dd format.
func (Birthday) MarshalJSON ¶ added in v0.5.0
MarshalJSON ...
func (*Birthday) UnmarshalJSON ¶ added in v0.5.0
UnmarshalJSON ...
type Color ¶
type Color string
Color holds the color for a member
type CreateMemberData ¶ added in v0.5.0
type CreateMemberData struct { Name string `json:"name,omitempty"` DisplayName string `json:"display_name,omitempty"` Description string `json:"description,omitempty"` Pronouns string `json:"pronouns,omitempty"` Color Color `json:"color,omitempty"` Birthday Birthday `json:"birthday,omitempty"` AvatarURL string `json:"avatar_url,omitempty"` Banner string `json:"banner,omitempty"` ProxyTags []ProxyTag `json:"proxy_tags,omitempty"` KeepProxy bool `json:"keep_proxy"` Visibility Privacy `json:"visibility,omitempty"` NamePrivacy Privacy `json:"name_privacy,omitempty"` DescriptionPrivacy Privacy `json:"description_privacy,omitempty"` AvatarPrivacy Privacy `json:"avatar_privacy,omitempty"` BirthdayPrivacy Privacy `json:"birthday_privacy,omitempty"` PronounPrivacy Privacy `json:"pronoun_privacy,omitempty"` MetadataPrivacy Privacy `json:"metadata_privacy,omitempty"` }
CreateMemberData is the data for s.CreateMember.
type EditMemberData ¶ added in v0.5.0
type EditMemberData struct { Name string `json:"name,omitempty"` DisplayName string `json:"display_name,omitempty"` Description string `json:"description,omitempty"` Pronouns string `json:"pronouns,omitempty"` Color Color `json:"color,omitempty"` Birthday Birthday `json:"birthday,omitempty"` AvatarURL string `json:"avatar_url,omitempty"` Banner string `json:"banner,omitempty"` ProxyTags []ProxyTag `json:"proxy_tags,omitempty"` KeepProxy bool `json:"keep_proxy,omitempty"` Visibility Privacy `json:"visibility,omitempty"` NamePrivacy Privacy `json:"name_privacy,omitempty"` DescriptionPrivacy Privacy `json:"description_privacy,omitempty"` AvatarPrivacy Privacy `json:"avatar_privacy,omitempty"` BirthdayPrivacy Privacy `json:"birthday_privacy,omitempty"` PronounPrivacy Privacy `json:"pronoun_privacy,omitempty"` MetadataPrivacy Privacy `json:"metadata_privacy,omitempty"` }
EditMemberData is the data for s.EditMember.
type EditSystemData ¶ added in v0.5.0
type EditSystemData struct { Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Tag string `json:"tag,omitempty"` AvatarURL string `json:"avatar_url,omitempty"` Banner string `json:"banner,omitempty"` Color string `json:"color,omitempty"` Timezone string `json:"tz,omitempty"` DescriptionPrivacy Privacy `json:"description_privacy,omitempty"` MemberListPrivacy Privacy `json:"member_list_privacy,omitempty"` FrontPrivacy Privacy `json:"front_privacy,omitempty"` FrontHistoryPrivacy Privacy `json:"front_history_privacy,omitempty"` }
EditSystemData ...
type Front ¶
type Front struct { Timestamp time.Time `json:"timestamp,omitempty"` Members []Member `json:"members"` }
Front holds the info for a full switch, as queried from /s/:id/fronters
type InvalidError ¶ added in v0.5.0
type InvalidError struct {
// contains filtered or unexported fields
}
InvalidError is returned when the data for a PATCH or POST endpoint is invalid.
func (*InvalidError) Error ¶ added in v0.5.0
func (e *InvalidError) Error() string
type Member ¶
type Member struct { ID string `json:"id"` Created time.Time `json:"created"` Name string `json:"name,omitempty"` DisplayName string `json:"display_name,omitempty"` Description string `json:"description,omitempty"` Pronouns string `json:"pronouns,omitempty"` Color Color `json:"color,omitempty"` Birthday Birthday `json:"birthday,omitempty"` AvatarURL string `json:"avatar_url,omitempty"` Banner string `json:"banner,omitempty"` ProxyTags []ProxyTag `json:"proxy_tags,omitempty"` KeepProxy bool `json:"keep_proxy"` Visibility Privacy `json:"visibility,omitempty"` NamePrivacy Privacy `json:"name_privacy,omitempty"` DescriptionPrivacy Privacy `json:"description_privacy,omitempty"` AvatarPrivacy Privacy `json:"avatar_privacy,omitempty"` BirthdayPrivacy Privacy `json:"birthday_privacy,omitempty"` PronounPrivacy Privacy `json:"pronoun_privacy,omitempty"` MetadataPrivacy Privacy `json:"metadata_privacy,omitempty"` }
Member holds information for a specific system member. Fields set to private are empty.
type Message ¶
type Message struct { Timestamp time.Time `json:"timestamp"` ID Snowflake `json:"id"` Original Snowflake `json:"original"` Sender Snowflake `json:"sender"` Channel Snowflake `json:"channel"` System System `json:"system"` Member Member `json:"member"` }
Message is a proxied message
type Privacy ¶
type Privacy string
Privacy is a system or member privacy field
func (Privacy) MarshalJSON ¶ added in v0.5.0
MarshalJSON ...
func (*Privacy) UnmarshalJSON ¶ added in v0.5.0
UnmarshalJSON ...
type ProxyTag ¶
type ProxyTag struct { Prefix string `json:"prefix,omitempty"` Suffix string `json:"suffix,omitempty"` }
ProxyTag is a single proxy tag for a member, in the format <prefix>text<suffix>
type RequestOption ¶ added in v1.1.1
RequestOption is an optional request option.
func WithBody ¶ added in v1.1.1
func WithBody(r io.Reader) RequestOption
WithBody adds a body to the request.
func WithHeader ¶ added in v1.1.1
func WithHeader(header http.Header) RequestOption
WithHeader adds headers to the request.
func WithJSONBody ¶ added in v1.1.1
func WithJSONBody(v interface{}) RequestOption
WithJSONBody adds a JSON body to the request. Marshaling errors are ignored.
func WithURLValues ¶ added in v1.1.1
func WithURLValues(values url.Values) RequestOption
WithURLValues adds query parameters to the request.
type Session ¶
type Session struct { // BaseURL is the API's base url. // This is set to the global variables BaseURL + Version when the session is initialized. BaseURL string Client *http.Client // Timeout is the maximum time this Session will wait for requests. Timeout time.Duration // RequestOptions are applied to every outgoing request. RequestOptions []RequestOption // contains filtered or unexported fields }
Session is the PluralKit API session, including a token
func New ¶ added in v0.5.0
New returns a session with the given token, or no token if the string is empty.
func NewWithLimiter ¶ added in v1.1.1
NewWithLimiter returns a session with the given token and rate limiter.
func (*Session) CreateMember ¶ added in v0.5.0
func (s *Session) CreateMember(data CreateMemberData) (m Member, err error)
CreateMember creates a member. Requires authentication.
func (*Session) DeleteMember ¶ added in v1.0.0
DeleteMember deletes a member. Requires authentication.
func (*Session) EditMember ¶ added in v0.5.0
func (s *Session) EditMember(id string, emd EditMemberData) (*Member, error)
EditMember edits a member by ID. Requires authentication.
func (*Session) EditSystem ¶ added in v0.5.0
func (s *Session) EditSystem(psd EditSystemData) (sys *System, err error)
EditSystem edits your system with the provided data.
func (*Session) Fronters ¶ added in v0.5.0
Fronters gets the current fronters for a system. If the system's fronters are set to private, requires authentication.
func (*Session) Me ¶ added in v0.5.0
Me gets the current token's system. If force is set to true, this will always fetch the system from the API.
func (*Session) Members ¶ added in v0.5.0
Members gets all members of a system. If the system's member list is set to private, requires authentication. If the request is not authenticated, only public members will be returned.
func (*Session) RegisterSwitch ¶
RegisterSwitch registers a switch with the given member IDs. Requires authentication.
func (*Session) Request ¶ added in v1.1.1
func (s *Session) Request(method, endpoint string, opts ...RequestOption) (response []byte, err error)
Request makes a request returning a JSON body.
func (*Session) RequestJSON ¶ added in v1.1.1
func (s *Session) RequestJSON(method, endpoint string, v interface{}, opts ...RequestOption) error
RequestJSON makes a request returning a JSON body.
func (*Session) Switches ¶ added in v0.5.0
Switches gets the latest 100 switches for a system. For earlier switches, see SwitchesBefore. If the system's font history is set to private, requires authentication.
func (*Session) SwitchesBefore ¶ added in v0.5.0
SwitchesBefore gets the 100 switches before the given timestamp. For the latest switches, see Switches. If the system's font history is set to private, requires authentication.
type Snowflake ¶ added in v0.4.0
type Snowflake uint64
Snowflake is a Discord snowflake
func ParseSnowflake ¶ added in v0.4.0
ParseSnowflake parses a snowflake from a string.
func (*Snowflake) UnmarshalJSON ¶ added in v0.4.0
UnmarshalJSON ...
type StatusError ¶ added in v0.5.0
StatusError is returned when a request returns a non-200 status code
func (*StatusError) Error ¶ added in v0.5.0
func (e *StatusError) Error() string
type Switch ¶
type Switch struct { Timestamp time.Time `json:"timestamp,omitempty"` Members []string `json:"members"` }
Switch holds the info for a simple switch, as queried from /s/:id/switches
type System ¶
type System struct { ID string `json:"id"` Created time.Time `json:"created"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Tag string `json:"tag,omitempty"` AvatarURL string `json:"avatar_url,omitempty"` Banner string `json:"banner,omitempty"` Color string `json:"color,omitempty"` Timezone string `json:"tz,omitempty"` DescriptionPrivacy Privacy `json:"description_privacy,omitempty"` MemberListPrivacy Privacy `json:"member_list_privacy,omitempty"` FrontPrivacy Privacy `json:"front_privacy,omitempty"` FrontHistoryPrivacy Privacy `json:"front_history_privacy,omitempty"` }
System holds all the data for a system