welcomer

package
v0.0.0-...-eead62d Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidJSON       = fmt.Errorf("invalid json")
	ErrInvalidColour     = fmt.Errorf("colour format is not recognised")
	ErrInvalidBackground = fmt.Errorf("invalid background")

	CustomBackgroundPrefix = "custom:"
	SolidColourPrefix      = "solid:"
	SolidColourPrefixBased = "profile"
	UnsplashPrefix         = "unsplash:"

	RGBAPrefix = "rgba"
	RGBPrefix  = "rgb"

	RGBRegex  = regexp.MustCompile(`^rgb\(([0-9]+)\w+?, ([0-9]+)\w+?, ([0-9]+)\w+?\)$`)
	RGBARegex = regexp.MustCompile(`^rgba\(([0-9]+)\w+?, ([0-9]+)\w+?, ([0-9].+)\w+?\)$`)
)

Functions

func IsValidBackground

func IsValidBackground(s string) bool

func IsValidColour

func IsValidColour(str string) bool

func IsValidEmbed

func IsValidEmbed(s string) bool

func IsValidHex

func IsValidHex(str string, allowAlpha bool) bool

func IsValidImageAlignment

func IsValidImageAlignment(value string) bool

func IsValidImageProfileBorderType

func IsValidImageProfileBorderType(value string) bool

func IsValidImageTheme

func IsValidImageTheme(value string) bool

func IsValidInteger

func IsValidInteger(str string) bool

func IsValidUnsplashID

func IsValidUnsplashID(str string) bool

Types

type Background

type Background struct {
	Type BackgroundType `json:"type"`
	// Background specific values.
	Value string `json:"value"`
}

func ParseBackground

func ParseBackground(str string) (*Background, error)

ParseBackground parses a background string provided by user. Expected formats: solid:FFAAAA - Solid colour with HEX code. solid:profile - Solid colour based on user profile picture. unsplash:Bnr_ZSmqbDY - Unsplash along with Id. custom_341685098468343822 - per-guild welcomer background

type BackgroundType

type BackgroundType int32

ENUM(default, welcomer, solid, solidProfile, unsplash, url)

const (
	// BackgroundTypeDefault is a BackgroundType of type Default.
	BackgroundTypeDefault BackgroundType = iota
	// BackgroundTypeWelcomer is a BackgroundType of type Welcomer.
	BackgroundTypeWelcomer
	// BackgroundTypeSolid is a BackgroundType of type Solid.
	BackgroundTypeSolid
	// BackgroundTypeSolidProfile is a BackgroundType of type SolidProfile.
	BackgroundTypeSolidProfile
	// BackgroundTypeUnsplash is a BackgroundType of type Unsplash.
	BackgroundTypeUnsplash
	// BackgroundTypeUrl is a BackgroundType of type Url.
	BackgroundTypeUrl
)

func ParseBackgroundType

func ParseBackgroundType(name string) (BackgroundType, error)

ParseBackgroundType attempts to convert a string to a BackgroundType.

func (BackgroundType) MarshalText

func (x BackgroundType) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (BackgroundType) String

func (x BackgroundType) String() string

String implements the Stringer interface.

func (*BackgroundType) UnmarshalText

func (x *BackgroundType) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type Colour

type Colour struct {
	R uint8
	G uint8
	B uint8
	A uint8
}

func ParseColour

func ParseColour(str string, defaultValue string) (*Colour, error)

ParseColour parses a colour and returns RGBA. Expected formats: #FFAAAA #FFAAAAFF RGBA(255, 255, 255, 0.1) RGB(255, 255, 255)

type ImageAlignment

type ImageAlignment int32

ENUM(left, center, right, topLeft, topCenter, topRight, bottomLeft, bottomCenter, bottomRight)

