structures

package
v0.0.0-...-048a247 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 13 Imported by: 4

Documentation

Index

Constants

View Source
const (
	EmoteSetNameLengthLeast int = 48
	EmoteSetNameLengthMost  int = 3
)
View Source
const (
	EntitlementKindSubscription = EntitlementKind("SUBSCRIPTION") // Subscription Entitlement
	EntitlementKindBadge        = EntitlementKind("BADGE")        // Badge Entitlement
	EntitlementKindPaint        = EntitlementKind("PAINT")        // Badge Entitlement
	EntitlementKindRole         = EntitlementKind("ROLE")         // Role Entitlement
	EntitlementKindEmoteSet     = EntitlementKind("EMOTE_SET")    // Emote Set Entitlement
)

All permissions

Variables

View Source
var (
	RegExpEmoteName               = regexp.MustCompile(`^[-_A-Za-z(!?&)$+:0-9]{2,100}$`)
	RegExpEmoteVersionName        = regexp.MustCompile(`^[A-Za-z0-9\s]{2,40}$`)
	RegExpEmoteVersionDescription = regexp.MustCompile(`^[-_*=/\\"'\]\[}{@&~!?;:A-Za-z0-9\s]{3,240}$`)
)
View Source
var BanEffectMap = map[string]BanEffect{
	"NO_PERMISSIONS": BanEffectNoPermissions,
	"NO_AUTH":        BanEffectNoAuth,
	"NO_OWNERSHIP":   BanEffectNoOwnership,
	"MEMORY_HOLE":    BanEffectMemoryHole,
	"IP_BLOCKED":     BanEffectBlockedIP,
}
View Source
var DeletedEmote = Emote{
	ID:          primitive.NilObjectID,
	OwnerID:     DeletedUser.ID,
	Name:        "*UnknownEmote",
	Flags:       0,
	Tags:        []string{},
	State:       EmoteState{},
	Versions:    []EmoteVersion{},
	ChildrenIDs: []primitive.ObjectID{},
	Owner:       &DeletedUser,
}
View Source
var DeletedUser = User{
	ID:            primitive.NilObjectID,
	UserType:      UserTypeSystem,
	Username:      "*deleted_user",
	DisplayName:   "*DeletedUser",
	Discriminator: "0000",
	RoleIDs:       []primitive.ObjectID{},
	Editors:       []UserEditor{},
	TokenVersion:  0,
	Connections:   UserConnectionList{},
}
View Source
var NilRole = Role{
	ID:       primitive.NilObjectID,
	Name:     "NULL",
	Position: 0,
}
View Source
var RegExpEmoteSetName = regexp.MustCompile(`^[a-zA-Z0-9&'_-~# ]{1,40}$`)
View Source
var RevocationRole = Role{
	ID:       [12]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32},
	Name:     "NORIGHTS",
	Denied:   RolePermissionAll,
	Position: 0,
}
View Source
var SystemUser = User{
	ID:            [12]byte{96, 58, 221, 0, 209, 207, 107, 48, 44, 192, 226, 142},
	UserType:      UserTypeSystem,
	Username:      "*system",
	DisplayName:   "*System",
	Discriminator: "0001",
	RoleIDs:       []primitive.ObjectID{},
	Editors:       []UserEditor{},
	Connections:   UserConnectionList{},
}
View Source
var UsernameRegex = regexp.MustCompile("[^a-zA-Z0-9_]+")

Functions

This section is empty.

Types

type ActiveEmote

type ActiveEmote struct {
	ID              primitive.ObjectID        `json:"id" bson:"id"`
	Name            string                    `json:"name" bson:"name"`
	Flags           BitField[ActiveEmoteFlag] `json:"flags" bson:"flags"`
	Timestamp       time.Time                 `json:"timestamp" bson:"timestamp"`
	TimestampUpdate *time.Time                `json:"timestamp_update,omitempty" bson:"timestamp_update,omitempty"`
	MergedFromID    primitive.ObjectID        `json:"merged_from_id,omitempty" bson:"merged_from_id,omitempty"`
	MergedAt        time.Time                 `json:"merged_at,omitempty" bson:"merged_at,omitempty"`
	ActorID         primitive.ObjectID        `json:"actor_id,omitempty" bson:"actor_id,omitempty"`

	Origin EmoteSetOrigin `json:"-" bson:"-"`
	Emote  *Emote         `json:"emote" bson:"emote,omitempty,skip"`
	Actor  *User          `json:"actor" bson:"actor,omitempty,skip"`
}

type ActiveEmoteFlag

type ActiveEmoteFlag int32
const (
	ActiveEmoteFlagZeroWidth                ActiveEmoteFlag = 1 << 0  // 1 - Emote is zero-width
	ActiveEmoteFlagPending                  ActiveEmoteFlag = 1 << 8  // 256 - Emote is pending review
	ActiveEmoteFlagOverrideTwitchGlobal     ActiveEmoteFlag = 1 << 16 // 65536 - Overrides Twitch Global emotes with the same name
	ActiveEmoteFlagOverrideTwitchSubscriber ActiveEmoteFlag = 1 << 17 // 131072 - Overrides Twitch Subscriber emotes with the same name
	ActiveEmoteFlagOverrideBetterTTV        ActiveEmoteFlag = 1 << 18 // 262144 - Overrides BetterTTV emotes with the same name
	ActiveEmoteFlagOverrideFrankerFaceZ     ActiveEmoteFlag = 1 << 19 // 524288 - Overrides FrankerFaceZ emotes with the same name
)

type AuditLog

type AuditLog struct {
	ID      primitive.ObjectID `json:"id" bson:"_id,omitempty"`
	Kind    AuditLogKind       `json:"kind" bson:"kind"`
	ActorID primitive.ObjectID `json:"actor_id" bson:"actor_id"`

	TargetID   primitive.ObjectID `json:"target_id" bson:"target_id"`
	TargetKind ObjectKind         `json:"target_kind" bson:"target_kind"`
	Changes    []*AuditLogChange  `json:"changes" bson:"changes"`

	Extra  map[string]any `json:"extra,omitempty" bson:"extra,omitempty"`
	Reason string         `json:"reason,omitempty" bson:"reason,omitempty"`
}

type AuditLogBuilder

type AuditLogBuilder struct {
	Update   UpdateMap
	AuditLog AuditLog
}

func NewAuditLogBuilder

func NewAuditLogBuilder(log AuditLog) *AuditLogBuilder

NewAuditLogBuilder creates a new Builder utility for an Audit Log

func (*AuditLogBuilder) AddChanges

func (alb *AuditLogBuilder) AddChanges(changes ...*AuditLogChange) *AuditLogBuilder

AddChanges adds one or more changes in the audit log

func (*AuditLogBuilder) SetActor

SetActor defines the ID of the responsible ('actor') user in the audit log

func (*AuditLogBuilder) SetExtra

func (alb *AuditLogBuilder) SetExtra(key string, value interface{}) *AuditLogBuilder

SetExtra defines arbitrary extraneous data that may be helpful in some cases where changes cannot be explained with just old and new values

func (*AuditLogBuilder) SetKind

func (alb *AuditLogBuilder) SetKind(kind AuditLogKind) *AuditLogBuilder

SetKind sets the kind of the audit log

func (*AuditLogBuilder) SetTargetID

func (alb *AuditLogBuilder) SetTargetID(id primitive.ObjectID) *AuditLogBuilder

SetTargetID sets the id of the resource targeted in the audit log

func (*AuditLogBuilder) SetTargetKind

func (alb *AuditLogBuilder) SetTargetKind(kind ObjectKind) *AuditLogBuilder

SetTargetKind sets the object kind of the resource targeted in the audit log

type AuditLogChange

type AuditLogChange struct {
	Format AuditLogChangeFormat `json:"format" bson:"format"`
	Key    string               `json:"key" bson:"key"`
	Value  bson.Raw             `json:"value" bson:"value"`
}

func NewAuditChange

func NewAuditChange(key string) *AuditLogChange

func (*AuditLogChange) WriteArrayAdded

func (alc *AuditLogChange) WriteArrayAdded(values ...any) *AuditLogChange

func (*AuditLogChange) WriteArrayRemoved

func (alc *AuditLogChange) WriteArrayRemoved(values ...any) *AuditLogChange

func (*AuditLogChange) WriteArrayUpdated

func (alc *AuditLogChange) WriteArrayUpdated(values ...AuditLogChangeSingleValue) *AuditLogChange

func (*AuditLogChange) WriteSingleValues

func (alc *AuditLogChange) WriteSingleValues(old any, new any) *AuditLogChange

type AuditLogChangeArrayChange

type AuditLogChangeArrayChange struct {
	Added   []any                       `json:"added,omitempty" bson:"added,omitempty"`
	Removed []any                       `json:"removed,omitempty" bson:"removed,omitempty"`
	Updated []AuditLogChangeSingleValue `json:"updated,omitempty" bson:"updated,omitempty"`
}

type AuditLogChangeFormat

type AuditLogChangeFormat int8
const (
	AuditLogChangeFormatSingleValue AuditLogChangeFormat = 1
	AuditLogChangeFormatArrayChange AuditLogChangeFormat = 2
)

type AuditLogChangeSingleValue

type AuditLogChangeSingleValue struct {
	New      any   `json:"n" bson:"n"`
	Old      any   `json:"o" bson:"o"`
	Position int32 `json:"p" bson:"p"`
}

type AuditLogKind

type AuditLogKind uint8
const (
	AuditLogKindCreateEmote     AuditLogKind = 1 // emote was created
	AuditLogKindDeleteEmote     AuditLogKind = 2 // emote was deleted
	AuditLogKindDisableEmote    AuditLogKind = 3 // emote was disabled
	AuditLogKindUpdateEmote     AuditLogKind = 4 // emote was updated
	AuditLogKindMergeEmote      AuditLogKind = 5 // emote was merged
	AuditLogKindUndoDeleteEmote AuditLogKind = 6 // deleted emote was restored
	AuditLogKindEnableEmote     AuditLogKind = 7 // emote was enabled
	AuditLogKindProcessEmote    AuditLogKind = 8 // a new processing job was ran for this emote

	AuditLogKindSignUserToken  AuditLogKind = 20 // a user token was signed
	AuditLogKindSignCSRFToken  AuditLogKind = 21 // a CSRF token was signed
	AuditLogKindRejectedAccess AuditLogKind = 26 // an attempt to access a privileged area was rejected

	AuditLogKindCreateUser AuditLogKind = 30 // user was created
	AuditLogKindDeleteUser AuditLogKind = 31 // user was deleted
	AuditLogKindBanUser    AuditLogKind = 32 // user was banned
	AuditLogKindEditUser   AuditLogKind = 33 // user was edited
	AuditLogKindUnbanUser  AuditLogKind = 36 // user was unbanned

	AuditLogKindCreateEmoteSet AuditLogKind = 70 // emote set was created
	AuditLogKindUpdateEmoteSet AuditLogKind = 71 // emote set was updated
	AuditLogKindDeleteEmoteSet AuditLogKind = 72 // emote set was deleted

	// Range: 80-89 (Report)
	AuditLogKindCreateReport AuditLogKind = 80
	AuditLogKindUpdateReport AuditLogKind = 81

	// Range: 90-110 (Messaging)
	AuditLogKindReadMessage AuditLogKind = 90
)

