db

package
v0.0.0-...-1e2a637 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserCollectionName = "users"
	ReputationDelay    = 40 * time.Minute
	BanDelay           = 3 * time.Hour
	DefaultReputation  = 0
)
View Source
const (
	WarningCollectionName = "warnings"
	WarningDuration       = 36 * time.Hour
)
View Source
const GuildCollectionName = "guilds"

Variables

View Source
var (
	MongoClient   *mongo.Client
	MongoDatabase *mongo.Database
)
View Source
var (
	MaxReputation float64 = 1000000
	MinReputation float64 = -1000000
)

Functions

func ChangeUserReportsResolvedCount

func ChangeUserReportsResolvedCount(userID string, change int) error

func ChangeUserReputation

func ChangeUserReputation(userID string, change int) error

func ConnectMongo

func ConnectMongo(mongoUri, mongoDatabaseName string)

func CreateWarning

func CreateWarning(warn Warning) error

func DeleteExpiredUserWarnings

func DeleteExpiredUserWarnings(userID string) error

func DeleteExpiredWarnings

func DeleteExpiredWarnings() (int64, error)

func IncrementUserMuteCount

func IncrementUserMuteCount(userID string) error

func IncrementUserReportsSentCount

func IncrementUserReportsSentCount(userID string) error

func RemoveUser

func RemoveUser(userID string) error

func RemoveUserWarnings

func RemoveUserWarnings(userID string) error

func ResetUserMuteCount

func ResetUserMuteCount(userID string) error

func ResetUserReputationDelay

func ResetUserReputationDelay(userID string) error

func SetUserReputation

func SetUserReputation(userID string, reputation int) error

func UpdateGuild

func UpdateGuild(server Guild) error

func UpdateUserBanDelay

func UpdateUserBanDelay(userID string) error

func UpdateUserReputationDelay

func UpdateUserReputationDelay(userID string) error

Types

type Guild

type Guild struct {
	ID                     string `bson:"id,omitempty"`
	SupremeModeratorRoleID string `bson:"supremeModeratorRoleID,omitempty"`
	ReportChannelID        string `bson:"reportChannelId,omitempty"`
	ResoledReportChannelID string `bson:"resoledReportChannelId,omitempty"`
	ReputationLogChannelID string `bson:"reputationLogChannelId,omitempty"`
	ModerationLogChannelID string `bson:"moderationLogChannelId,omitempty"`
}

func GetGuild

func GetGuild() (Guild, error)

type User

type User struct {
	ID                   string    `bson:"id,omitempty"`
	Reputation           int       `bson:"reputation,omitempty"`
	ReputationDelay      time.Time `bson:"reputationDelayEnd,omitempty"`
	BanDelay             time.Time `bson:"banDelayEnd,omitempty"`
	ReportsSentCount     int       `bson:"reportsSentCount,omitempty"`
	ReportsResolvedCount int       `bson:"reportsResolvedCount,omitempty"`
	MuteCount            int       `bson:"muteCount,omitempty"`
	LastMuteTime         time.Time `bson:"lastMuteTime,omitempty"`
}

func GetUser

func GetUser(userID string) (User, error)

func GetUserReputationTop

func GetUserReputationTop() ([]User, error)

type Warning

type Warning struct {
	ID          primitive.ObjectID `bson:"_id,omitempty"`
	Time        time.Time          `bson:"time,omitempty"`
	Reason      string             `bson:"reason,omitempty"`
	UserID      string             `bson:"userId,omitempty"`
	ModeratorID string             `bson:"moderatorId,omitempty"`
}

func GetUserWarnings

func GetUserWarnings(userID string) ([]Warning, error)

func GetWarning

func GetWarning(warnID uint64) (Warning, error)

func RemoveWarning

func RemoveWarning(warnID primitive.ObjectID) (Warning, error)

Jump to

Keyboard shortcuts

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