const (
	// ImageAlignmentLeft is a ImageAlignment of type Left.
	ImageAlignmentLeft ImageAlignment = iota
	// ImageAlignmentCenter is a ImageAlignment of type Center.
	ImageAlignmentCenter
	// ImageAlignmentRight is a ImageAlignment of type Right.
	ImageAlignmentRight
	// ImageAlignmentTopLeft is a ImageAlignment of type TopLeft.
	ImageAlignmentTopLeft
	// ImageAlignmentTopCenter is a ImageAlignment of type TopCenter.
	ImageAlignmentTopCenter
	// ImageAlignmentTopRight is a ImageAlignment of type TopRight.
	ImageAlignmentTopRight
	// ImageAlignmentBottomLeft is a ImageAlignment of type BottomLeft.
	ImageAlignmentBottomLeft
	// ImageAlignmentBottomCenter is a ImageAlignment of type BottomCenter.
	ImageAlignmentBottomCenter
	// ImageAlignmentBottomRight is a ImageAlignment of type BottomRight.
	ImageAlignmentBottomRight
)

func ParseImageAlignment

func ParseImageAlignment(name string) (ImageAlignment, error)

ParseImageAlignment attempts to convert a string to a ImageAlignment.

func (ImageAlignment) MarshalText

func (x ImageAlignment) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (ImageAlignment) String

func (x ImageAlignment) String() string

String implements the Stringer interface.

func (*ImageAlignment) UnmarshalText

func (x *ImageAlignment) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type ImageProfileBorderType

type ImageProfileBorderType int32

ENUM(circular, rounded, squared, hexagonal)

const (
	// ImageProfileBorderTypeCircular is a ImageProfileBorderType of type Circular.
	ImageProfileBorderTypeCircular ImageProfileBorderType = iota
	// ImageProfileBorderTypeRounded is a ImageProfileBorderType of type Rounded.
	ImageProfileBorderTypeRounded
	// ImageProfileBorderTypeSquared is a ImageProfileBorderType of type Squared.
	ImageProfileBorderTypeSquared
	// ImageProfileBorderTypeHexagonal is a ImageProfileBorderType of type Hexagonal.
	ImageProfileBorderTypeHexagonal
)

func ParseImageProfileBorderType

func ParseImageProfileBorderType(name string) (ImageProfileBorderType, error)

ParseImageProfileBorderType attempts to convert a string to a ImageProfileBorderType.

func (ImageProfileBorderType) MarshalText

func (x ImageProfileBorderType) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (ImageProfileBorderType) String

func (x ImageProfileBorderType) String() string

String implements the Stringer interface.

func (*ImageProfileBorderType) UnmarshalText

func (x *ImageProfileBorderType) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type ImageTheme

type ImageTheme int32

ENUM(default, vertical, card)

const (
	// ImageThemeDefault is a ImageTheme of type Default.
	ImageThemeDefault ImageTheme = iota
	// ImageThemeVertical is a ImageTheme of type Vertical.
	ImageThemeVertical
	// ImageThemeCard is a ImageTheme of type Card.
	ImageThemeCard
)

func ParseImageTheme

func ParseImageTheme(name string) (ImageTheme, error)

ParseImageTheme attempts to convert a string to a ImageTheme.

func (ImageTheme) MarshalText

func (x ImageTheme) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (ImageTheme) String

func (x ImageTheme) String() string

String implements the Stringer interface.

func (*ImageTheme) UnmarshalText

func (x *ImageTheme) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type UserProvidedEmbed

type UserProvidedEmbed struct {
	Content string          `json:"content"`
	Embeds  []discord.Embed `json:"embeds"`
}

type Welcomer

type Welcomer struct {
	Logger zerolog.Logger
	Bot    *sandwich.Bot

	Database *database.Queries
	// contains filtered or unexported fields
}

func NewWelcomer

func NewWelcomer(identifierName string, sandwichClient *sandwich.Sandwich) (welcomer *Welcomer)

func (*Welcomer) CaptureInteractionExecution

func (w *Welcomer) CaptureInteractionExecution(interactionCtx *sandwich.InteractionContext, interactionStart time.Time, interactionError error) (commandUUID uuid.UUID, err error)

func (*Welcomer) Register

func (w *Welcomer) Register() (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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