reputation

package
v1.4.10 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2018 License: MIT Imports: 25 Imported by: 0

README

Reputation

This YAGPDB plugin adds a reputation system.

Provides the +/giverep, rep and toprep commands.

Documentation

Index

Constants

View Source
const DBSchema = `` /* 1417-byte string literal not displayed */

Variables

View Source
var (
	ErrMissingRequiredGiveRole    = UserError("Missing the required role to give points")
	ErrMissingRequiredReceiveRole = UserError("Missing the required role to receive points")

	ErrBlacklistedGive    = UserError("Blaclisted from giving points")
	ErrBlacklistedReceive = UserError("Blacklisted from receiving points")
	ErrCooldown           = UserError("You're still on cooldown")
)
View Source
var (
	ErrUserNotFound = errors.New("User not found")
)

Functions

func CanModifyRep

func CanModifyRep(conf *models.ReputationConfig, sender, receiver *dstate.MemberState) error

Returns a user error if the sender can not modify the rep of receiver Admins are always able to modify the rep of everyone

func CheckSetCooldown

func CheckSetCooldown(conf *models.ReputationConfig, senderID int64) (bool, error)

CheckSetCooldown checks and updates the reputation cooldown of a user, it returns true if the user was not on cooldown

func ClearCooldown

func ClearCooldown(guildID, senderID int64) error

func CmdGiveRep

func CmdGiveRep(parsed *dcmd.Data) (interface{}, error)

func DefaultConfig

func DefaultConfig(guildID int64) *models.ReputationConfig

func DelRep added in v1.4.10

func DelRep(ctx context.Context, gid int64, userID int64) error

func GetConfig

func GetConfig(ctx context.Context, guildID int64) (*models.ReputationConfig, error)

func GetUserStats

func GetUserStats(guildID, userID int64) (score int64, rank int, err error)

func HandleGetReputation

func HandleGetReputation(w http.ResponseWriter, r *http.Request) interface{}

func HandleLeaderboardJson

func HandleLeaderboardJson(w http.ResponseWriter, r *http.Request) interface{}

func HandlePostReputation

func HandlePostReputation(w http.ResponseWriter, r *http.Request) (templateData web.TemplateData, err error)

func IsAdmin

func IsAdmin(gs *dstate.GuildState, member *dstate.MemberState, config *models.ReputationConfig) bool

func KeyCooldown

func KeyCooldown(guildID, userID int64) string

func ModifyRep

func ModifyRep(ctx context.Context, conf *models.ReputationConfig, guildID int64, sender, receiver *dstate.MemberState, amount int64) (err error)

func RegisterPlugin

func RegisterPlugin()

func SetRep

func SetRep(ctx context.Context, gid int64, senderID, userID int64, points int64) error

Types

type LeaderboardEntry

type LeaderboardEntry struct {
	*RankEntry
	Username string `json:"username"`
	Bot      bool   `json:"bot"`
	Avatar   string `json:"avatar"`
}

func DetailedLeaderboardEntries

func DetailedLeaderboardEntries(guildID int64, ranks []*RankEntry) ([]*LeaderboardEntry, error)

type Plugin

type Plugin struct{}

func (*Plugin) AddCommands added in v1.4.1

func (p *Plugin) AddCommands()

func (*Plugin) BotInit added in v1.4.1

func (p *Plugin) BotInit()

func (*Plugin) InitWeb

func (p *Plugin) InitWeb()

func (*Plugin) Name

func (p *Plugin) Name() string

type PostConfigForm

type PostConfigForm struct {
	Enabled                bool
	EnableThanksDetection  bool
	PointsName             string `valid:",50"`
	Cooldown               int    `valid:"0,86401"` // One day
	MaxGiveAmount          int64
	RequiredGiveRole       string `valid:"role,true"`
	RequiredReceiveRole    string `valid:"role,true"`
	BlacklistedGiveRole    string `valid:"role,true"`
	BlacklistedReceiveRole string `valid:"role,true"`
	AdminRole              string `valid:"role,true"`
}

func (PostConfigForm) RepConfig

func (p PostConfigForm) RepConfig() *models.ReputationConfig

type RankEntry

type RankEntry struct {
	Rank   int   `json:"rank"`
	UserID int64 `json:"user_id"`
	Points int64 `json:"points"`
}

func TopUsers

func TopUsers(guildID int64, offset, limit int) ([]*RankEntry, error)

type UserError

type UserError string

func (UserError) Error

func (b UserError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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