Documentation ¶
Index ¶
- Variables
- func CanModifyRep(conf *models.ReputationConfig, sender, receiver *discordgo.Member) error
- func CheckSetCooldown(conf *models.ReputationConfig, redisClient *redis.Client, senderID int64) (bool, error)
- func ClearCooldown(redisClient *redis.Client, guildID, senderID int64) error
- func CmdGiveRep(parsed *dcmd.Data) (interface{}, error)
- func DefaultConfig(guildID int64) *models.ReputationConfig
- func Dir(useLocal bool, name string) http.FileSystem
- func FS(useLocal bool) http.FileSystem
- func FSByte(useLocal bool, name string) ([]byte, error)
- func FSMustByte(useLocal bool, name string) []byte
- func FSMustString(useLocal bool, name string) string
- func FSString(useLocal bool, name string) (string, error)
- func GetConfig(guildID int64) (*models.ReputationConfig, error)
- func GetUserStats(guildID, userID int64) (score int64, rank int, err error)
- func HandleGetReputation(w http.ResponseWriter, r *http.Request) interface{}
- func HandleLeaderboardJson(w http.ResponseWriter, r *http.Request) interface{}
- func HandlePostReputation(w http.ResponseWriter, r *http.Request) (templateData web.TemplateData, err error)
- func IsAdmin(gs *dstate.GuildState, member *discordgo.Member, ...) bool
- func KeyCooldown(guildID, userID int64) string
- func ModifyRep(conf *models.ReputationConfig, redisClient *redis.Client, guildID int64, ...) (err error)
- func RegisterPlugin()
- func SetRep(gid int64, senderID, userID int64, points int64) error
- type LeaderboardEntry
- type Plugin
- type PostConfigForm
- type RankEntry
- type UserError
Constants ¶
This section is empty.
Variables ¶
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") )
var (
ErrUserNotFound = errors.New("User not found")
)
Functions ¶
func CanModifyRep ¶
func CanModifyRep(conf *models.ReputationConfig, sender, receiver *discordgo.Member) 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, redisClient *redis.Client, 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 CmdGiveRep ¶
func DefaultConfig ¶
func DefaultConfig(guildID int64) *models.ReputationConfig
func Dir ¶
func Dir(useLocal bool, name string) http.FileSystem
Dir returns a http.Filesystem for the embedded assets on a given prefix dir. If useLocal is true, the filesystem's contents are instead used.
func FS ¶
func FS(useLocal bool) http.FileSystem
FS returns a http.Filesystem for the embedded assets. If useLocal is true, the filesystem's contents are instead used.
func FSByte ¶
FSByte returns the named file from the embedded assets. If useLocal is true, the filesystem's contents are instead used.
func FSMustByte ¶
FSMustByte is the same as FSByte, but panics if name is not present.
func FSMustString ¶
FSMustString is the string version of FSMustByte.
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 *discordgo.Member, config *models.ReputationConfig) bool
func KeyCooldown ¶
func RegisterPlugin ¶
func RegisterPlugin()
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 PostConfigForm ¶
type PostConfigForm struct { Enabled 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