db

package
v0.0.0-...-f4937b0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAction

func AddAction(punishment *Action) (*mongo.InsertOneResult, error)

func AddBlockedString

func AddBlockedString(guildid string, level int, str string) (*mongo.UpdateResult, error)

func AddBlockedSubstring

func AddBlockedSubstring(guildid string, level int, substring string) (*mongo.UpdateResult, error)

func AddConfig

func AddConfig(config *MongoGuild) (*mongo.InsertOneResult, error)

func AddGuild

func AddGuild(g *discordgo.Guild, invokedByUserID string) *structs.Config

func AddUntrustworthy

func AddUntrustworthy(u *structs.Untrustworthy) error

func CheckPermission

func CheckPermission(s *discordgo.Session, conf *structs.Config, guildid string, userid string, permission interface{}) (string, bool)

will return a string of the failed permission if appropriate

func CheckTargets

func CheckTargets(s *discordgo.Session, conf *structs.Config, guildid string, actioner string, targets []string) bool

func DeleteMute

func DeleteMute(guildid string, userid string) (*mongo.DeleteResult, error)

func DeleteUntrustworthy

func DeleteUntrustworthy(id string) error

func ExportConfigYAML

func ExportConfigYAML(guildid string) ([]byte, error)

func GetAllUntrustworthy

func GetAllUntrustworthy() ([]structs.Untrustworthy, error)

func GetConfig

func GetConfig(id string) (*structs.Config, error)

func GetLevel

func GetLevel(s *discordgo.Session, conf *structs.Config, guildid string, userid string) int64

func GetMultipleUntrustworthy

func GetMultipleUntrustworthy(in []*structs.Untrustworthy) ([]*structs.Untrustworthy, error)

func GetPermission

func GetPermission(s *discordgo.Session, conf *structs.Config, guildid string, permission string) (int64, error)

func GetSingleUntrustworthy

func GetSingleUntrustworthy(in *structs.Untrustworthy) (*structs.Untrustworthy, error)

func ImportConfigYAML

func ImportConfigYAML(guildid string, in []byte) error

func IsStaff

func IsStaff(s *discordgo.Session, conf *structs.Config, guildid string, userid string) bool

func LoadFlatConfig

func LoadFlatConfig() structs.FlatConfig

func LoadGopherlinkConfig

func LoadGopherlinkConfig() structs.GopherlinkConfig

func MakeConfig

func MakeConfig(g *discordgo.Guild, invokedByUserID string) *structs.Config

func MakeMuteCmd

func MakeMuteCmd(s *discordgo.Session, conf *structs.Config, m *discordgo.Message, ctx *discordgo.Context, args []string)

func NoPermissionHandler

func NoPermissionHandler(s *discordgo.Session, m *discordgo.Message, conf *structs.Config, permission string)

func RemoveAction

func RemoveAction(guildid string, uuid string) (*mongo.DeleteResult, error)

func SetConfig

func SetConfig(id string, config *structs.Config) (*mongo.UpdateResult, error)

func SetLevel

func SetLevel(s *discordgo.Session, guildid string, userid string, level int64) error

func SetMutedRole

func SetMutedRole(guildid string, roleid string) (*mongo.UpdateResult, error)

Set funcs

func SetPermission

func SetPermission(s *discordgo.Session, guildid string, permission string, level int64) error

func SetupCmd

func SetupCmd(s *discordgo.Session, conf *structs.Config, m *discordgo.Message, ctx *discordgo.Context, args []string)

func StartDB

func StartDB(cfg structs.MongoConfig)

func UpdateAutomod

func UpdateAutomod(guildid string, automod *structs.Automod) (*mongo.UpdateResult, error)

Update automod funcs

Types

type Action

type Action struct {
	// for timestamps
	ID primitive.ObjectID `bson:"_id,omitempty"`

	// action data
	GuildID string `bson:"guildID"`
	UserID  string `bson:"userID"`
	Issuer  string `bson:"issuer"`
	Type    string `bson:"type"`
	Expires int64  `bson:"expires,omitempty"`

	// punishment specific fields
	// mutes
	RoleID string `bson:"roleID,omitempty"`

	// strikes
	Weight int64  `bson:"weight,omitempty"`
	Reason string `bson:"reason,omitempty"`

	UUID string `bson:"uuid"`
}

func GetActions

func GetActions(guildid string, userid string) ([]*Action, error)

func GetBan

func GetBan(guildid string, userid string) (*Action, error)

func GetMute

func GetMute(guildid string, userid string) (*Action, error)

func GetNonPunishments

func GetNonPunishments(guildid string, userid string) ([]*Action, error)

func GetPunishmentByUUID

func GetPunishmentByUUID(guildid string, uuid string) (*Action, error)

func GetPunishments

func GetPunishments(guildid string, userid string) ([]*Action, error)

type DB

type DB struct {
	// contains filtered or unexported fields
}

func GetDB

func GetDB() *DB

func InitDB

func InitDB() *DB

func (*DB) ConnectDB

func (db *DB) ConnectDB(mongoCfg structs.MongoConfig)

func (*DB) GetBlackMesaUser

func (db *DB) GetBlackMesaUser(id string) (*structs.BlackMesaUser, error)

func (*DB) GetMongoClient

func (db *DB) GetMongoClient() *mongo.Client

type MongoGuild

type MongoGuild struct {
	GuildID string          `json:"guildID" bson:"guildID"`
	Config  *structs.Config `json:"config" bson:"config"`
}

Jump to

Keyboard shortcuts

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