database

package
v0.0.0-...-e4b2dea Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StatTurns           = makeStatistic("turns", "Turns played")
	StatCorrect         = makeStatistic("correct", "Your correct guesses")
	StatIncorrect       = makeStatistic("incorrect", "Your fuckups")
	StatStreak          = makeStatistic("streak", "Current streak")
	StatStreakMax       = makeStatistic("streak_max", "Your longest streak")
	StatGameStreakBreak = makeStatistic("game_streak_break", "Longest game you've ended by getting an answer wrong")
)

Functions

func ConfigureFromMessage

func ConfigureFromMessage(db *gorm.DB, m *discordgo.MessageCreate)

func Connect

func Connect(config DatabaseConfig) *gorm.DB

func GetNextGame

func GetNextGame(db *gorm.DB, channelID string) int

Types

type AuditLog

type AuditLog struct {
	ID        int `gorm:"primaryKey;autoIncrement"`
	UserID    string
	Username  string // just for human readability
	MessageID string
	ChannelID string
	Action    string
	Data      string
	CreatedAt time.Time `gorm:"autoCreateTime"`
}

type DatabaseConfig

type DatabaseConfig struct {
	Host     string
	Port     string
	User     string
	Password string
	Database string
	Ssl      string
	Timezone string
}

type ServerConfig

type ServerConfig struct {
	GuildID           string `gorm:"primaryKey"`
	CountingChannelID string `gorm:"primaryKey"`
	CreatedAt         time.Time
}

func GetAllServerConfigs

func GetAllServerConfigs(db *gorm.DB) []ServerConfig

type Statistic

type Statistic struct {
	Key         string
	Description string
}

func GetAllStatistics

func GetAllStatistics() []*Statistic

func GetStatByKey

func GetStatByKey(key string) *Statistic

func (*Statistic) ForUser

func (s *Statistic) ForUser(db *gorm.DB, userID string) StatisticRow

func (*Statistic) ToRow

func (s *Statistic) ToRow(userID string, value int) StatisticRow

type StatisticRow

type StatisticRow struct {
	UserID    string `gorm:"primaryKey"`
	Stat      string `gorm:"primaryKey"`
	Value     int
	UpdatedAt time.Time `gorm:"autoUpdateTime"`
}

type Turn

type Turn struct {
	Game      int `gorm:"primaryKey"`
	Turn      int `gorm:"primaryKey"`
	UserID    string
	MessageID string
	ChannelID string
	Rules     int
	Guess     int
	Correct   bool
	CreatedAt time.Time `gorm:"autoCreateTime"`
}

func CreateTurnFromContext

func CreateTurnFromContext(db *gorm.DB, s *discordgo.Session, m *discordgo.MessageCreate, lastTurn Turn, guess int, correct bool) Turn

func GetCurrentTurn

func GetCurrentTurn(db *gorm.DB, channelID string) Turn

func GetHighScoreTurn

func GetHighScoreTurn(db *gorm.DB, channelID string) Turn

Jump to

Keyboard shortcuts

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