users

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PermissionAdministrator = 0x01
	PermissionModerator     = 0x02
)

These constants define the bitflags which represent the permissions a user may have

Variables

This section is empty.

Functions

func RemoveFromCache

func RemoveFromCache(userID string)

RemoveFromCache removes a user from the cache

Types

type Permission

type Permission int

Permission represents a permission

type User

type User struct {
	ID          primitive.ObjectID `bson:"_id,omitempty"`
	DiscordID   string             `bson:"discordID"`
	Permissions int                `bson:"permissions"`
}

User represents a bot user

func Retrieve

func Retrieve(userID string) (*User, error)

Retrieve retrieves a user from the database

func RetrieveCached

func RetrieveCached(userID string) (*User, error)

RetrieveCached retrieves a user but checks the cache first

func (*User) GrantPermission

func (user *User) GrantPermission(permission Permission)

GrantPermission gives the current user the given permission

func (*User) HasPermission

func (user *User) HasPermission(permissions ...Permission) bool

HasPermission checks whether or not the current user has at least one of the given permissions

func (*User) RevokePermission

func (user *User) RevokePermission(permission Permission)

RevokePermission revokes the given permission from the current user

func (*User) Update

func (user *User) Update() error

Update overrides the databases variables with the local ones

Jump to

Keyboard shortcuts

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