storage

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfKey      = "conf"
	InfoKey      = "info"
	UsersBucket  = "users"
	GuildsBucket = "guilds"
)

Various constant keys and bucket names

Variables

View Source
var (
	// ErrGuildNotFound is returned when the guild was not found in the bolt db
	ErrGuildNotFound = errors.New("guild not found")
	// ErrGuildsBucketNotFound is returned when the guilds bucket can't be found
	ErrGuildsBucketdNotFound = errors.New("guilds bucket not found")
	// ErrConfNotFound is returned when the guild's conf was not found in the bolt db
	ErrConfNotFound = errors.New("guild conf not found")
)

Functions

This section is empty.

Types

type BoltStorage added in v0.2.0

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

BoltStorage is

func NewBoltStorage added in v0.2.0

func NewBoltStorage(lc fx.Lifecycle, c *cmd.Conf, l zerolog.Logger) (*BoltStorage, error)

NewBoltStorage will initiate a new bolt storage backend with the appropriate buckets, path and permissions.

func (*BoltStorage) GetGuildConf added in v0.2.0

func (bs *BoltStorage) GetGuildConf(guildID string) (*models.Conf, error)

GetGuildConf will attempt to fetch the guild configuration for a given ID.

func (*BoltStorage) NewGuild added in v0.2.0

func (bs *BoltStorage) NewGuild(g *discordgo.GuildCreate) (*models.Conf, error)

func (*BoltStorage) NewGuildConf added in v0.2.0

func (bs *BoltStorage) NewGuildConf(guildID string) (*models.Conf, error)

NewGuildConf will create a new nested bucket with the guild ID, and will put the conf in the `conf` key.

func (*BoltStorage) SaveGuildConf added in v0.2.0

func (bs *BoltStorage) SaveGuildConf(gc *models.Conf) error

SaveGuildConf will save the guild conf to the appropriate bucket Note that this can fail in the event of manual tampering with the guild conf, for example removing its ID or setting it to empty string before calling this method.

func (*BoltStorage) UpdateGuildInfo added in v0.2.0

func (bs *BoltStorage) UpdateGuildInfo(g *discordgo.GuildCreate) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