type Ban

type Ban struct {
	ID primitive.ObjectID `json:"id" bson:"_id,omitempty"`

	// The user who is affected by this ban
	VictimID primitive.ObjectID `json:"victim_id" bson:"victim_id"`
	// The user who created this ban
	ActorID primitive.ObjectID `json:"actor_id" bson:"actor_id"`
	// The reason for the ban
	Reason string `json:"reason" bson:"reason"`
	// The time at which the ban will expire
	ExpireAt time.Time `json:"expire_at" bson:"expire_at"`
	// The effects that this ban will have
	Effects BanEffect `json:"effects" bson:"effects"`

	Victim *User `json:"victim" bson:"victim,skip,omitempty"`
	Actor  *User `json:"actor" bson:"actor,skip,omitempty"`
}

type BanBuilder

type BanBuilder struct {
	Ban    Ban
	Update UpdateMap
	// contains filtered or unexported fields
}

func NewBanBuilder

func NewBanBuilder(ban Ban) *BanBuilder

NewRoleBuilder: create a new role builder

func (BanBuilder) Initial

func (bb BanBuilder) Initial() Ban

Initial returns a pointer to the value first passed to this Builder

func (BanBuilder) IsTainted

func (bb BanBuilder) IsTainted() bool

IsTainted returns whether or not this Builder has been mutated before

func (*BanBuilder) MarkAsTainted

func (ub *BanBuilder) MarkAsTainted()

MarkAsTainted taints the builder, preventing it from being mutated again

func (*BanBuilder) SetActorID

func (bb *BanBuilder) SetActorID(id primitive.ObjectID) *BanBuilder

func (*BanBuilder) SetEffects

func (bb *BanBuilder) SetEffects(a BanEffect) *BanBuilder

func (*BanBuilder) SetExpireAt

func (bb *BanBuilder) SetExpireAt(t time.Time) *BanBuilder

func (*BanBuilder) SetReason

func (bb *BanBuilder) SetReason(s string) *BanBuilder

func (*BanBuilder) SetVictimID

func (bb *BanBuilder) SetVictimID(id primitive.ObjectID) *BanBuilder

type BanEffect

type BanEffect uint32
const (
	// Strip the banned user of all permissions
	BanEffectNoPermissions BanEffect = 1 << 0
	// Prevents the banned user from authenticating
	BanEffectNoAuth BanEffect = 1 << 1
	// Any object owned by the banned user will no longer be returned by the API
	BanEffectNoOwnership BanEffect = 1 << 2
	// The banned user is never returned by the API to non-privileged users
	BanEffectMemoryHole BanEffect = 1 << 3
	// The banned user's IP will be blocked from accessing all services
	BanEffectBlockedIP BanEffect = 1 << 4
)

func (*BanEffect) Add

func (bef *BanEffect) Add(eff BanEffect)

func (BanEffect) Has

func (bef BanEffect) Has(eff BanEffect) bool

func (*BanEffect) Remove

func (bef *BanEffect) Remove(eff BanEffect)

func (BanEffect) String

func (bef BanEffect) String() string

type BitField

type BitField[T ~int64 | ~int32] int64

func (BitField[T]) Has

func (b BitField[T]) Has(flag T) bool

func (BitField[T]) Set

func (b BitField[T]) Set(flag T) BitField[T]

func (BitField[T]) Unset

func (b BitField[T]) Unset(flag T) BitField[T]

func (BitField[T]) Value

func (b BitField[T]) Value() T

type Cosmetic

type Cosmetic[D CosmeticData] struct {
	ID       primitive.ObjectID   `json:"id" bson:"_id"`
	Kind     CosmeticKind         `json:"kind" bson:"kind"`
	Priority int                  `json:"priority" bson:"priority"`
	Name     string               `json:"name" bson:"name"`
	UserIDs  []primitive.ObjectID `json:"users" bson:"user_ids"`
	Users    []User               `json:"user_objects" bson:"user_objects,skip,omitempty"`
	Data     D                    `json:"data" bson:"data"`

	// User Relationals
	Selected bool `json:"selected" bson:"selected,skip,omitempty"`
}

func ConvertCosmetic

func ConvertCosmetic[D CosmeticData](c Cosmetic[bson.Raw]) (Cosmetic[D], error)

func (Cosmetic[D]) ToRaw

func (c Cosmetic[D]) ToRaw() Cosmetic[bson.Raw]

type CosmeticData

type CosmeticData interface {
	bson.Raw | CosmeticDataBadge | CosmeticDataPaint
}

type CosmeticDataBadge

type CosmeticDataBadge struct {
	ID      primitive.ObjectID `json:"id" bson:"-"`
	Tag     string             `json:"tag" bson:"tag"`
	Tooltip string             `json:"tooltip" bson:"tooltip"`
	Misc    bool               `json:"misc,omitempty" bson:"misc"`
}

type CosmeticDataPaint

type CosmeticDataPaint struct {
	ID primitive.ObjectID `json:"id" bson:"-"`
	// The default color of the paint
	Color *utils.Color `json:"color" bson:"color"`
	// A list of gradients. There may be any amount, which can be stacked onto each other
	Gradients []CosmeticPaintGradient `json:"gradients" bson:"gradients"`
	// A list of drop shadows. There may be any amount, which can be stacked onto each other
	DropShadows []CosmeticPaintDropShadow `json:"drop_shadows,omitempty" bson:"drop_shadows,omitempty"`
	// A list of flairs
	Flairs []CosmeticPaintFlair `json:"flairs,omitempty" bson:"flairs,omitempty"`
	// Text properties
	Text *CosmeticPaintText `json:"text,omitempty" bson:"text,omitempty"`
	// Text stroke
	// The function used to generate the paint (i.e gradients or an image)
	Function CosmeticPaintGradientFunction `json:"function" bson:"function"`
	// Gradient stops, a list of positions and colors
	Stops []CosmeticPaintGradientStop `json:"stops" bson:"stops"`
	// Whether or not the gradient repeats outside its original area
	Repeat bool `json:"repeat" bson:"repeat"`
	// Gradient angle in degrees
	Angle int32 `json:"angle" bson:"angle"`
	// Shape of a radial gradient, when the paint is of RADIAL_GRADIENT type
	Shape string `json:"shape,omitempty" bson:"shape,omitempty"`
	// URL of an image, when the paint is of BACKGROUND_IMAGE type
	ImageURL string `json:"image_url,omitempty" bson:"image_url,omitempty"`
}

type CosmeticKind

type CosmeticKind string
const (
	CosmeticKindBadge        CosmeticKind = "BADGE"
	CosmeticKindNametagPaint CosmeticKind = "PAINT"
	CosmeticKindAvatar       CosmeticKind = "AVATAR"
)

type CosmeticPaintDropShadow

type CosmeticPaintDropShadow struct {
	OffsetX float64     `json:"x_offset" bson:"x_offset"`
	OffsetY float64     `json:"y_offset" bson:"y_offset"`
	Radius  float64     `json:"radius" bson:"radius"`
	Color   utils.Color `json:"color" bson:"color"`
}

type CosmeticPaintFlair

type CosmeticPaintFlair struct {
	// The kind of sprite
	Kind CosmeticPaintFlairKind `json:"kind" bson:"kind"`
	// The X offset of the flair (%)
	OffsetX float64 `json:"x_offset" bson:"x_offset"`
	// The Y offset of the flair (%)
	OffsetY float64 `json:"y_offset" bson:"y_offset"`
	// The width of the flair
	Width float64 `json:"width" bson:"width"`
	// The height of the flair
	Height float64 `json:"height" bson:"height"`
	// Base64-encoded image or vector data
	Data string `json:"data" bson:"data"`
}

type CosmeticPaintFlairKind

type CosmeticPaintFlairKind string
const (
	CosmeticPaintSpriteKindImage  CosmeticPaintFlairKind = "IMAGE"
	CosmeticPaintSpriteKindVector CosmeticPaintFlairKind = "VECTOR"
	CosmeticPaintSpriteKindText   CosmeticPaintFlairKind = "TEXT"
)

type CosmeticPaintGradient

type CosmeticPaintGradient struct {
	// The function used to generate the paint (i.e gradients or an image)
	Function CosmeticPaintGradientFunction `json:"function" bson:"function"`
	// The repeat mode of the gradient canvas
	CanvasRepeat CosmeticPaintGradientRepeat `json:"canvas_repeat" bson:"canvas_repeat"`
	// The canvas size for the paint
	Size [2]float64 `json:"size" bson:"size"`
	// Gradient position (X/Y % values)
	At [2]float64 `json:"at,omitempty" bson:"at,omitempty"`
	// Gradient stops, a list of positions and colors
	Stops []CosmeticPaintGradientStop `json:"stops" bson:"stops"`
	// For a URL-based paint, the URL to an image
	ImageURL string `json:"image_url,omitempty" bson:"image_url,omitempty"`
	// For a radial gradient, the shape of the gradient
	Shape string `json:"shape,omitempty" bson:"shape,omitempty"`
	// The degree angle of the gradient (does not apply if function is URL)
	Angle int32 `json:"angle,omitempty" bson:"angle,omitempty"`
	// Whether or not the gradient stops repeat after they end
	Repeat bool `json:"repeat" bson:"repeat"`
}

type CosmeticPaintGradientFunction

type CosmeticPaintGradientFunction string
const (
	CosmeticPaintFunctionLinearGradient CosmeticPaintGradientFunction = "LINEAR_GRADIENT"
	CosmeticPaintFunctionRadialGradient CosmeticPaintGradientFunction = "RADIAL_GRADIENT"
	CosmeticPaintFunctionImageURL       CosmeticPaintGradientFunction = "URL"
)

type CosmeticPaintGradientRepeat

