utils

package
v0.0.0-...-df62f9d Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2025 License: MIT Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SecureProxyClient *secureproxy.Client
View Source
var SuccessResponse = gin.H{
	"success": true,
}

Functions

func Base64Decode

func Base64Decode(s string) string

func Base64Encode

func Base64Encode(s string) string

func Contains

func Contains[T comparable](slice []T, value T) bool

func ErrorJson

func ErrorJson(err error) map[string]any

func ErrorStr

func ErrorStr(err string, format ...any) map[string]any

func Exists

func Exists[T comparable](v []T, el T) bool

func ExistsMap

func ExistsMap[T any, U comparable](v []T, el U, mapper func(T) U) bool

func FindMap

func FindMap[T any, U comparable](v []T, el U, mapper func(T) U) *T

func FormatValidationError

func FormatValidationError(err validator.FieldError) string

func FormatValidationErrors

func FormatValidationErrors(errors validator.ValidationErrors) string

func GenerateImageProxyToken

func GenerateImageProxyToken(imageUrl string) (string, error)

func GetEmoji

func GetEmoji(input string) (emoji string, ok bool)

func GetPermissionLevel

func GetPermissionLevel(ctx context.Context, guildId, userId uint64) (permission.PermissionLevel, error)

func GetUrlHost

func GetUrlHost(rawUrl string) string

func GetUserId

func GetUserId(store sessions.Session) uint64

func HasPermissionToViewTicket

func HasPermissionToViewTicket(ctx context.Context, guildId, userId uint64, ticket database.Ticket) (bool, *api.RequestError)

TODO: Use this on the ticket list

func IsInt

func IsInt(str string) bool

func IsLoggedIn

func IsLoggedIn(store sessions.Session) bool

func LoadEmoji

func LoadEmoji()

func Map

func Map[T comparable, U any](slice []T, f func(T) U) []U

func Must

func Must(err error)

func ProxyHook

func ProxyHook(token string, req *http.Request)

Twilight's HTTP proxy doesn't support the typical HTTP proxy protocol - instead you send the request directly to the proxy's host in the URL. This is not how Go's proxy function should be used, but it works :)

func Ptr

func Ptr[T any](v T) *T

func RandString

func RandString(length int) (string, error)

func ReadFile

func ReadFile(path string) (string, error)

func Reverse

func Reverse(slice []message.Message) []message.Message

func RoleToId

func RoleToId(role guild.Role) uint64

func SecondLevelDomain

func SecondLevelDomain(domain string) string

func SetNilIfZero

func SetNilIfZero[T comparable](value **T)

func Slice

func Slice[T any](v ...T) []T

func StringMax

func StringMax(str string, max int, suffix ...string) string

func ToSet

func ToSet[T comparable](slice []T) *collections.Set[T]

func ValueOrZero

func ValueOrZero[T any](v *T) T

Types

type GuildDto

type GuildDto struct {
	Id              uint64                     `json:"id,string"`
	Name            string                     `json:"name"`
	Icon            string                     `json:"icon"`
	PermissionLevel permission.PermissionLevel `json:"permission_level"`
}

func LoadGuilds

func LoadGuilds(ctx context.Context, accessToken string, userId uint64) ([]GuildDto, error)

type HexColour

type HexColour int

func (HexColour) Int

func (h HexColour) Int() int

func (HexColour) MarshalJSON

func (h HexColour) MarshalJSON() ([]byte, error)

func (*HexColour) UnmarshalJSON

func (h *HexColour) UnmarshalJSON(data []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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