cfg

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotConfigured     = errors.New("bot not configured")
	ErrBotConfigNotFound = errors.New("bot config not found")
)

Functions

func FormatValidationResult

func FormatValidationResult(result *ValidationResult) string

FormatValidationResult formats a validation result as a string

func SaveConfig

func SaveConfig(config *Config)

Types

type Bot

type Bot struct {
	Token string `yaml:"token"`
}

Bot contains bot configurations

type BotConfig

type BotConfig struct {
	Name string `yaml:"name"`
	Bot  Bot    `yaml:"bot"`
}

BotConfig represents a bot configuration from a config file

type Config

type Config struct {
	CurrentBot string      `yaml:"current-bot"`
	Bots       []BotConfig `yaml:"bots"`
}

Config represents a CLI configuration file

func LoadConfig

func LoadConfig() (*Config, error)

func (*Config) GetBotByName

func (c *Config) GetBotByName(name string) (*BotConfig, error)

GetBotByName returns bot by its config name

func (*Config) GetCurrent

func (c *Config) GetCurrent() (*BotConfig, error)

GetCurrent returns current configured bot. If current bot is not found, change current to first from the configured bot list

type TokenValidationResult

type TokenValidationResult struct {
	Valid    bool
	Errors   []ValidationError
	Warnings []string
}

TokenValidationResult contains the results of token validation

func ValidateBotToken

func ValidateBotToken(token string) *TokenValidationResult

ValidateBotToken validates a Discord bot token format

type ValidationError

type ValidationError struct {
	Field   string
	Message string
}

ValidationError represents a configuration validation error

func (ValidationError) Error

func (e ValidationError) Error() string

type ValidationResult

type ValidationResult struct {
	Valid    bool
	Errors   []ValidationError
	Warnings []string
}

ValidationResult contains the results of configuration validation

func ValidateConfig

func ValidateConfig(config *Config) *ValidationResult

ValidateConfig validates the entire configuration

func ValidateConfigFile

func ValidateConfigFile() (*ValidationResult, error)

ValidateConfigFile loads and validates the configuration file

Jump to

Keyboard shortcuts

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