type CosmeticPaintGradientRepeat string
const (
	CosmeticPaintCanvasRepeatNone   CosmeticPaintGradientRepeat = "no-repeat"
	CosmeticPaintCanvasRepeatX      CosmeticPaintGradientRepeat = "repeat-x"
	CosmeticPaintCanvasRepeatY      CosmeticPaintGradientRepeat = "repeat-y"
	CosmeticPaintCanvasRepeatRevert CosmeticPaintGradientRepeat = "revert"
	CosmeticPaintCanvasRepeatRound  CosmeticPaintGradientRepeat = "round"
	CosmeticPaintCanvasRepeatSpace  CosmeticPaintGradientRepeat = "space"
)

type CosmeticPaintGradientStop

type CosmeticPaintGradientStop struct {
	At    float64     `json:"at" bson:"at"`
	Color utils.Color `json:"color" bson:"color"`
	// the center position for the gradient. X/Y % values (for radial gradients only)
	CenterAt [2]float64 `json:"center_at,omitempty" bson:"center_at,omitempty"`
}

type CosmeticPaintStroke

type CosmeticPaintStroke struct {
	// Stroke color
	Color utils.Color `json:"color" bson:"color"`
	// Stroke width
	Width float64 `json:"width" bson:"width"`
}

type CosmeticPaintText

type CosmeticPaintText struct {
	// Weight multiplier for the text. Defaults to 9x is not specified
	Weight uint8 `json:"weight,omitempty" bson:"weight,omitempty"`
	// Shadows applied to the text
	Shadows []CosmeticPaintDropShadow `json:"shadows,omitempty" bson:"shadows,omitempty"`
	// Text tranformation
	Transform CosmeticPaintTextTransform `json:"transform,omitempty" bson:"transform,omitempty"`
	// Text stroke
	Stroke *CosmeticPaintStroke `json:"stroke,omitempty" bson:"stroke,omitempty"`
	// (css) font variant property. non-standard
	Variant string `json:"variant" bson:"variant"`
}

type CosmeticPaintTextTransform

type CosmeticPaintTextTransform string
const (
	CosmeticPaintTextTransformUppercase CosmeticPaintTextTransform = "uppercase"
	CosmeticPaintTextTransformLowercase CosmeticPaintTextTransform = "lowercase"
)

type Emote

type Emote struct {
	ID      ObjectID            `json:"id" bson:"_id"`
	OwnerID ObjectID            `json:"owner_id" bson:"owner_id"`
	Name    string              `json:"name" bson:"name"`
	Flags   BitField[EmoteFlag] `json:"flags" bson:"flags"`
	Tags    []string            `json:"tags" bson:"tags"`
	State   EmoteState          `json:"state" bson:"state"`

	Versions    []EmoteVersion       `json:"versions" bson:"versions"`
	ChildrenIDs []primitive.ObjectID `json:"children_ids" bson:"children_ids"`
	ParentID    *primitive.ObjectID  `json:"parent_id" bson:"parent_id"`

	Owner      *User         `json:"owner" bson:"owner_user,skip,omitempty"`
	Channels   []User        `json:"channels" bson:"channels,skip,omitempty"`
	VersionRef *EmoteVersion `json:"version_ref" bson:"version_ref,skip,omitempty"`
}

func (Emote) GetLatestVersion

func (e Emote) GetLatestVersion(onlyListed bool) EmoteVersion

func (Emote) GetVersion

func (e Emote) GetVersion(id ObjectID) (EmoteVersion, int)

func (*Emote) Validator

func (e *Emote) Validator() EmoteValidator

func (Emote) WebURL

func (e Emote) WebURL(origin string) string

type EmoteBuilder

type EmoteBuilder struct {
	Update UpdateMap
	Emote  Emote
	// contains filtered or unexported fields
}

EmoteBuilder Wraps an Emote and offers methods to fetch and mutate emote data

func NewEmoteBuilder

func NewEmoteBuilder(emote Emote) *EmoteBuilder

NewEmoteBuilder: create a new emote builder

func (*EmoteBuilder) AddVersion

func (eb *EmoteBuilder) AddVersion(v EmoteVersion) *EmoteBuilder

func (*EmoteBuilder) Initial

func (eb *EmoteBuilder) Initial() Emote

Initial returns a pointer to the value first passed to this Builder

func (*EmoteBuilder) InitialVersions

func (eb *EmoteBuilder) InitialVersions() []EmoteVersion

func (*EmoteBuilder) IsTainted

func (eb *EmoteBuilder) IsTainted() bool

IsTainted returns whether or not this Builder has been mutated before

func (*EmoteBuilder) MarkAsTainted

func (eb *EmoteBuilder) MarkAsTainted()

MarkAsTainted taints the builder, preventing it from being mutated again

func (*EmoteBuilder) RemoveVersion

func (eb *EmoteBuilder) RemoveVersion(id ObjectID) *EmoteBuilder

func (*EmoteBuilder) SetFlags

func (eb *EmoteBuilder) SetFlags(sum BitField[EmoteFlag]) *EmoteBuilder

func (*EmoteBuilder) SetName

func (eb *EmoteBuilder) SetName(name string) *EmoteBuilder

SetName: change the name of the emote

func (*EmoteBuilder) SetOwnerID

func (eb *EmoteBuilder) SetOwnerID(id primitive.ObjectID) *EmoteBuilder

func (*EmoteBuilder) SetTags

func (eb *EmoteBuilder) SetTags(tags []string, validate bool) *EmoteBuilder

func (*EmoteBuilder) UpdateVersion

func (eb *EmoteBuilder) UpdateVersion(id ObjectID, v EmoteVersion) *EmoteBuilder

type EmoteFlag

type EmoteFlag int32
const (
	EmoteFlagsPrivate   EmoteFlag = 1 << 0 // The emote is private and can only be accessed by its owner, editors and moderators
	EmoteFlagsAuthentic EmoteFlag = 1 << 1 // The emote was verified to be an original creation by the uploader
	EmoteFlagsZeroWidth EmoteFlag = 1 << 8 // The emote is recommended to be enabled as Zero-Width

	EmoteFlagsContentSexual           EmoteFlag = 1 << 16 // Sexually Suggesive
	EmoteFlagsContentEpilepsy         EmoteFlag = 1 << 17 // Rapid flashing
	EmoteFlagsContentEdgy             EmoteFlag = 1 << 18 // Edgy or distasteful, may be offensive to some users
	EmoteFlagsContentTwitchDisallowed EmoteFlag = 1 << 24 // Not allowed specifically on the Twitch platform
)

func (EmoteFlag) String

func (e EmoteFlag) String() string

type EmoteLifecycle

type EmoteLifecycle int32
const (
	EmoteLifecycleDeleted EmoteLifecycle = iota - 1
	EmoteLifecyclePending
	EmoteLifecycleProcessing
	EmoteLifecycleDisabled
	EmoteLifecycleLive
	EmoteLifecycleFailed EmoteLifecycle = -2
)

type EmoteSet

type EmoteSet struct {
	ID primitive.ObjectID `json:"-" bson:"_id,omitempty"`
	// The emote set's name
	Name string `json:"name" bson:"name"`
	// Search tags for the emote set
	Tags []string `json:"tags" bson:"tags"`
	// Bit flags for the emote set
	Flags BitField[EmoteSetFlag] `json:"flags" bson:"flags"`
	// Whether or not the emote set can be edited
	//
	// DEPRECATED - use Flags instead
	Immutable bool `json:"immutable" bson:"immutable"`
	// If true, the set is "privileged" and can only be modified by its owner or a super administrator, regardless of the "Edit Any Emote Set" permission
	//
	// DEPRECATED - use Flags instead
	Privileged bool `json:"privilleged" bson:"privileged"`
	// The emotes assigned to this set
	Emotes []ActiveEmote `json:"emotes" bson:"emotes"`
	// The set's emote capacity (slots), the maximum amount of emotes it can hold
	Capacity int32 `json:"capacity" bson:"capacity"`
	// The set's emote capacity using the quota system
	// Experimental - replaces slot capacity
	QuotaCapacity float64 `json:"capacity_experimental,omitempty" bson:"capacity_experimental,omitempty"`
	// Other emote sets that this set is based upon
	Origins []EmoteSetOrigin `json:"origins,omitempty" bson:"origins,omitempty"`
	// The ID of the user who owns this emote set
	OwnerID ObjectID `json:"owner_id" bson:"owner_id"`

	// Conditions governing how this emote set may be utilized
	Condition EmoteSetCondition `json:"condition" bson:"condition"`

	Owner *User `json:"owner,omitempty" bson:"owner_user,skip,omitempty"`
}

func (EmoteSet) GetEmote

func (es EmoteSet) GetEmote(id primitive.ObjectID) (ActiveEmote, int)

HasEmote: returns whether or not the set has an emote active, as well as its index

func (*EmoteSet) Validator

func (e *EmoteSet) Validator() EmoteSetValidator

type EmoteSetBuilder

type EmoteSetBuilder struct {
	Update   UpdateMap
	EmoteSet EmoteSet
	// contains filtered or unexported fields
}

func NewEmoteSetBuilder

func NewEmoteSetBuilder(emoteSet EmoteSet) *EmoteSetBuilder

func (*EmoteSetBuilder) AddActiveEmote

func (esb *EmoteSetBuilder) AddActiveEmote(id ObjectID, alias string, at time.Time, actorID *primitive.ObjectID) *EmoteSetBuilder

func (*EmoteSetBuilder) AddOrigin

func (esb *EmoteSetBuilder) AddOrigin(id ObjectID, weight int32) *EmoteSetBuilder

func (*EmoteSetBuilder) Initial

func (esb *EmoteSetBuilder) Initial() *EmoteSet

Initial returns a pointer to the value first passed to this Builder

func (*EmoteSetBuilder) IsTainted

func (esb *EmoteSetBuilder) IsTainted() bool

IsTainted returns whether or not this Builder has been mutated before

func (*EmoteSetBuilder) MarkAsTainted

func (esb *EmoteSetBuilder) MarkAsTainted()

MarkAsTainted taints the builder, preventing it from being mutated again

func (*EmoteSetBuilder) RemoveActiveEmote

func (esb *EmoteSetBuilder) RemoveActiveEmote(id ObjectID) (*EmoteSetBuilder, int)

func (*EmoteSetBuilder) RemoveOrigin

func (esb *EmoteSetBuilder) RemoveOrigin(id ObjectID) *EmoteSetBuilder

func (*EmoteSetBuilder) SetCapacity

func (esb *EmoteSetBuilder) SetCapacity(slots int32) *EmoteSetBuilder

func (*EmoteSetBuilder) SetImmutable

func (esb *EmoteSetBuilder) SetImmutable(b bool) *EmoteSetBuilder

