model

package
v0.0.0-...-ad493d3 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB
View Source
var ErrNoSqid = errors.New("no sqid could be decoded")

Functions

func DeleteInfractionBySqid

func DeleteInfractionBySqid(sqid string) error

func InitDB

func InitDB(path string) (*gorm.DB, error)

func SetGuildSettings

func SetGuildSettings(settings *GuildSettings) error

Types

type GuildSettings

type GuildSettings struct {
	GuildID   snowflake.ID `gorm:"primaryKey;autoIncrement:false"`
	UpdatedAt time.Time    `gorm:"autoUpdateTime"`

	// ModeratorChannel is the channel where notifications and other
	// information for moderators and administrators are sent.
	ModeratorChannel snowflake.ID

	// InfractionHalfLifeDays is the half-life time of infractions in days.
	InfractionHalfLifeDays      float64
	NotifyOnWarnedUserJoin      bool
	NotifyWarnSeverityThreshold float64 `gorm:"default:1.0"`

	GatekeepEnabled              bool
	GatekeepPendingRole          snowflake.ID
	GatekeepApprovedRole         snowflake.ID
	GatekeepAddPendingRoleOnJoin bool
	GatekeepApprovedMessage      string

	JoinMessageEnabled  bool
	JoinMessage         string
	LeaveMessageEnabled bool
	LeaveMessage        string
	JoinLeaveChannel    snowflake.ID

	AntiSpamEnabled         bool
	AntiSpamCount           int `gorm:"default:5"`
	AntiSpamCooldownSeconds int `gorm:"default:20"`
}

func GetGuildSettings

func GetGuildSettings(guildID snowflake.ID) (*GuildSettings, error)

type Infraction

type Infraction struct {
	gorm.Model
	GuildID   snowflake.ID
	UserID    snowflake.ID
	Moderator snowflake.ID
	Reason    string
	Weight    float64
	Timestamp time.Time
	Silent    bool
}

func CreateInfraction

func CreateInfraction(guildID, userID, moderator snowflake.ID, reason string, weight float64, silent bool) (*Infraction, error)

func GetUserInfractions

func GetUserInfractions(guildID, userID snowflake.ID, limit, offset int) ([]Infraction, int64, error)

func (Infraction) Sqid

func (i Infraction) Sqid() string

type TempBan

type TempBan struct {
	GuildID snowflake.ID `gorm:"primaryKey;autoIncrement:false"`
	UserID  snowflake.ID `gorm:"primaryKey;autoIncrement:false"`

	CreatedAt time.Time `gorm:"autoCreateTime"`
	UpdatedAt time.Time `gorm:"autoUpdateTime"`

	Reason string
	Banner snowflake.ID
	Until  time.Time
}

func CreateTempBan

func CreateTempBan(guildID, userID, banner snowflake.ID, reason string, until time.Time) (*TempBan, error)

func GetExpiredTempBans

func GetExpiredTempBans() ([]TempBan, error)

func GetTempBan

func GetTempBan(guildID, userID snowflake.ID) (*TempBan, error)

func GetTempBans

func GetTempBans(guildID snowflake.ID) ([]TempBan, error)

func (*TempBan) Delete

func (tb *TempBan) Delete() error

Jump to

Keyboard shortcuts

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