config

package
v0.0.0-...-5cb0a9e Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: MIT Imports: 11 Imported by: 0

README

Config

The config package is essential for setting up and maintaining the application's configuration.

It ensures that the application is configured correctly and ready to run. As the README.md file in the root directory outlines, this project relies on environment variables and a YAML file to configure its behavior.

This package reads .env and config.yaml files from the disk, parses them, and validates them. Any error thrown from this package should halt the application's bootstrap process.

In addition to managing these files, it also holds the configuration related to the Discord bot, including permissions and intents.

Documentation

Index

Constants

View Source
const BotDefaultContentPermission int64 = discordgo.PermissionUseSlashCommands

BotDefaultContentPermission represents the default permissions required for dynamic slash-commands.

BotIntents represents the intents the bot is interested in.

BotPermissions represents the permissions required by the bot.

BotProtectedContentPermission represents the permissions required for protected content.

Variables

This section is empty.

Functions

func Bootstrap

func Bootstrap(configFilePath string)

func GetAppID

func GetAppID() string

func GetBotToken

func GetBotToken() string

func GetGuildID

func GetGuildID() string

Types

type AutoMod

type AutoMod struct {
	Enabled                 bool   `mapstructure:"enabled" validate:"boolean"`
	ModeratorsBypass        bool   `mapstructure:"moderatorsBypass" validate:"boolean"`
	LogChannelId            string `mapstructure:"logChannelId" validate:"required,min=1"`
	LogMentionRoleId        string `mapstructure:"logMentionRoleId"`
	MessageTTL              int    `mapstructure:"messageTTL" validate:"required,min=1"`
	MaxChannelsLimitPerUser int    `mapstructure:"maxChannelsLimitPerUser" validate:"required,min=1"`
	DenyTTL                 int    `mapstructure:"denyTTL" validate:"required,min=1"`
}

type Button

type Button struct {
	Label string `mapstructure:"label" validate:"required,min=3,max=40"`
	URL   string `mapstructure:"url" validate:"required,url,min=3"`
	Emoji string `mapstructure:"emoji" validate:"regexp=^[\p{Emoji}]$"`
}

type Command

type Command struct {
	Description string      `mapstructure:"description" validate:"required,min=1,max=100"`
	Content     string      `mapstructure:"content" validate:"required,min=1"`
	Protected   bool        `mapstructure:"protected" validate:"boolean"`
	Buttons     [][]*Button `mapstructure:"buttons" validate:"min=0,max=8,dive,min=1,max=4,dive"`
}

type Ratelimit

type Ratelimit struct {
	TTL     int    `mapstructure:"ttl" validate:"required,min=1"`
	Usage   int    `mapstructure:"usage" validate:"required,min=2"`
	Message string `mapstructure:"message" validate:"required,min=3"`
}

type Yaml

type Yaml struct {
	Moderators []string            `mapstructure:"moderators" validate:"required,min=1,dive,min=1"`
	Ratelimit  Ratelimit           `mapstructure:"ratelimit" validate:"required"`
	AutoMod    AutoMod             `mapstructure:"autoMod" validate:"required"`
	Commands   map[string]*Command `mapstructure:"commands" validate:"required,max-one-space-allowed,min=1,max=85,dive"`
}

func GetYaml

func GetYaml() *Yaml

Jump to

Keyboard shortcuts

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