func (*EmoteSetBuilder) SetName

func (esb *EmoteSetBuilder) SetName(name string) *EmoteSetBuilder

func (*EmoteSetBuilder) SetOrigins

func (esb *EmoteSetBuilder) SetOrigins(origins []EmoteSetOrigin) *EmoteSetBuilder

func (*EmoteSetBuilder) SetOwnerID

func (esb *EmoteSetBuilder) SetOwnerID(id ObjectID) *EmoteSetBuilder

func (*EmoteSetBuilder) SetPrivileged

func (esb *EmoteSetBuilder) SetPrivileged(b bool) *EmoteSetBuilder

func (*EmoteSetBuilder) SetTags

func (esb *EmoteSetBuilder) SetTags(tags []string) *EmoteSetBuilder

func (*EmoteSetBuilder) UpdateActiveEmote

func (esb *EmoteSetBuilder) UpdateActiveEmote(id ObjectID, alias string) *EmoteSetBuilder

type EmoteSetCondition

type EmoteSetCondition struct {
	// If true, this emote set may be entitled on to a user and used globally
	Entitlable bool `json:"entitlable,omitempty" bson:"entitlable,omitempty"`
	// A list of channel IDs (user connections) where this set is allowed to be used. If empty it is unrestricted
	Channels []string `json:"channels,omitempty" bson:"channels,omitempty"`
}

type EmoteSetFlag

type EmoteSetFlag int32
const (
	// 1 - Set is immutable, meaning it cannot be modified
	EmoteSetFlagImmutable EmoteSetFlag = 1 << 0
	// 2 - Set is privileged, meaning it can only be modified by its owner
	// or a super administrator, regardless of the "Edit Any Emote Set" permission
	EmoteSetFlagPrivileged EmoteSetFlag = 1 << 1
	// 4 - Set can be personally entitled to a user, meaning its content can be used globally
	// but may require additional review by content moderators
	EmoteSetFlagPersonal EmoteSetFlag = 1 << 2
	// 8 - Set is distributed via a purchase, meaning its content must be approved
	// for commercial use by rightsholders
	EmoteSetFlagCommercial EmoteSetFlag = 1 << 3
)

type EmoteSetOrigin

type EmoteSetOrigin struct {
	// The ID of the referenced emote set
	ID primitive.ObjectID `json:"id" bson:"id"`
	// The weight of this set for serving emotes with names
	Weight int32 `json:"weight" bson:"weight"`
	// Slicing of active emotes inside the origin set
	Slices []uint32 `json:"slices" bson:"slices"`

	Set *EmoteSet
}

type EmoteSetValidator

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

func (EmoteSetValidator) Name

func (x EmoteSetValidator) Name() error

type EmoteState

type EmoteState struct {
	// IDs of users who are eligible to claim ownership of this emote
	Claimants []primitive.ObjectID `json:"claimants" bson:"claimants"`
}

type EmoteValidator

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

func (EmoteValidator) Name

func (x EmoteValidator) Name() error

type EmoteVersion

type EmoteVersion struct {
	ID          primitive.ObjectID `json:"id" bson:"id"`
	Name        string             `json:"name" bson:"name"`
	Description string             `json:"description" bson:"description"`
	Animated    bool               `json:"animated" bson:"animated"`
	State       EmoteVersionState  `json:"state" bson:"state"`

	InputFile   ImageFile   `json:"input_file" bson:"input_file"`
	ImageFiles  []ImageFile `json:"image_files" bson:"image_files"`
	ArchiveFile ImageFile   `json:"archive_file" bson:"archive_file"`

	CreatedAt   time.Time `json:"created_at" bson:"created_at"`
	StartedAt   time.Time `json:"started_at" bson:"started_at"`
	CompletedAt time.Time `json:"completed_at" bson:"completed_at"`
}

func (EmoteVersion) CountFiles

func (ev EmoteVersion) CountFiles(contentType string, omitStatic bool) int32

func (EmoteVersion) GetFiles

func (ev EmoteVersion) GetFiles(contentType string, omitStatic bool) []ImageFile

func (EmoteVersion) IsProcessing

func (ev EmoteVersion) IsProcessing() bool

func (EmoteVersion) IsUnavailable

func (ev EmoteVersion) IsUnavailable() bool

func (*EmoteVersion) Validator

func (e *EmoteVersion) Validator() EmoteVersionValidator

type EmoteVersionState

type EmoteVersionState struct {
	// The current life cycle of the emote
	// indicating whether it's processing, live, deleted, etc.
	Lifecycle EmoteLifecycle `json:"lifecycle" bson:"lifecycle"`
	// An error message linked to a failure in the emote's processing stage
	Error string `json:"error,omitempty" bson:"error,omitempty"`
	// ID of a replacing emote (used to redirect merges)
	ReplaceID primitive.ObjectID `json:"replace_id,omitempty" bson:"replace_id,omitempty"`
	// Whether or not the emote is listed
	Listed bool `json:"listed" bson:"listed"`
	// Whether or not the emote is validated for personal use
	AllowPersonal *bool `json:"allow_personal" bson:"allow_personal"`
	// The ranked position for the amount of channels this emote is added on to.
	// This value is to be determined with an external cron job
	ChannelCountRank int32 `json:"-" bson:"channel_count_rank"`
	// The amount of channels this emote is added on to.
	// This value is to be determined with an external cron job
	ChannelCount int32 `json:"-" bson:"channel_count"`
	// The time at which the ChannelCount value was last checked
	ChannelCountCheckAt time.Time `json:"-" bson:"channel_count_check_at"`
	Language            string    `json:"language,omitempty" bson:"language,omitempty"`
}

type EmoteVersionValidator

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

func (EmoteVersionValidator) Description

func (x EmoteVersionValidator) Description() error

func (EmoteVersionValidator) Name

func (x EmoteVersionValidator) Name() error

type Entitlement

type Entitlement[D EntitlementData] struct {
	ID primitive.ObjectID `json:"id" bson:"_id,omitempty"`
	// Kind represents what item this entitlement grants
	Kind EntitlementKind `json:"kind" bson:"kind"`
	// Data referencing the entitled item
	Data D `json:"data" bson:"data"`
	// The user who is entitled to the item
	UserID primitive.ObjectID `json:"user_id" bson:"user_id"`
	// An optional claim expectation
	Claim *EntitlementClaim `json:"claim" bson:"claim"`
	// Eligibility conditions for this entitlement
	Condition EntitlementCondition `json:"condition" bson:"condition"`
	// Whether this entitlement is currently inactive
	Disabled bool `json:"disabled,omitempty" bson:"disabled,omitempty"`
	// Information about the app that created this entitlement
	App *EntitlementApp `json:"app,omitempty" bson:"app,omitempty"`
}

Entitlement is a binding between a resource and a user It grants the user access to the bound resource and may define some additional properties on top.

func ConvertEntitlement

func ConvertEntitlement[D EntitlementData](c Entitlement[bson.Raw]) (Entitlement[D], error)

func (Entitlement[D]) ToRaw

func (e Entitlement[D]) ToRaw() Entitlement[bson.Raw]

type EntitlementApp

type EntitlementApp struct {
	Name    string         `json:"name" bson:"name"`
	ActorID string         `json:"actor_id,omitempty" bson:"actor_id"`
	State   map[string]any `json:"state" bson:"state"`
}

type EntitlementBuilder

type EntitlementBuilder[D EntitlementData] struct {
	Entitlement Entitlement[D]

	User *User
	// contains filtered or unexported fields
}

func NewEntitlementBuilder

func NewEntitlementBuilder[D EntitlementData](ent Entitlement[D]) *EntitlementBuilder[D]

func (*EntitlementBuilder[D]) SetApp

func (*EntitlementBuilder[D]) SetClaim

func (b *EntitlementBuilder[D]) SetClaim(claim EntitlementClaim) *EntitlementBuilder[D]

func (*EntitlementBuilder[D]) SetCondition

func (b *EntitlementBuilder[D]) SetCondition(cond EntitlementCondition) *EntitlementBuilder[D]

func (*EntitlementBuilder[D]) SetData

func (b *EntitlementBuilder[D]) SetData(data D) *EntitlementBuilder[D]

SetSubscriptionData: Add a subscription reference to the entitlement

func (*EntitlementBuilder[D]) SetKind

func (b *EntitlementBuilder[D]) SetKind(kind EntitlementKind) *EntitlementBuilder[D]

SetKind: Change the entitlement's kind

func (*EntitlementBuilder[D]) SetUserID

func (b *EntitlementBuilder[D]) SetUserID(id primitive.ObjectID) *EntitlementBuilder[D]

SetUserID: Change the entitlement's assigned user

type EntitlementClaim

type EntitlementClaim struct {
	Platform UserConnectionPlatform `json:"platform" bson:"platform"`
	ID       string                 `json:"id" bson:"id"`
}

type EntitlementCondition

type EntitlementCondition struct {
	AnyRoles []primitive.ObjectID `json:"any_roles,omitempty" bson:"any_roles,omitempty"`
	AllRoles []primitive.ObjectID `json:"all_roles,omitempty" bson:"all_roles,omitempty"`
	MinDate  time.Time            `json:"min_date,omitempty" bson:"min_date,omitempty"`
	MaxDate  time.Time            `json:"max_date,omitempty" bson:"max_date,omitempty"`
	NoLegacy bool                 `json:"no_legacy,omitempty" bson:"no_legacy,omitempty"`
}

func (EntitlementCondition) IsMet

type EntitlementDataBadge

type EntitlementDataBadge struct {
	RefID     primitive.ObjectID           `json:"-" bson:"ref"`
	RefObject *Cosmetic[CosmeticDataBadge] `json:"ref_object" bson:"ref_object,skip,omitempty"`
	Selected  bool                         `json:"selected,omitempty" bson:"selected,omitempty"`
}

EntitledBadge Badge binding in an Entitlement

type EntitlementDataBase

type EntitlementDataBase struct {
	// The ID of the subscription
	RefID primitive.ObjectID `json:"-" bson:"ref"`
}

type EntitlementDataBaseSelectable

type EntitlementDataBaseSelectable struct {
	// The ID of the subscription
	RefID    primitive.ObjectID `json:"-" bson:"ref"`
	Selected bool               `json:"selected" bson:"selected"`
}

type EntitlementDataEmoteSet

type EntitlementDataEmoteSet struct {
	RefID     primitive.ObjectID `json:"-" bson:"ref"`
	RefObject *EmoteSet          `json:"ref_object" bson:"ref_object,skip,omitempty"`
}

