common

package
v0.0.0-...-ada9184 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: OSL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Find

func Find[E any](s []E, filter func(*E) bool) *E

func IsAlpha

func IsAlpha(s string) bool

func MapKeys

func MapKeys[M ~map[K]V, K comparable, V any](m M) []K

func MapTransform

func MapTransform[M ~map[K]V, K comparable, V, R any](m M, transform func(K, V) R) []R

func SliceTransform

func SliceTransform[E, R any](s []E, transform func(E) R) []R

func Ternary

func Ternary[T any](cond bool, a, b T) T

func ToTitle

func ToTitle(s string) string

Types

type AutoReplyConfig

type AutoReplyConfig struct {
	ToggleableModule

	IgnoredRoles []discord.RoleID

	PRD         discord.ChannelID
	PluginsList discord.ChannelID
	NewPlugins  discord.ChannelID

	SupportCategory discord.ChannelID
}

type BotConfig

type BotConfig struct {
	ToggleableModule

	Token               string
	OwnerIDs            []discord.UserID
	RoleIDs             *RoleIDsConfig
	Starboard           *StarboardConfig
	AutoPublish         bool
	TrollSupportRole    *TrollSupportRoleConfig
	VoiceTextChatLocker *VoiceTextChatLockerConfig
	AntiNitroScam       bool
	NormalizeNicknames  bool
	AutoReplyConfig     *AutoReplyConfig

	ApkCacheDir string `json:"-"`
	Origin      string `json:"-"`
}

type Config

type Config struct {
	Bot            *BotConfig
	Database       *DatabaseConfig
	UpdateTracker  *UpdateTrackerConfig
	MaxDownloadVer int
	MinDownloadVer int
	ApkCacheDir    string
	Port           string
	Origin         string
}

type DatabaseConfig

type DatabaseConfig struct {
	Addr     string
	User     string
	Password string
	DB       string
}

type ExtendedLogger

type ExtendedLogger struct {
	*log.Logger
}

func NewLogger

func NewLogger(prefix string) *ExtendedLogger

func (*ExtendedLogger) LogIfErr

func (logger *ExtendedLogger) LogIfErr(err error)

func (*ExtendedLogger) LogWithCtxIfErr

func (logger *ExtendedLogger) LogWithCtxIfErr(context string, errs ...error)

LogWithCtxIfErr logs one or more errors with context. Context should be simple description with -ing verb like "adding role" (will be logged as "Exception while adding role")

func (*ExtendedLogger) PanicIfErr

func (logger *ExtendedLogger) PanicIfErr(err error)

type GooglePlayChannelConfig

type GooglePlayChannelConfig struct {
	Email    string
	AASToken string
	Webhook  bool
}

type RoleIDsConfig

type RoleIDsConfig struct {
	ModRole         discord.RoleID
	SupportMuted    discord.RoleID
	PrdMuted        discord.RoleID
	DevMuted        discord.RoleID
	ReactionMuted   discord.RoleID
	AttachmentMuted discord.RoleID
}

type StarboardConfig

type StarboardConfig struct {
	ToggleableModule

	Channel discord.ChannelID
	Ignore  []discord.ChannelID
	Min     int
}

type ToggleableModule

type ToggleableModule struct {
	Enabled bool
}

type TrollSupportRoleConfig

type TrollSupportRoleConfig struct {
	ToggleableModule

	ID discord.RoleID
}

type UpdateTrackerConfig

type UpdateTrackerConfig struct {
	ToggleableModule

	Cache             string
	IgnoreFirstUpdate bool
	Webhook           *UpdateWebhookConfig

	GooglePlay map[string]GooglePlayChannelConfig
}

type UpdateWebhookConfig

type UpdateWebhookConfig struct {
	ToggleableModule

	ID    discord.WebhookID
	Token string
}

type VoiceTextChatLockerConfig

type VoiceTextChatLockerConfig struct {
	ToggleableModule

	Voice discord.ChannelID
	Text  discord.ChannelID
}

Jump to

Keyboard shortcuts

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