Documentation ¶
Overview ¶
rolecommands is a plugin which allows users to assign roles to themselves
Index ¶
- Constants
- func AssignRole(guildID int64, member *discordgo.Member, cmd *CommandGroupPair) (gaveRole bool, err error)
- func CanAssignRoleCmdTo(r *models.RoleCommand, memberRoles []int64) error
- func CheckIgnoredRoles(ignore []int64, has []int64) error
- func CheckRequiredRoles(requireOneOf []int64, has []int64) bool
- func CmdFuncListCommands(parsed *dcmd.Data) (interface{}, error)
- func CmdFuncRole(parsed *dcmd.Data) (interface{}, error)
- func CmdFuncRoleMenu(parsed *dcmd.Data) (interface{}, error)
- func ContinueRoleMenuSetup(rm *models.RoleMenu, ra *discordgo.MessageReactionAdd) (resp string, err error)
- 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 FindAssignRole(guildID int64, member *discordgo.Member, name string) (gaveRole bool, err error)
- func GetAllRoleCommandsSorted(guildID int64) (groups []*models.RoleGroup, ...)
- func GroupAssignRoleToMember(rg *models.RoleGroup, guildID int64, member *discordgo.Member, ...) (gaveRole bool, err error)
- func HandleMoveCommand(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
- func HandleNewCommand(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
- func HandleNewGroup(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
- func HandleRemoveCommand(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
- func HandleRemoveGroup(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
- func HandleSettings(w http.ResponseWriter, r *http.Request) (tmpl web.TemplateData, err error)
- func HandleUpdateCommand(w http.ResponseWriter, r *http.Request) (tmpl web.TemplateData, err error)
- func HandleUpdateGroup(w http.ResponseWriter, r *http.Request) (tmpl web.TemplateData, err error)
- func HumanizeAssignError(guild *dstate.GuildState, err error) (string, error)
- func IsRoleCommandError(err error) bool
- func MemberChooseOption(rm *models.RoleMenu, ra *discordgo.MessageReactionAdd, gs *dstate.GuildState, ...) (resp string, err error)
- func NewGroupError(msg string, group *models.RoleGroup) error
- func NewLmitError(msg string, limit int) error
- func NewRoleError(msg string, role int64) error
- func NewSimpleError(format string, args ...interface{}) error
- func NextRoleMenuSetupStep(rm *models.RoleMenu, opts []*models.RoleMenuOption, first bool) (resp string, err error)
- func OptionCommandPairLessFunc(slice []*OptionCommandPair) func(int, int) bool
- func RegisterPlugin()
- func RoleCommandsLessFunc(slice []*models.RoleCommand) func(int, int) bool
- func StringCommands(cmds []*models.RoleCommand) string
- func ToggleRole(guildID int64, member *discordgo.Member, role int64) (gaveRole bool, err error)
- func UpdateMenu(parsed *dcmd.Data, existing *models.RoleMenu) (interface{}, error)
- func UpdateRoleMenuMessage(rm *models.RoleMenu, opts []*models.RoleMenuOption) error
- type CommandGroupPair
- type FormCommand
- type FormGroup
- type GroupError
- type LmitError
- type OptionCommandPair
- type Plugin
- type RoleError
- type SimpleError
Constants ¶
const ( GroupModeNone = iota GroupModeSingle GroupModeMultiple )
const ( RoleMenuStateSettingUp = 0 RoleMenuStateDone = 1 )
Variables ¶
This section is empty.
Functions ¶
func AssignRole ¶
func AssignRole(guildID int64, member *discordgo.Member, cmd *CommandGroupPair) (gaveRole bool, err error)
AssignRole attempts to assign the given role command, returns an error if the role does not exists or is unable to receie said role
func CanAssignRoleCmdTo ¶
func CanAssignRoleCmdTo(r *models.RoleCommand, memberRoles []int64) error
func CheckIgnoredRoles ¶
func CheckRequiredRoles ¶
func CmdFuncListCommands ¶
func CmdFuncRole ¶
func CmdFuncRoleMenu ¶
func ContinueRoleMenuSetup ¶
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 FindAssignRole ¶
func GetAllRoleCommandsSorted ¶
func GetAllRoleCommandsSorted(guildID int64) (groups []*models.RoleGroup, grouped map[*models.RoleGroup][]*models.RoleCommand, unGrouped []*models.RoleCommand, err error)
func GroupAssignRoleToMember ¶
func GroupAssignRoleToMember(rg *models.RoleGroup, guildID int64, member *discordgo.Member, targetRole *models.RoleCommand) (gaveRole bool, err error)
AssignRoleToMember attempts to assign the given role command, part of this group to the member
func HandleMoveCommand ¶
func HandleMoveCommand(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
func HandleNewCommand ¶
func HandleNewCommand(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
func HandleNewGroup ¶
func HandleNewGroup(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
func HandleRemoveCommand ¶
func HandleRemoveCommand(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
func HandleRemoveGroup ¶
func HandleRemoveGroup(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
func HandleSettings ¶
func HandleSettings(w http.ResponseWriter, r *http.Request) (tmpl web.TemplateData, err error)
func HandleUpdateCommand ¶
func HandleUpdateCommand(w http.ResponseWriter, r *http.Request) (tmpl web.TemplateData, err error)
func HandleUpdateGroup ¶
func HandleUpdateGroup(w http.ResponseWriter, r *http.Request) (tmpl web.TemplateData, err error)
func HumanizeAssignError ¶
func HumanizeAssignError(guild *dstate.GuildState, err error) (string, error)
func IsRoleCommandError ¶
func MemberChooseOption ¶
func MemberChooseOption(rm *models.RoleMenu, ra *discordgo.MessageReactionAdd, gs *dstate.GuildState, option *models.RoleMenuOption) (resp string, err error)
func NewLmitError ¶
func NewRoleError ¶
func NewSimpleError ¶
func NextRoleMenuSetupStep ¶
func OptionCommandPairLessFunc ¶
func OptionCommandPairLessFunc(slice []*OptionCommandPair) func(int, int) bool
func RegisterPlugin ¶
func RegisterPlugin()
func RoleCommandsLessFunc ¶
func RoleCommandsLessFunc(slice []*models.RoleCommand) func(int, int) bool
func StringCommands ¶
func StringCommands(cmds []*models.RoleCommand) string
StringCommands pretty formats a bunch of commands into a string
func ToggleRole ¶
ToggleRole toggles the role of a guildmember, adding it if the member does not have the role and removing it if they do
func UpdateMenu ¶
func UpdateRoleMenuMessage ¶
func UpdateRoleMenuMessage(rm *models.RoleMenu, opts []*models.RoleMenuOption) error
Types ¶
type CommandGroupPair ¶
type CommandGroupPair struct { Command *models.RoleCommand Group *models.RoleGroup }
type FormCommand ¶
type GroupError ¶
func (*GroupError) Error ¶
func (r *GroupError) Error() string
type OptionCommandPair ¶
type OptionCommandPair struct { Option *models.RoleMenuOption Command *models.RoleCommand }
type SimpleError ¶
type SimpleError string
Just a simple type but distinguishable from errors.Error
func (SimpleError) Error ¶
func (s SimpleError) Error() string