EntitledEmoteSet Emote Set binding in an Entitlement

type EntitlementDataPaint

type EntitlementDataPaint struct {
	RefID     primitive.ObjectID           `json:"-" bson:"ref"`
	RefObject *Cosmetic[CosmeticDataPaint] `json:"ref_object" bson:"ref_object,skip,omitempty"`
	Selected  bool                         `json:"selected,omitempty" bson:"selected,omitempty"`
}

type EntitlementDataRole

type EntitlementDataRole struct {
	RefID     primitive.ObjectID `json:"-" bson:"ref"`
	RefObject *Role              `json:"ref_object" bson:"ref_object,skip,omitempty"`
}

EntitledRole Role binding in an Entitlement

type EntitlementDataSubscription

type EntitlementDataSubscription struct {
	Interval     int    `json:"interval" bson:"interval"`
	IntervalUnit string `json:"interval_unit" bson:"interval_unit"`
}

EntitledSubscription Subscription binding in an Entitlement

type EntitlementKind

type EntitlementKind string

EntitlementKind A string representing a kind of entitlement

type ImageFile

type ImageFile struct {
	Name         string `json:"name" bson:"name"`                         // The name of the file
	Width        int32  `json:"width" bson:"width,omitempty"`             // The pixel width of the emote
	Height       int32  `json:"height" bson:"height,omitempty"`           // The pixel height of the emote
	FrameCount   int32  `json:"frame_count" bson:"frame_count,omitempty"` // Whether or not this file is animated
	Size         int64  `json:"size" bson:"size"`                         // The file size in bytes
	ContentType  string `json:"content_type" bson:"content_type"`
	SHA3         string `json:"sha3" bson:"sha3"`
	Key          string `json:"key" bson:"key"`
	Bucket       string `json:"bucket" bson:"bucket"`
	ACL          string `json:"acl"`
	CacheControl string `json:"cache_control"`
}

func (ImageFile) IsStatic

func (ef ImageFile) IsStatic() bool

type ListItemAction

type ListItemAction string
const (
	ListItemActionAdd    ListItemAction = "ADD"
	ListItemActionUpdate ListItemAction = "UPDATE"
	ListItemActionRemove ListItemAction = "REMOVE"
)

type Message

type Message[D MessageData] struct {
	ID primitive.ObjectID `json:"id" bson:"_id,omitempty"`

	// The kind of message this is (i.e a comment, or inbox message)
	Kind MessageKind `json:"kind" bson:"kind"`
	// The ID of the user who created this message
	AuthorID primitive.ObjectID `json:"author_id" bson:"author_id,omitempty"`
	// Whether or not the message's author will not be displayed to unprivileged end users
	Anonymous bool `json:"anonymous,omitempty" bson:"anonymous,omitempty"`
	// The date on which this message was cretaed
	CreatedAt time.Time `json:"created_at" bson:"created_at"`
	// Message data
	Data D `json:"data" bson:"data"`

	Author    *User     `json:"author,omitempty" bson:"author,omitempty"`
	Timestamp time.Time `json:"timestamp,omitempty" bson:"timestamp,omitempty"`
	Read      bool      `json:"read,omitempty" bson:"read,omitempty"`
}

func ConvertMessage

func ConvertMessage[D MessageData](c Message[bson.Raw]) (Message[D], error)

func (Message[D]) ToRaw

func (m Message[D]) ToRaw() Message[bson.Raw]

type MessageBuilder

type MessageBuilder[D MessageData] struct {
	Message Message[D]
	Update  UpdateMap
	// contains filtered or unexported fields
}

func NewMessageBuilder

func NewMessageBuilder[D MessageData](msg Message[D]) *MessageBuilder[D]

func (*MessageBuilder[D]) IsTainted

func (eb *MessageBuilder[D]) IsTainted() bool

IsTainted returns whether or not this Builder has been mutated before

func (*MessageBuilder[D]) MarkAsTainted

func (eb *MessageBuilder[D]) MarkAsTainted()

MarkAsTainted taints the builder, preventing it from being mutated again

func (*MessageBuilder[D]) SetAnonymous

func (mb *MessageBuilder[D]) SetAnonymous(b bool) *MessageBuilder[D]

func (*MessageBuilder[D]) SetAuthorID

func (mb *MessageBuilder[D]) SetAuthorID(id primitive.ObjectID) *MessageBuilder[D]

func (*MessageBuilder[D]) SetData

func (mb *MessageBuilder[D]) SetData(data D) *MessageBuilder[D]

func (*MessageBuilder[D]) SetKind

func (mb *MessageBuilder[D]) SetKind(kind MessageKind) *MessageBuilder[D]

func (*MessageBuilder[D]) SetTimestamp

func (mb *MessageBuilder[D]) SetTimestamp(t time.Time) *MessageBuilder[D]

type MessageComponent

type MessageComponent struct {
	Type    MessageComponentType `json:"type" bson:"type"`                           // the type of component
	Heading uint8                `json:"heading,omitempty" bson:"heading,omitempty"` // component heading level
	Weight  uint8                `json:"weight,omitempty" bson:"weight,omitempty"`   // component font weight (1-9)
	Color   utils.Color          `json:"color" bson:"color"`                         // text color (ineffective on some types)
	Locale  bool                 `json:"locale" bson:"locale"`                       // whether or not the content of this component is a locale string
	Content string               `json:"content" bson:"content"`                     // the content of the component
}

type MessageComponentBuilder

type MessageComponentBuilder struct {
	MessageComponent MessageComponent
	Update           UpdateMap
}

func NewMessageComponentBuilder

func NewMessageComponentBuilder(mcb MessageComponent) *MessageComponentBuilder

func (*MessageComponentBuilder) SetColor

func (*MessageComponentBuilder) SetContent

func (*MessageComponentBuilder) SetHeading

func (*MessageComponentBuilder) SetLocale

func (*MessageComponentBuilder) SetType

func (*MessageComponentBuilder) SetWeight

type MessageComponentType

type MessageComponentType string
const (
	MessageComponentTypeImage    MessageComponentType = "image"
	MessageComponentTypeLink     MessageComponentType = "link"
	MessageComponentTypeText     MessageComponentType = "text"
	MessageComponentTypeMention  MessageComponentType = "mention"
	MessageComponentTypeInteract MessageComponentType = "interact"
)

type MessageDataEmoteComment

type MessageDataEmoteComment struct {
	EmoteID primitive.ObjectID `json:"emote_id" bson:"emote_id"`
	// Whether or not the comment is an official statement
	// i.e, a warning by a moderator
	Authoritative bool `json:"authoritative,omitempty" bson:"authoritative,omitempty"`
	// Whether or not the comment is pinned.
	// Pinned comments will always appear at the top
	Pinned bool `json:"pinned,omitempty" bson:"pinned,omitempty"`
	// The comment's text contents
	Content string `json:"content" bson:"content"`
}

type MessageDataInbox

type MessageDataInbox struct {
	Subject      string             `json:"subject" bson:"subject"`                               // the message's subject
	Components   []MessageComponent `json:"components" bson:"components"`                         // the message's components
	Content      string             `json:"content" bson:"content"`                               // the content of the message
	Important    bool               `json:"important,omitempty" bson:"important,omitempty"`       // whether or not the message is important
	Starred      bool               `json:"starred,omitempty" bson:"starred,omitempty"`           // whether or not the message is started
	Pinned       bool               `json:"pinned,omitempty" bson:"pinned,omitempty"`             // whether or not the message is pinned
	Locked       bool               `json:"locked,omitempty" bson:"locked,omitempty"`             // whether or not replies can be added to this message
	Locale       bool               `json:"locale,omitempty" bson:"locale,omitempty"`             // whether or not this message can use locale strings
	System       bool               `json:"system,omitempty" bson:"system,omitempty"`             // whether or not the message is a system message
	Placeholders map[string]string  `json:"placeholders,omitempty" bson:"placeholders,omitempty"` // placeholders for localization
}

type MessageDataModRequest

type MessageDataModRequest struct {
	TargetKind       ObjectKind         `json:"target_kind" bson:"target_kind"`
	TargetID         primitive.ObjectID `json:"target_id" bson:"target_id"`
	Wish             string             `json:"wish" bson:"wish"`
	Priority         uint8              `json:"priority" bson:"priority,omitempty"`
	ActorCountryName string             `json:"actor_country_name,omitempty" bson:"actor_country_name,omitempty"`
	ActorCountryCode string             `json:"actor_country_code,omitempty" bson:"actor_country_code,omitempty"`

	Target bson.Raw `json:"target" bson:"target,omitempty"`
}

type MessageDataPlaceholder

type MessageDataPlaceholder struct {
	Key   string `json:"key" bson:"key"`
	Value string `json:"value" bson:"value"`
}

type MessageKind

type MessageKind int8
const (
	MessageKindEmoteComment MessageKind = 1 // a comment
	MessageKindModRequest   MessageKind = 2 // a moderator action request
	MessageKindInbox        MessageKind = 3 // an inbox message
	MessageKindNews         MessageKind = 4 // a news post
)

func (MessageKind) String

func (k MessageKind) String() string

type MessageRead

type MessageRead struct {
	ID          primitive.ObjectID `json:"id" bson:"_id,omitempty"`
	Kind        MessageKind        `json:"kind" bson:"kind"`
	Timestamp   time.Time          `json:"timestamp" bson:"timestamp"`
	MessageID   primitive.ObjectID `json:"message_id" bson:"message_id"`
	RecipientID primitive.ObjectID `json:"recipient_id,omitempty" bson:"recipient_id,omitempty"`
	Read        bool               `json:"read" bson:"read"`
	ReadAt      time.Time          `json:"read_at,omitempty" bson:"read_at,omitempty"`
	Weight      int32              `json:"weight" bson:"weight"`

	Message *Message[bson.Raw] `json:"message,omitempty" bson:"message,skip,omitempty"`
}

MessageRead read/unread state for a message

type Object

type Object interface {
	AuditLog | Ban | Cosmetic[bson.Raw] | Emote | EmoteSet | Entitlement[bson.Raw] | Message[bson.Raw] | Report | Role | User
}

type ObjectID

type ObjectID = primitive.ObjectID

type ObjectKind

type ObjectKind int8
const (
	ObjectKindUser        ObjectKind = 1
	ObjectKindEmote       ObjectKind = 2
	ObjectKindEmoteSet    ObjectKind = 3
	ObjectKindRole        ObjectKind = 4
	ObjectKindEntitlement ObjectKind = 5
	ObjectKindBan         ObjectKind = 6
	ObjectKindMessage     ObjectKind = 7
	ObjectKindReport      ObjectKind = 8
	ObjectKindPresence    ObjectKind = 9
	ObjectKindCosmetic    ObjectKind = 10
)

