Documentation
¶
Index ¶
- Constants
- Variables
- type AutoproxyMode
- type Birthday
- type Color
- type CreateGroupData
- type CreateMemberData
- type EditGroupData
- type EditMemberData
- type EditMemberGuildData
- type EditSystemData
- type EditSystemGuildData
- type Front
- type Group
- type GroupPrivacy
- type InvalidError
- type Member
- type MemberGuild
- type MemberPrivacy
- type Message
- type ModelError
- type NullableBool
- type NullableInt
- type NullableString
- type PKAPIError
- type Privacy
- type ProxyTag
- type RequestOption
- type Session
- func (s *Session) Account(id Snowflake) (sys System, err error)
- func (s *Session) AddGroupMembers(groupID string, memberIDs []string) (err error)
- func (s *Session) AddMemberGroups(memberID string, groupIDs []string) (err error)
- func (s *Session) CreateGroup(data CreateGroupData) (g Group, err error)
- func (s *Session) CreateMember(data CreateMemberData) (m Member, err error)
- func (s *Session) DeleteGroup(id string) (err error)
- func (s *Session) DeleteMember(id string) (err error)
- func (s *Session) DeleteSwitch(id uuid.UUID) (err error)
- func (s *Session) EditGroup(id string, dat EditGroupData) (g Group, err error)
- func (s *Session) EditMember(id string, emd EditMemberData) (Member, error)
- func (s *Session) EditMemberGuild(memberID string, guildID Snowflake, dat EditMemberGuildData) (mg MemberGuild, err error)
- func (s *Session) EditSystem(psd EditSystemData) (sys System, err error)
- func (s *Session) EditSystemGuild(guildID Snowflake, dat EditSystemGuildData) (sg SystemGuild, err error)
- func (s *Session) Fronters(id string) (f Front, err error)
- func (s *Session) Group(id string) (g Group, err error)
- func (s *Session) GroupByUUID(id uuid.UUID) (g Group, err error)
- func (s *Session) GroupMembers(groupID string) (m []Member, err error)
- func (s *Session) Groups(systemID string) (g []Group, err error)
- func (s *Session) GroupsWithMembers(systemID string) (g []Group, err error)
- func (s *Session) Me() (sys System, err error)
- func (s *Session) Member(id string) (m Member, err error)
- func (s *Session) MemberByUUID(id uuid.UUID) (Member, error)
- func (s *Session) MemberGroups(id string) (g []Group, err error)
- func (s *Session) MemberGuild(memberID string, guildID Snowflake) (mg MemberGuild, err error)
- func (s *Session) Members(id string) ([]Member, error)
- func (s *Session) Message(id Snowflake) (m Message, err error)
- func (s *Session) OverwriteGroupMembers(groupID string, memberIDs []string) (err error)
- func (s *Session) OverwriteMemberGroups(memberID string, groupIDs []string) (err error)
- func (s *Session) RegisterSwitch(ids ...string) (err error)
- func (s *Session) RegisterSwitchWithTimestamp(t time.Time, ids ...string) (err error)
- func (s *Session) RemoveGroupMembers(groupID string, memberIDs []string) (err error)
- func (s *Session) RemoveMemberGroups(memberID string, groupIDs []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) Switch(systemID string, switchID uuid.UUID) (f Front, err error)
- func (s *Session) Switches(id string) (switches []Switch, err error)
- func (s *Session) SwitchesBefore(id string, before time.Time, limit uint64) (switches []Switch, err error)
- func (s *Session) System(id string) (sys System, err error)
- func (s *Session) SystemByUUID(id uuid.UUID) (System, error)
- func (s *Session) SystemGuild(guildID Snowflake) (sg SystemGuild, err error)
- func (s *Session) SystemSettings() (settings SystemSettings, err error)
- func (s *Session) UpdateSwitchMembers(id uuid.UUID, members []string) (f Front, err error)
- func (s *Session) UpdateSwitchTimestamp(id uuid.UUID, t time.Time) (f Front, err error)
- func (s *Session) UpdateSystemSettings(data UpdateSystemSettingsData) (settings SystemSettings, err error)
- type Snowflake
- type Switch
- type System
- type SystemGuild
- type SystemPrivacy
- type SystemSettings
- type UpdateSystemSettingsData
Constants ¶
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") ErrInvalidProxyTag = errors.Sentinel("pkgo: invalid proxy tag") )
Errors
const ( SystemNotFound = 20001 MemberNotFound = 20002 MemberNotFoundWithRef = 20003 GroupNotFound = 20004 GroupNotFoundWithRef = 20005 MessageNotFound = 20006 SwitchNotFound = 20007 SwitchNotFoundPublic = 20008 SystemGuildNotFound = 20009 MemberGuildNotFound = 20010 NotOwnMember = 30006 NotOwnGroup = 30007 NotOwnMemberWithRef = 30008 NotOwnGroupWithRef = 30009 MissingAutoproxyMember = 40002 DuplicateMembersInList = 40003 SameSwitchMembers = 40004 SameSwitchTimestamp = 40005 InvalidSwitchID = 40006 MemberLimitReached = 40007 GroupLimitReached = 40008 Unimplemented = 50001 )
Error codes
Variables ¶
var ( // BaseURL is the API base url BaseURL = "https://api.pluralkit.me/v" // Version is the API version Version = "2" )
Functions ¶
This section is empty.
Types ¶
type AutoproxyMode ¶
type AutoproxyMode string
var ( AutoproxyModeOff AutoproxyMode = "off" AutoproxyModeFront AutoproxyMode = "front" AutoproxyModeLatch AutoproxyMode = "latch" AutoproxyModeMember AutoproxyMode = "member" )
Autoproxy modes
type Birthday ¶
Birthday is a member's birthday
func ParseBirthday ¶
ParseBirthday parses a birthday in yyyy-mm-dd or mm-dd format.
func (Birthday) MarshalJSON ¶
MarshalJSON ...
func (*Birthday) UnmarshalJSON ¶
UnmarshalJSON ...
type Color ¶
type Color string
Color holds the color for a member
type CreateGroupData ¶
type CreateGroupData struct {
Name string `json:"name"`
DisplayName string `json:"display_name,omitempty"`
Description string `json:"description,omitempty"`
Icon string `json:"icon,omitempty"`
Banner string `json:"banner,omitempty"`
Color Color `json:"color"`
Privacy *GroupPrivacy `json:"privacy,omitempty"`
}
CreateGroupData is the data for s.CreateGroup.
type CreateMemberData ¶
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"`
Privacy *MemberPrivacy `json:"privacy,omitempty"`
}
CreateMemberData is the data for s.CreateMember.
type EditGroupData ¶
type EditGroupData struct {
Name NullableString `json:"name,omitempty"`
DisplayName NullableString `json:"display_name,omitempty"`
Description NullableString `json:"description,omitempty"`
Icon NullableString `json:"icon,omitempty"`
Banner NullableString `json:"banner,omitempty"`
Color *Color `json:"color"`
Privacy *GroupPrivacy `json:"privacy,omitempty"`
}
EditGroupData is the data for s.EditGroup.
type EditMemberData ¶
type EditMemberData struct {
Name NullableString `json:"name,omitempty"`
DisplayName NullableString `json:"display_name,omitempty"`
Description NullableString `json:"description,omitempty"`
Pronouns NullableString `json:"pronouns,omitempty"`
Color *Color `json:"color,omitempty"`
Birthday *Birthday `json:"birthday,omitempty"`
AvatarURL NullableString `json:"avatar_url,omitempty"`
Banner NullableString `json:"banner,omitempty"`
ProxyTags []ProxyTag `json:"proxy_tags,omitempty"`
KeepProxy bool `json:"keep_proxy,omitempty"`
Privacy *MemberPrivacy `json:"privacy,omitempty"`
}
EditMemberData is the data for s.EditMember.
type EditMemberGuildData ¶
type EditMemberGuildData struct {
DisplayName NullableString `json:"display_name,omitempty"`
AvatarURL NullableString `json:"avatar_url,omitempty"`
}
EditMemberGuildData ...
type EditSystemData ¶
type EditSystemData struct {
Name NullableString `json:"name,omitempty"`
Description NullableString `json:"description,omitempty"`
Tag NullableString `json:"tag,omitempty"`
AvatarURL NullableString `json:"avatar_url,omitempty"`
Banner NullableString `json:"banner,omitempty"`
Color NullableString `json:"color,omitempty"`
Timezone NullableString `json:"tz,omitempty"`
Privacy *SystemPrivacy `json:"privacy,omitempty"`
}
EditSystemData ...
type EditSystemGuildData ¶
type EditSystemGuildData struct {
ProxyingEnabled NullableBool `json:"proxying_enabled"`
AutoproxyMode *AutoproxyMode `json:"autoproxy_mode"`
AutoproxyMember NullableString `json:"autoproxy_member,omitempty"`
Tag NullableString `json:"tag,omitempty"`
TagEnabled NullableBool `json:"tag_enabled"`
}
EditSystemGuildData ...
type Front ¶
type Front struct {
ID uuid.UUID `json:"id"`
Timestamp time.Time `json:"timestamp,omitempty"`
Members []Member `json:"members"`
}
Front holds the info for a full switch, as queried from /systems/{systemRef}/fronters
type Group ¶
type Group struct {
ID string `json:"id"`
UUID uuid.UUID `json:"uuid"`
Name string `json:"name"`
DisplayName string `json:"display_name,omitempty"`
Description string `json:"description,omitempty"`
Icon string `json:"icon,omitempty"`
Banner string `json:"banner,omitempty"`
Color Color `json:"color"`
Privacy *GroupPrivacy `json:"privacy,omitempty"`
// Only returned in GroupsWithMembers
Members []uuid.UUID `json:"members,omitempty"`
}
Group is a member group.
type GroupPrivacy ¶
type GroupPrivacy struct {
DescriptionPrivacy Privacy `json:"description_privacy,omitempty"`
IconPrivacy Privacy `json:"icon_privacy,omitempty"`
ListPrivacy Privacy `json:"list_privacy,omitempty"`
Visibility Privacy `json:"visibility,omitempty"`
}
GroupPrivacy is a group privacy object.
type InvalidError ¶
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 ¶
func (e *InvalidError) Error() string
type Member ¶
type Member struct {
ID string `json:"id"`
UUID uuid.UUID `json:"uuid"`
Name string `json:"name,omitempty"`
DisplayName string `json:"display_name,omitempty"`
Color Color `json:"color,omitempty"`
Birthday Birthday `json:"birthday,omitempty"`
Pronouns string `json:"pronouns,omitempty"`
AvatarURL string `json:"avatar_url,omitempty"`
Banner string `json:"banner,omitempty"`
Description string `json:"description,omitempty"`
Created time.Time `json:"created"`
ProxyTags []ProxyTag `json:"proxy_tags,omitempty"`
KeepProxy bool `json:"keep_proxy"`
Privacy *MemberPrivacy `json:"privacy,omitempty"`
}
Member holds information for a specific system member. Fields set to private are empty.
type MemberGuild ¶
type MemberGuild struct {
DisplayName string `json:"display_name,omitempty"`
AvatarURL string `json:"avatar_url,omitempty"`
}
MemberGuild is a member's guild-specific settings
type MemberPrivacy ¶
type MemberPrivacy struct {
Visibility Privacy `json:"visibility,omitempty"`
NamePrivacy Privacy `json:"name_privacy,omitempty"`
DescriptionPrivacy Privacy `json:"description_privacy,omitempty"`
BirthdayPrivacy Privacy `json:"birthday_privacy,omitempty"`
PronounPrivacy Privacy `json:"pronoun_privacy,omitempty"`
AvatarPrivacy Privacy `json:"avatar_privacy,omitempty"`
MetadataPrivacy Privacy `json:"metadata_privacy,omitempty"`
}
MemberPrivacy is a member privacy object.
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. System and Member may be null if the system/member the message is connected to is deleted.
type ModelError ¶
type ModelError struct {
Message string `json:"message"`
MaxLength int `json:"max_length"`
ActualLength int `json:"actual_length"`
}
ModelError ...
type NullableBool ¶
type NullableBool = *bool
NullableBool is a nullable bool for use in post/patch endpoints
func NewNullableBool ¶
func NewNullableBool(b bool) NullableBool
NewNullableBool creates a new nullable bool with the given value
type NullableInt ¶
type NullableInt = *int
NullableBool is a nullable int for use in post/patch endpoints
func NewNullableInt ¶
func NewNullableInt(i int) NullableInt
NewNullableInt creates a new nullable int with the given value
type NullableString ¶
type NullableString = *string
NullableString is a nullable string for use in post/patch endpoints
func NewNullableString ¶
func NewNullableString(s string) NullableString
NewNullableString creates a new nullable string with the given value
type PKAPIError ¶
type PKAPIError struct {
StatusCode int `json:"-"`
Code int `json:"code"`
RetryAfter *int `json:"retry_after,omitempty"`
Message string `json:"message"`
Errors map[string][]ModelError `json:"errors,omitempty"`
}
PKAPIError is an error returned by the PluralKit API
func (PKAPIError) Error ¶
func (e PKAPIError) Error() string
type Privacy ¶
type Privacy string
Privacy is a system or member privacy field. Note: an empty Privacy is marshaled as null.
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>
func (ProxyTag) MarshalJSON ¶
MarshalJSON marshals the ProxyTag to json
type RequestOption ¶
RequestOption is an optional request option.
func WithHeader ¶
func WithHeader(header http.Header) RequestOption
WithHeader adds headers to the request.
func WithJSONBody ¶
func WithJSONBody(v interface{}) RequestOption
WithJSONBody adds a JSON body to the request. Marshaling errors are ignored.
func WithURLValues ¶
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 NewWithLimiter ¶
NewWithLimiter returns a session with the given token and rate limiter.
func (*Session) AddGroupMembers ¶
AddGroupMembers adds the given member IDs to the given group.
func (*Session) AddMemberGroups ¶
AddMemberGroups adds a member to the given groups IDs.
func (*Session) CreateGroup ¶
func (s *Session) CreateGroup(data CreateGroupData) (g Group, err error)
CreateGroup creates a group.
func (*Session) CreateMember ¶
func (s *Session) CreateMember(data CreateMemberData) (m Member, err error)
CreateMember creates a member. Requires authentication.
func (*Session) DeleteGroup ¶
DeleteGroup deletes a group. Requires authentication.
func (*Session) DeleteMember ¶
DeleteMember deletes a member. Requires authentication.
func (*Session) DeleteSwitch ¶
DeleteSwitch deletes a switch. Requires authentication.
func (*Session) EditGroup ¶
func (s *Session) EditGroup(id string, dat EditGroupData) (g Group, err error)
EditGroup edits the given group.
func (*Session) EditMember ¶
func (s *Session) EditMember(id string, emd EditMemberData) (Member, error)
EditMember edits a member by ID. Requires authentication.
func (*Session) EditMemberGuild ¶
func (s *Session) EditMemberGuild(memberID string, guildID Snowflake, dat EditMemberGuildData) (mg MemberGuild, err error)
EditMemberGuild edits the member's guild settings.
func (*Session) EditSystem ¶
func (s *Session) EditSystem(psd EditSystemData) (sys System, err error)
EditSystem edits your system with the provided data.
func (*Session) EditSystemGuild ¶
func (s *Session) EditSystemGuild(guildID Snowflake, dat EditSystemGuildData) (sg SystemGuild, err error)
EditSystemGuild edits the current system's guild settings.
func (*Session) Fronters ¶
Fronters gets the current fronters for a system. If the system's fronters are set to private, requires authentication.
func (*Session) GroupByUUID ¶
GroupByUUID returns a group by its UUID.
func (*Session) GroupMembers ¶
GroupMembers gets the members list of the given group.
func (*Session) GroupsWithMembers ¶
GroupsWithMembers gets a system's groups, with the Members field filled.
func (*Session) MemberByUUID ¶
MemberByUUID gets a member by their UUID.
func (*Session) MemberGroups ¶
MemberGroups returns the groups the given member is in.
func (*Session) MemberGuild ¶
func (s *Session) MemberGuild(memberID string, guildID Snowflake) (mg MemberGuild, err error)
MemberGuild returns the member's guild settings.
func (*Session) Members ¶
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) OverwriteGroupMembers ¶
OverwriteGroupMembers overwrites a group's members with the given member IDs.
func (*Session) OverwriteMemberGroups ¶
OverwriteMemberGroups overwrites a member's groups with the given groups IDs.
func (*Session) RegisterSwitch ¶
RegisterSwitch registers a switch with the given member IDs. Requires authentication.
func (*Session) RegisterSwitchWithTimestamp ¶
RegisterSwitchWithTimestamp registers a switch with the given member IDs and the given timestamp. Requires authentication.
func (*Session) RemoveGroupMembers ¶
RemoveGroupMembers removes the given member IDs from the given group.
func (*Session) RemoveMemberGroups ¶
RemoveMemberGroups removes a member from the given groups IDs.
func (*Session) Request ¶
func (s *Session) Request(method, endpoint string, opts ...RequestOption) (response []byte, err error)
Request makes a request returning a JSON body.
func (*Session) RequestJSON ¶
func (s *Session) RequestJSON(method, endpoint string, v interface{}, opts ...RequestOption) error
RequestJSON makes a request returning a JSON body.
func (*Session) Switches ¶
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 ¶
func (s *Session) SwitchesBefore(id string, before time.Time, limit uint64) (switches []Switch, err error)
SwitchesBefore gets `limit` switches before the given timestamp. A zero limit will return *all* switches. For the latest switches, see Switches. If the system's font history is set to private, requires authentication.
func (*Session) System ¶
System gets a system by its 5-character system ID. Some fields may be empty if unauthenticated and the system has chosen to make those fields private.
func (*Session) SystemByUUID ¶
SystemByUUID gets a system by its UUID. See s.System for more documentation.
func (*Session) SystemGuild ¶
func (s *Session) SystemGuild(guildID Snowflake) (sg SystemGuild, err error)
SystemGuild returns the current system's guild settings.
func (*Session) SystemSettings ¶
func (s *Session) SystemSettings() (settings SystemSettings, err error)
SystemSettings returns the current token's system's settings.
func (*Session) UpdateSwitchMembers ¶
UpdateSwitchMembers updates the given switch's members.
func (*Session) UpdateSwitchTimestamp ¶
UpdateSwitchTimestamp updates the given switch's timestamp.
func (*Session) UpdateSystemSettings ¶
func (s *Session) UpdateSystemSettings(data UpdateSystemSettingsData) (settings SystemSettings, err error)
type Snowflake ¶
type Snowflake uint64
Snowflake is a Discord snowflake
func ParseSnowflake ¶
ParseSnowflake parses a snowflake from a string.
func (*Snowflake) UnmarshalJSON ¶
UnmarshalJSON ...
type Switch ¶
type Switch struct {
ID uuid.UUID `json:"id"`
Timestamp time.Time `json:"timestamp,omitempty"`
Members []string `json:"members"`
}
Switch holds the info for a simple switch, as queried from /systems/{systemRef}/switches
type System ¶
type System struct {
ID string `json:"id"`
UUID uuid.UUID `json:"uuid"`
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"`
Created time.Time `json:"created"`
Privacy *SystemPrivacy `json:"privacy,omitempty"`
}
System holds all the data for a system
type SystemGuild ¶
type SystemGuild struct {
ProxyingEnabled bool `json:"proxying_enabled"`
AutoproxyMode AutoproxyMode `json:"autoproxy_mode"`
AutoproxyMember string `json:"autoproxy_member,omitempty"`
Tag string `json:"tag,omitempty"`
TagEnabled bool `json:"tag_enabled"`
}
SystemGuild is a system's guild-specific settings
type SystemPrivacy ¶
type SystemPrivacy struct {
DescriptionPrivacy Privacy `json:"description_privacy,omitempty"`
MemberListPrivacy Privacy `json:"member_list_privacy,omitempty"`
GroupListPrivacy Privacy `json:"group_list_privacy,omitempty"`
FrontPrivacy Privacy `json:"front_privacy,omitempty"`
FrontHistoryPrivacy Privacy `json:"front_history_privacy,omitempty"`
}
SystemPrivacy is a system privacy object.
type SystemSettings ¶
type SystemSettings struct {
Timezone string `json:"timezone"`
PingsEnabled bool `json:"pings_enabled"`
LatchTimeout int `json:"latch_timeout"`
MemberDefaultPrivate bool `json:"member_default_private"`
GroupDefaultPrivate bool `json:"group_default_private"`
ShowPrivateInfo bool `json:"show_private_info"`
MemberLimit int `json:"member_limit"`
GroupLimit int `json:"group_limit"`
}
type UpdateSystemSettingsData ¶
type UpdateSystemSettingsData struct {
Timezone NullableString `json:"timezone"`
PingsEnabled NullableBool `json:"pings_enabled"`
LatchTimeout NullableInt `json:"latch_timeout"`
MemberDefaultPrivate NullableBool `json:"member_default_private"`
GroupDefaultPrivate NullableBool `json:"group_default_private"`
ShowPrivateInfo NullableBool `json:"show_private_info"`
}