config

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2020 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Functions to interact with global and guild-specific configuration values.

Index

Constants

This section is empty.

Variables

View Source
var (
	Config         = parseConfig()
	NitoriConfPath string
	TokenOverride  string
	LogLevel       = getLogLevel()
)

Exported variables for usage in other classes

View Source
var CustomizableMessages = map[string]string{
	"levelup": "Congratulations $USER on reaching level $LEVEL.",
}

Functions

func AdvanceTotalMessages

func AdvanceTotalMessages() error

AdvanceTotalMessages advances the total messages processed counter.

func ExpEnabled

func ExpEnabled(gid string) (enabled bool, err error)

ExpEnabled queries whether the experience system is enabled for a guild.

func ExpToLevel

func ExpToLevel(exp int) int

ExpToLevel calculates amount of levels from an experience integer.

func ExpToggle

func ExpToggle(gid string) (pre bool, err error)

ExpToggle toggles the experience system enabler.

func GetCustomizableMessage

func GetCustomizableMessage(gid string, key string) (string, error)

GetCustomizableMessage gets a guild-specific message within predefined messages, returning default if not present.

func GetLastfm

func GetLastfm(user *discordgo.User, guild *discordgo.Guild) (string, error)

GetLastfm gets a user's lastfm username.

func GetMemberExp

func GetMemberExp(user *discordgo.User, guild *discordgo.Guild) (int, error)

GetMemberExp obtains experience amount of a guild member.

func GetPrefix

func GetPrefix(gid string) string

GetPrefix gets the command prefix of a guild and returns the default if none is set.

func GetTotalMessages

func GetTotalMessages() int

GetTotalMessages gets the total amount of messages processed.

func LevelToExp

func LevelToExp(level int) int

LevelToExp calculates amount of experience from a level integer.

func ResetGuild

func ResetGuild(gid string)

ResetGuild deletes all database values that belongs to a specific guild.

func ResetLastfm

func ResetLastfm(user *discordgo.User, guild *discordgo.Guild) error

ResetLastfm resets a user's lastfm username.

func ResetPrefix

func ResetPrefix(gid string) error

ResetPrefix resets the command prefix of a guild.

func SetCustomizableMessage

func SetCustomizableMessage(gid string, key string, message string) error

SetCustomizableMessage sets a guild-specific message string within predefined messages.

func SetLastfm

func SetLastfm(user *discordgo.User, guild *discordgo.Guild, username string) error

SetLastfm sets a user's lastfm username.

func SetMemberExp

func SetMemberExp(user *discordgo.User, guild *discordgo.Guild, exp int) error

SetMemberExp sets a member's experience amount.

func SetPrefix

func SetPrefix(gid string, prefix string) error

SetPrefix sets the command prefix of a guild.

Types

type Conf

type Conf struct {
	System    SystemSection
	WebServer WebServerSection
	Discord   DiscordSection
	LastFM    LastFMSection
}

type DiscordSection

type DiscordSection struct {
	Token        string
	ClientID     int
	ClientSecret string
	Presence     string
	Shard        bool
	ShardCount   int
}

type LastFMSection

type LastFMSection struct {
	ApiKey    string
	ApiSecret string
}

type MessageOutOfBounds

type MessageOutOfBounds struct{}

Configuration related types

func (MessageOutOfBounds) Error

func (err MessageOutOfBounds) Error() string

type SystemSection

type SystemSection struct {
	LogLevel      string
	Socket        string
	Database      string
	Prefix        string
	Administrator int
	Operator      []int
}

type WebServerSection

type WebServerSection struct {
	SecretKey           string
	Host                string
	Port                int
	BaseURL             string
	ForwardedByClientIP bool
	RateLimit           int
	RateLimitPeriod     int
}

Jump to

Keyboard shortcuts

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