func (ObjectKind) CollectionName

func (k ObjectKind) CollectionName() string

func (ObjectKind) String

func (k ObjectKind) String() string

type Report

type Report struct {
	ID     primitive.ObjectID `json:"id" bson:"_id"`
	CaseID string             `json:"case_id" bson:"case_id"`
	// The type of the target
	TargetKind ObjectKind `json:"target_kind" bson:"target_kind"`
	// The ID of the target
	TargetID primitive.ObjectID `json:"target_id" bson:"target_id"`
	// The ID of the user who created the report
	ActorID primitive.ObjectID `json:"actor_id" bson:"actor_id"`
	// The report subject (i.e "Stolen Emote")
	Subject string `json:"subject" bson:"subject"`
	// The report body (a user-generated text field with details)
	Body string `json:"body" bson:"body"`
	// Priority of the report
	Priority int32 `json:"priority" bson:"priority"`
	// Whether or not the report is open
	Status ReportStatus `json:"status" bson:"status"`
	// The date on which the report was created
	CreatedAt time.Time `json:"created_at" bson:"created_at"`
	// The date on which the report was closed
	ClosedAt *time.Time `json:"closed_at,omitempty" bson:"closed_at,omitempty"`
	// The date on which the report was last updated
	LastUpdatedAt time.Time `json:"last_updated_at" bson:"last_updated_at"`
	// The IDs of users assigned to this report
	AssigneeIDs []primitive.ObjectID `json:"assignee_ids" bson:"assignee_ids"`
	// Notes (moderator comments)
	Notes []ReportNote `json:"notes" bson:"notes"`

	Target    *User  `json:"target" bson:"target,skip,omitempty"`
	Actor     *User  `json:"reporter" bson:"actor,skip,omitempty"`
	Assignees []User `json:"assignees" bson:"assignees,skip,omitempty"`
}

type ReportBuilder

type ReportBuilder struct {
	Update UpdateMap
	Report Report
}

func NewReportBuilder

func NewReportBuilder(report Report) *ReportBuilder

NewReportBuilder: create a new report builder

func (*ReportBuilder) AddAssignee

func (rb *ReportBuilder) AddAssignee(id primitive.ObjectID) *ReportBuilder

func (*ReportBuilder) AddNote

func (rb *ReportBuilder) AddNote(note ReportNote) *ReportBuilder

func (*ReportBuilder) RemoveAssignee

func (rb *ReportBuilder) RemoveAssignee(id primitive.ObjectID) *ReportBuilder

func (*ReportBuilder) SetBody

func (rb *ReportBuilder) SetBody(body string) *ReportBuilder

func (*ReportBuilder) SetClosedAt

func (rb *ReportBuilder) SetClosedAt(t time.Time) *ReportBuilder

func (*ReportBuilder) SetCreatedAt

func (rb *ReportBuilder) SetCreatedAt(t time.Time) *ReportBuilder

func (*ReportBuilder) SetLastUpdatedAt

func (rb *ReportBuilder) SetLastUpdatedAt(t time.Time) *ReportBuilder

func (*ReportBuilder) SetPriority

func (rb *ReportBuilder) SetPriority(p int32) *ReportBuilder

func (*ReportBuilder) SetReporterID

func (rb *ReportBuilder) SetReporterID(id primitive.ObjectID) *ReportBuilder

func (*ReportBuilder) SetStatus

func (rb *ReportBuilder) SetStatus(s ReportStatus) *ReportBuilder

func (*ReportBuilder) SetSubject

func (rb *ReportBuilder) SetSubject(subject string) *ReportBuilder

func (*ReportBuilder) SetTargetID

func (rb *ReportBuilder) SetTargetID(id primitive.ObjectID) *ReportBuilder

func (*ReportBuilder) SetTargetKind

func (rb *ReportBuilder) SetTargetKind(kind ObjectKind) *ReportBuilder

type ReportNote

type ReportNote struct {
	// The time at which the note was created
	Timestamp time.Time `json:"timestamp" bson:"timestamp"`
	// The ID of the user who wrote this note
	AuthorID primitive.ObjectID `json:"author_id" bson:"author_id"`
	// The text content of the note
	Content string `json:"content" bson:"content"`
	// If true, the note is only visible to other privileged users
	// it will not be visible to the reporter
	Internal bool `json:"internal" bson:"internal"`
	// Whether or not the note was read by the reporter
	Read bool `json:"read" bson:"read"`
	// A reply to the note by the reporter
	Reply string `json:"reply" bson:"reply"`
}

type ReportStatus

type ReportStatus string
const (
	ReportStatusOpen     ReportStatus = "OPEN"
	ReportStatusAssigned ReportStatus = "ASSIGNED"
	ReportStatusClosed   ReportStatus = "CLOSED"
)

type Role

type Role struct {
	ID primitive.ObjectID `json:"id" bson:"_id"`
	// the role's name
	Name string `json:"name" bson:"name"`
	// the role's privilege position
	Position int32 `json:"position" bson:"position"`
	// the role's display color
	Color utils.Color `json:"color" bson:"color"`
	// the role's allowed permission bits
	Allowed RolePermission `json:"allowed" bson:"allowed"`
	// the role's denied permission bits
	Denied RolePermission `json:"denied" bson:"denied"`
	// whether or not this role is the default role
	Default bool `json:"default" bson:"default,omitempty"`
	// whether or not the role
	Invisible bool `json:"invisible" bson:"invisible,omitempty"`

	// the id of the linked role on discord
	DiscordID uint64 `json:"discord_id,omitempty" bson:"discord_id,omitempty"`
}

func (Role) HasPermissionBit

func (r Role) HasPermissionBit(bit RolePermission) bool

HasPermissionBit: Check for specific bit in the role's allowed permissions

type RoleBuilder

type RoleBuilder struct {
	Update UpdateMap
	Role   Role
	// contains filtered or unexported fields
}

func NewRoleBuilder

func NewRoleBuilder(role Role) *RoleBuilder

NewRoleBuilder: create a new role builder

func (*RoleBuilder) Initial

func (eb *RoleBuilder) Initial() Role

Initial returns a pointer to the value first passed to this Builder

func (*RoleBuilder) SetAllowed

func (rb *RoleBuilder) SetAllowed(allowed RolePermission) *RoleBuilder

func (*RoleBuilder) SetColor

func (rb *RoleBuilder) SetColor(color utils.Color) *RoleBuilder

func (*RoleBuilder) SetDenied

func (rb *RoleBuilder) SetDenied(denied RolePermission) *RoleBuilder

func (*RoleBuilder) SetName

func (rb *RoleBuilder) SetName(name string) *RoleBuilder

func (*RoleBuilder) SetPosition

func (rb *RoleBuilder) SetPosition(pos int32) *RoleBuilder

type RolePermission

type RolePermission int64

RolePermission Role permission bits

const (
	RolePermissionCreateEmote    RolePermission = 1 << 0 // 1 - Allows creating emotes
	RolePermissionEditEmote      RolePermission = 1 << 1 // 2 - Allows editing emotes
	RolePermissionCreateEmoteSet RolePermission = 1 << 2 // 4 - Allows creating emote sets
	RolePermissionEditEmoteSet   RolePermission = 1 << 3 // 8 - Allows creating and modifying emote sets
)

Emotes Range: 1 << 0 - 1 << 5

const (
	RolePermissionCreateReport RolePermission = 1 << 13 // 8192 - Allows creating reports
	RolePermissionSendMessages RolePermission = 1 << 14 // 16384 - Allows sending messages (i.e comments or user inboxs)

	RolePermissionFeatureZeroWidthEmoteType      RolePermission = 1 << 23 // 8388608 - Allows using the Zero-Width emote type
	RolePermissionFeatureProfilePictureAnimation RolePermission = 1 << 24 // 16777216 - Allows the user's profile picture to be animated
	RolePermissionFeatureMessagingPriority       RolePermission = 1 << 25 // 33554432 - The user's messages will become prioritized
)

User / Misc / Special Range: 1 << 13 - 1 << 1 << 29

const (
	RolePermissionManageBans      RolePermission = 1 << 30 // 1073741824 - (Mod) Allows creating or deleting bans
	RolePermissionManageRoles     RolePermission = 1 << 31 // 2147483648 - (Mod) Allows creating, deleting and assigning roles to users
	RolePermissionManageReports   RolePermission = 1 << 32 // 4294967296 - (Mod) Allows managing reports
	RolePermissionManageUsers     RolePermission = 1 << 33 // 8589934592 - (Mod) Allows managing users
	RolePermissionEditAnyEmote    RolePermission = 1 << 41 // 2199023255552 - (Mod) Allows editing any emote
	RolePermissionEditAnyEmoteSet RolePermission = 1 << 42 // 4398046511104 - (Mod) Allows editing any emote set, unless it is a privileged set
	RolePermissionBypassPrivacy   RolePermission = 1 << 48 // 281474976710656 - (Mod) Lets the user see all non-public content
)

Moderation Range: 1 << 30 - 1 << 53

const (
	RolePermissionSuperAdministrator RolePermission = 1 << 62 // 4611686018427387904 - (Admin) GRANTS EVERY PERMISSION /!\
	RolePermissionManageContent      RolePermission = 1 << 54 // 18014398509481984 - (Admin) Allows managing featured content or publish items of significance
	RolePermissionManageStack        RolePermission = 1 << 55 // 36028797018963968 - (Admin) Allows managing the application stack
	RolePermissionManageCosmetics    RolePermission = 1 << 56 // 72057594037927936 - (Admin) Allows managing user cosmetics
	RolePermissionRunJobs            RolePermission = 1 << 57 // 144115188075855872 - (Admin) Allows firing processing jobs
	RolePermissionManageEntitlements RolePermission = 1 << 58 // 288230376151711744 - (Admin) Allows managing entitlements
)

Range: 1 << 54 - 1 << 63

type System

type System struct {
	ID ObjectID `json:"id" bson:"_id"`

	AdminUserID ObjectID `json:"admin_user_id" bson:"admin_user_id"`
	EmoteSetID  ObjectID `json:"emote_set_id" bson:"emote_set_id"`
	Config      struct {
		Extension        SystemConfigExtension `json:"extension" bson:"extension"`
		ExtensionNightly SystemConfigExtension `json:"extension_nightly" bson:"extension_nightly"`
	} `json:"config" bson:"config"`
}

type SystemConfigExtension

type SystemConfigExtension struct {
	Version       string                        `json:"version" bson:"version"`
	Overrides     []struct{}                    `json:"overrides" bson:"overrides"`
	Compatibility []SystemConfigExtensionCompat `json:"compatibility" bson:"compatibility"`
}

type SystemConfigExtensionCompat

type SystemConfigExtensionCompat struct {
	ID     []string                           `json:"id" bson:"id"`
	Issues []SystemConfigExtensionCompatIssue `json:"issues" bson:"issues"`
}

type SystemConfigExtensionCompatIssue

type SystemConfigExtensionCompatIssue struct {
	Platforms []UserConnectionPlatform                 `json:"platform" bson:"platform"`
	Severity  SystemConfigExtensionCompatIssueSeverity `json:"severity" bson:"severity"`
	Message   string                                   `json:"message" bson:"message"`
}

type SystemConfigExtensionCompatIssueSeverity

type SystemConfigExtensionCompatIssueSeverity string
const (
	SystemConfigExtensionCompatIssueSeverityNote                   SystemConfigExtensionCompatIssueSeverity = "NOTE"
	SystemConfigExtensionCompatIssueSeverityWarning                SystemConfigExtensionCompatIssueSeverity = "WARNING"
	SystemConfigExtensionCompatIssueSeverityBadPerformance         SystemConfigExtensionCompatIssueSeverity = "BAD_PERFORMANCE"
	SystemConfigExtensionCompatIssueSeverityClashing               SystemConfigExtensionCompatIssueSeverity = "CLASHING"
	SystemConfigExtensionCompatIssueSeverityDuplicateFunctionality SystemConfigExtensionCompatIssueSeverity = "DUPLICATE_FUNCTIONALITY"
)

type SystemDefaultObject

type SystemDefaultObject struct {
	ID         ObjectID `json:"id" bson:"id"`
	Collection string   `json:"collection" bson:"collection"`
}

type UpdateMap

type UpdateMap bson.M

func (UpdateMap) AddToSet

func (u UpdateMap) AddToSet(key string, value UpdateValue) UpdateMap

func (UpdateMap) Clear

func (u UpdateMap) Clear()

func (UpdateMap) Has

func (u UpdateMap) Has(operator, key string) bool

func (UpdateMap) Pull

func (u UpdateMap) Pull(key string, value UpdateValue) UpdateMap

func (UpdateMap) Push

func (u UpdateMap) Push(key string, value UpdateValue) UpdateMap

func (UpdateMap) Set

func (u UpdateMap) Set(key string, value UpdateValue) UpdateMap

func (UpdateMap) UndoSet

func (u UpdateMap) UndoSet(key string) UpdateMap

type UpdateValue

type UpdateValue interface{}

type User

type User struct {
	ID ObjectID `json:"id,omitempty" bson:"_id,omitempty"`
	// the type of this user. empty when a regular user, but could also be "BOT" or "SYSTEM"
	UserType UserType `json:"type,omitempty" bson:"type,omitempty"`
	// the user's username
	Username string `json:"username" bson:"username"`
	// the user's display name
	DisplayName string `json:"display_name" bson:"display_name"`
	// the user's discriminatory space
	Discriminator string `json:"discriminator" bson:"discriminator"`
	// the user's email
	Email string `json:"email" bson:"email"`
	// list of role IDs directly bound to the user (not via an entitlement)
	RoleIDs []ObjectID `json:"role_ids" bson:"role_ids"`
	// the user's editors
	Editors []UserEditor `json:"editors" bson:"editors"`
	// the user's avatar URL
	AvatarID string `json:"avatar_id" bson:"avatar_id"`
	// the user's avatar
	Avatar *UserAvatar `json:"avatar" bson:"avatar"`
	// the user's biography
	Biography string `json:"biography" bson:"biography"`
	// token version. When this value changes all existing auth tokens are invalidated
	TokenVersion float64 `json:"token_version" bson:"token_version"`
	// third party connections. Who's the third party now?
	Connections UserConnectionList `json:"connections" bson:"connections"`
	// the ID of users who have been blocked by the user
	BlockedUserIDs []ObjectID `json:"blocked_user_ids,omitempty" bson:"blocked_user_ids,omitempty"`
	// persisted non-structural data that can be used internally for querying
	State UserState `json:"-" bson:"state"`
	// Special treatments attributed to the user;
	// This is used to run experiments
	Treatments []string `json:"treatments" bson:"treatments"`

	Emotes       []Emote                 `json:"emotes" bson:"emotes,skip,omitempty"`
	OwnedEmotes  []Emote                 `json:"owned_emotes" bson:"owned_emotes,skip,omitempty"`
	Bans         []Ban                   `json:"bans" bson:"bans,skip,omitempty"`
	Entitlements []Entitlement[bson.Raw] `json:"entitlements" bson:"entitlements,skip,omitempty"`

	Roles     []Role       `json:"roles" bson:"roles,skip,omitempty"`
	EditorOf  []UserEditor `json:"editor_of" bson:"editor_of,skip,omitempty"`
	AvatarURL string       `json:"avatar_url" bson:"-"`
}

User A standard app user object

func (*User) AddRoles

func (u *User) AddRoles(roles ...Role)

func (*User) FinalPermission

func (u *User) FinalPermission() (total RolePermission)

func (*User) GetEditor

func (u *User) GetEditor(id primitive.ObjectID) (UserEditor, bool, int)

GetEditor returns the specified user editor

func (*User) GetHighestRole

func (u *User) GetHighestRole() Role

func (*User) HasPermission

func (u *User) HasPermission(bit RolePermission) bool

HasPermission checks relational roles against a permission bit

func (*User) InferUsername

func (u *User) InferUsername()

func (*User) SetDiscriminator

func (u *User) SetDiscriminator(discrim string)

func (*User) SortRoles

func (u *User) SortRoles()

func (User) WebURL

func (e User) WebURL(origin string) string

type UserAvatar

type UserAvatar struct {
	ID         primitive.ObjectID  `json:"id" bson:"id"`
	InputFile  ImageFile           `json:"input_file" bson:"input_file"`
	ImageFiles []ImageFile         `json:"image_files" bson:"image_files"`
	PendingID  *primitive.ObjectID `json:"pending_id,omitempty" bson:"pending_id,omitempty"`
}

type UserBuilder

type UserBuilder struct {
	Update UpdateMap
	User   User
	// contains filtered or unexported fields
}

func NewUserBuilder

func NewUserBuilder(user User) *UserBuilder

NewUserBuilder: create a new user builder

func (*UserBuilder) AddConnection

func (ub *UserBuilder) AddConnection(conn UserConnection[bson.Raw]) *UserBuilder

func (*UserBuilder) AddEditor

func (ub *UserBuilder) AddEditor(id ObjectID, permissions UserEditorPermission, visible bool) (UserEditor, int, *UserBuilder)

func (*UserBuilder) GetConnection

func (ub *UserBuilder) GetConnection(p UserConnectionPlatform, id ...string) (*UserConnectionBuilder[bson.Raw], int)

func (*UserBuilder) Initial

func (ub *UserBuilder) Initial() *User

Initial returns a pointer to the value first passed to this Builder

func (*UserBuilder) IsTainted

func (ub *UserBuilder) IsTainted() bool

IsTainted returns whether or not this Builder has been mutated before

func (*UserBuilder) MarkAsTainted

func (ub *UserBuilder) MarkAsTainted()

MarkAsTainted taints the builder, preventing it from being mutated again

func (*UserBuilder) RemoveConnection

func (ub *UserBuilder) RemoveConnection(id string) (*UserBuilder, int)

func (*UserBuilder) RemoveEditor

func (ub *UserBuilder) RemoveEditor(id ObjectID) (UserEditor, int, *UserBuilder)

func (*UserBuilder) SetAvatarID

func (ub *UserBuilder) SetAvatarID(url string) *UserBuilder

func (*UserBuilder) SetDiscriminator

func (ub *UserBuilder) SetDiscriminator(discrim string) *UserBuilder

func (*UserBuilder) SetDisplayName

func (ub *UserBuilder) SetDisplayName(s string) *UserBuilder

func (*UserBuilder) SetEmail

func (ub *UserBuilder) SetEmail(email string) *UserBuilder

SetEmail: set the email for the user

func (*UserBuilder) SetUsername

func (ub *UserBuilder) SetUsername(username string) *UserBuilder

SetUsername: set the username for the user

func (*UserBuilder) UpdateConnection

func (ub *UserBuilder) UpdateConnection(id string, data bson.Raw) bool

func (*UserBuilder) UpdateEditor

func (ub *UserBuilder) UpdateEditor(id ObjectID, permissions UserEditorPermission, visible bool) (UserEditor, int, *UserBuilder)

type UserConnection

type UserConnection[D UserConnectionData] struct {
	ID string `json:"id,omitempty" bson:"id,omitempty"`
	// the platform of this connection
	Platform UserConnectionPlatform `json:"platform" bson:"platform"`
	// the time at which this connection was linked
	LinkedAt time.Time `json:"linked_at" bson:"linked_at"`
	// the maximum amount of emotes this connection may have have enabled, counting the total from active sets
	EmoteSlots int32 `json:"emote_slots" bson:"emote_slots"`
	// emote sets bound to this connection / channel
	EmoteSetID ObjectID `json:"emote_set_id,omitempty" bson:"emote_set_id,omitempty"`
	// third-party connection data
	Data D `json:"data" bson:"data"`
	// a list of different possible connection data objects
	// the user must choose one to confirm the connection
	ChoiceData []bson.Raw `json:"choice_data,omitempty" bson:"choice_data,omitempty"`
	// a full oauth2 token grant
	Grant *UserConnectionGrant `json:"-" bson:"grant,omitempty"`

	EmoteSet *EmoteSet `json:"emote_set" bson:"emote_set,skip,omitempty"`
}

UserConnection: Represents an external connection to a platform for a user

func ConvertUserConnection

func ConvertUserConnection[D UserConnectionData](c UserConnection[bson.Raw]) (UserConnection[D], error)

func (UserConnection[D]) ToRaw

func (u UserConnection[D]) ToRaw() UserConnection[bson.Raw]

func (UserConnection[D]) Username

func (uc UserConnection[D]) Username() (string, string)

type UserConnectionBuilder

type UserConnectionBuilder[D UserConnectionData] struct {
	Update         UpdateMap
	UserConnection UserConnection[D]
}

UserConnectionBuilder: utility for creating a new UserConnection

func NewUserConnectionBuilder

func NewUserConnectionBuilder[D UserConnectionData](v UserConnection[D]) *UserConnectionBuilder[D]

NewUserConnectionBuilder: create a new user connection builder

func (*UserConnectionBuilder[D]) SetActiveEmoteSet

func (ucb *UserConnectionBuilder[D]) SetActiveEmoteSet(id ObjectID) *UserConnectionBuilder[D]

func (*UserConnectionBuilder[D]) SetData

func (ucb *UserConnectionBuilder[D]) SetData(data D) *UserConnectionBuilder[D]

func (*UserConnectionBuilder[D]) SetGrant

func (ucb *UserConnectionBuilder[D]) SetGrant(at string, rt string, ex int, sc []string) *UserConnectionBuilder[D]

func (*UserConnectionBuilder[D]) SetID

func (ucb *UserConnectionBuilder[D]) SetID(id string) *UserConnectionBuilder[D]

func (*UserConnectionBuilder[D]) SetLinkedAt

func (ucb *UserConnectionBuilder[D]) SetLinkedAt(date time.Time) *UserConnectionBuilder[D]

SetLinkedAt: set the time at which the connection was linked

func (*UserConnectionBuilder[D]) SetPlatform

func (ucb *UserConnectionBuilder[D]) SetPlatform(platform UserConnectionPlatform) *UserConnectionBuilder[D]

SetPlatform: defines the platform a connection is for (i.e twitch/youtube)

type UserConnectionDataDiscord

type UserConnectionDataDiscord struct {
	ID            string `json:"id" bson:"id"`
	Username      string `json:"username" bson:"username"`
	Discriminator string `json:"discriminator" bson:"discriminator"`
	Avatar        string `json:"avatar" bson:"avatar"`
	Bot           bool   `json:"bot" bson:"bot"`
	System        bool   `json:"system" bson:"system"`
	MFAEnabled    bool   `json:"mfa_enabled" bson:"mfa_enabled"`
	Banner        string `json:"banner" bson:"banner,omitempty"`
	AccentColor   int64  `json:"accent_color" bson:"accent_color,omitempty"`
	Locale        string `json:"locale" bson:"locale,omitempty"`
	Verified      bool   `json:"verified" bson:"verified"`
	Email         string `json:"email" bson:"email,omitempty"`
	Flags         int64  `json:"flags" bson:"flags"`
	PremiumType   uint32 `json:"premium_type" bson:"premium_type"`
	PublicFlags   uint32 `json:"public_flags" bson:"public_flags"`
}

type UserConnectionDataKick

type UserConnectionDataKick struct {
	ID          string `json:"id" bson:"id"`
	ChatroomID  string `json:"chatroom_id" bson:"chatroom_id"`
	Username    string `json:"username" bson:"username"`
	DisplayName string `json:"display_name" bson:"display_name"`
	Bio         string `json:"bio" bson:"bio"`
}

type UserConnectionDataTwitch

type UserConnectionDataTwitch struct {
	ID              string    `json:"id" bson:"id"`
	Login           string    `json:"login" bson:"login"`
	DisplayName     string    `json:"display_name" bson:"display_name"`
	BroadcasterType string    `json:"broadcaster_type" bson:"broadcaster_type"`
	Description     string    `json:"description" bson:"description"`
	ProfileImageURL string    `json:"profile_image_url" bson:"profile_image_url"`
	OfflineImageURL string    `json:"offline_image_url" bson:"offline_image_url"`
	ViewCount       int       `json:"view_count" bson:"view_count"`
	Email           string    `json:"email" bson:"email"`
	CreatedAt       time.Time `json:"created_at" bson:"twitch_created_at"`
}

type UserConnectionDataYoutube

type UserConnectionDataYoutube struct {
	ID              string `json:"id" bson:"id"`
	Title           string `json:"title" bson:"title"`
	Description     string `json:"description" bson:"description"`
	ViewCount       int64  `json:"view_count" bson:"view_count"`
	SubCount        int64  `json:"sub_count" bson:"sub_count"`
	ProfileImageURL string `json:"profile_image_url" bson:"profile_image_url"`
}

type UserConnectionGrant

type UserConnectionGrant struct {
	AccessToken  string    `json:"access_token" bson:"access_token"`
	RefreshToken string    `json:"refresh_token" bson:"refresh_token"`
	Scope        []string  `json:"scope" bson:"scope"`
	ExpiresAt    time.Time `json:"expires_at" bson:"expires_at"`
}

type UserConnectionList

type UserConnectionList []UserConnection[bson.Raw]

func (UserConnectionList) Discord

func (UserConnectionList) Get

func (UserConnectionList) Twitch

Twitch returns the first Twitch user connection

func (UserConnectionList) YouTube

YouTube returns the first YouTube user connection

type UserConnectionPlatform

type UserConnectionPlatform string

UserConnectionPlatform Represents a platform that the app supports

var (
	UserConnectionPlatformTwitch  UserConnectionPlatform = "TWITCH"
	UserConnectionPlatformYouTube UserConnectionPlatform = "YOUTUBE"
	UserConnectionPlatformDiscord UserConnectionPlatform = "DISCORD"
	UserConnectionPlatformKick    UserConnectionPlatform = "KICK"
)

func (UserConnectionPlatform) AuthorizeURL

func (ap UserConnectionPlatform) AuthorizeURL() string

func (UserConnectionPlatform) Supported

func (ucp UserConnectionPlatform) Supported() bool

func (UserConnectionPlatform) TokenURL

func (ap UserConnectionPlatform) TokenURL() string

type UserDiscriminator

type UserDiscriminator uint8

type UserEditor

type UserEditor struct {
	ID ObjectID `json:"id" bson:"id"`
	// The permissions this editor has
	Permissions UserEditorPermission `json:"permissions" bson:"permissions"`
	// Whether or not that editor will be visible on the user's profile page
	Visible bool `json:"visible" bson:"visible"`

	AddedAt time.Time `json:"added_at,omitempty" bson:"added_at,omitempty"`

	// Relational
	User *User `json:"user" bson:"user,skip,omitempty"`
}

func (*UserEditor) HasPermission

func (ed *UserEditor) HasPermission(bit UserEditorPermission) bool

HasPermission: check whether or not the editor has a permission

type UserEditorPermission

type UserEditorPermission int32
const (
	UserEditorPermissionModifyEmotes      UserEditorPermission = 1 << 0 // 1 - Allows modifying emotes in the user's active emote sets
	UserEditorPermissionUsePrivateEmotes  UserEditorPermission = 1 << 1 // 2 - Allows using the user's private emotes
	UserEditorPermissionManageProfile     UserEditorPermission = 1 << 2 // 4 - Allows managing the user's public profile
	UserEditorPermissionManageOwnedEmotes UserEditorPermission = 1 << 3 // 8 - Allows managing the user's owned emotes
	UserEditorPermissionManageEmoteSets   UserEditorPermission = 1 << 4 // 16 - Allows managing the user's owned emote sets
	UserEditorPermissionManageBilling     UserEditorPermission = 1 << 5 // 32 - Allows managing billing and payments, such as subscriptions
	UserEditorPermissionManageEditors     UserEditorPermission = 1 << 6 // 64 - Allows adding or removing editors for the user
	UserEditorPermissionViewMessages      UserEditorPermission = 1 << 7 // 128 - Allows viewing the user's private messages, such as inbox
)

type UserPresence

type UserPresence[T UserPresenceData] struct {
	ID     primitive.ObjectID `json:"id" bson:"_id,omitempty"`
	UserID primitive.ObjectID `json:"user_id" bson:"user_id"`
	// IP is the IP address of the client who initiated this presence
	IP string `json:"ip" bson:"ip"`
	// Authentic is whether or not this presence was authenticated; confirmed that the actor issued this presence
	//
	// If false, such a presence cannot be trusted as truth of a user's location.
	// This may be used for non-sensitive information delivery, for example
	// to allow a client to announce a user as active in a chat room, but not require
	// a full authentication flow to attain this functionality.
	Authentic bool `json:"authentic" bson:"authentic"`
	// Known is whether or not the data in this presence is known
	//
	// If false, it means the data passed wasn't validated to match a real location.
	Known bool `json:"known" bson:"known"`
	// Timestamp is the time at which this presence was issued
	Timestamp time.Time `json:"timestamp" bson:"timestamp"`
	// TTL is how long this presence is valid for, before it expires
	TTL time.Time `json:"ttl" bson:"ttl"`
	// Kind is the type of presence this is
	Kind         UserPresenceKind          `json:"kind" bson:"kind"`
	Data         T                         `json:"data" bson:"data"`
	Entitlements []UserPresenceEntitlement `json:"entitlements,omitempty" bson:"entitlements,omitempty"`
}

func ConvertPresence

func ConvertPresence[D UserPresenceData](presence UserPresence[bson.Raw]) (UserPresence[D], error)

func (UserPresence[T]) ToRaw

func (up UserPresence[T]) ToRaw() UserPresence[bson.Raw]

type UserPresenceDataChannel

type UserPresenceDataChannel struct {
	Platform UserConnectionPlatform        `json:"platform" bson:"platform"`
	ID       string                        `json:"id" bson:"id"`
	Filter   UserPresenceDataChannelFilter `json:"filter" bson:"-"`
}

type UserPresenceDataChannelFilter

type UserPresenceDataChannelFilter struct {
	Emotes []string `json:"emotes" bson:"-"`
}

type UserPresenceEntitlement

type UserPresenceEntitlement struct {
	Kind         EntitlementKind    `json:"kind" bson:"kind"`
	ID           primitive.ObjectID `json:"id" bson:"id"`
	RefID        primitive.ObjectID `json:"ref" bson:"ref"`
	DispatchHash uint32             `json:"dispatch_hash,omitempty" bson:"dispatch_hash,omitempty"`
}

type UserPresenceKind

type UserPresenceKind uint8
const (
	UserPresenceKindUnknown UserPresenceKind = iota
	UserPresenceKindChannel
	UserPresenceKindWebPage
)

func (UserPresenceKind) String

func (upk UserPresenceKind) String() string

type UserPresenceLocationDataWebPage

type UserPresenceLocationDataWebPage struct {
	URL       string `json:"url" bson:"url"`
	UserAgent string `json:"user_agent" bson:"user_agent"`
}

type UserState

type UserState struct {
	RolePosition  int       `json:"-" bson:"role_position"`
	ClientIP      string    `json:"-" bson:"client_ip"`
	LastLoginDate time.Time `json:"-" bson:"last_login_at"`
	LastVisitDate time.Time `json:"-" bson:"last_visit_at"`
}

type UserType

type UserType string
var (
	UserTypeRegular UserType = ""
	UserTypeBot     UserType = "BOT"
	UserTypeSystem  UserType = "SYSTEM"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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