Documentation ¶
Index ¶
- Constants
- func CheckLimits(in ...string) bool
- func CheckMatch(globalPrefix string, cmd *CustomCommand, msg string) (match bool, stripped string, args []string)
- func Dir(useLocal bool, name string) http.FileSystem
- func ExecuteCustomCommand(cmd *CustomCommand, cmdArgs []string, stripped string, client *redis.Client, ...) (resp string, tmplCtx *templates.Context, err error)
- 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 HandleCommands(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
- func HandleDeleteCommand(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
- func HandleMessageCreate(evt *eventsystem.EventData)
- func HandleNewCommand(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
- func HandleUpdateCommand(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
- func KeyCommands(guildID int64) string
- func RegisterPlugin()
- func StringCommands(ccs []*CustomCommand) string
- type CommandTriggerType
- type CustomCommand
- type CustomCommandSlice
- type Plugin
Constants ¶
const ( MaxCommands = 100 MaxUserMessages = 20 )
Variables ¶
This section is empty.
Functions ¶
func CheckLimits ¶
func CheckMatch ¶
func CheckMatch(globalPrefix string, cmd *CustomCommand, msg string) (match bool, stripped string, args []string)
CheckMatch returns true if the given cmd matches, as well as the arguments following the command trigger (arg 0 being the message up to, and including, the trigger).
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 ExecuteCustomCommand ¶
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 HandleCommands ¶
func HandleCommands(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
func HandleDeleteCommand ¶
func HandleDeleteCommand(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
func HandleMessageCreate ¶
func HandleMessageCreate(evt *eventsystem.EventData)
func HandleNewCommand ¶
func HandleNewCommand(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
func HandleUpdateCommand ¶
func HandleUpdateCommand(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
func KeyCommands ¶
func RegisterPlugin ¶
func RegisterPlugin()
func StringCommands ¶
func StringCommands(ccs []*CustomCommand) string
Types ¶
type CommandTriggerType ¶
type CommandTriggerType int
const ( CommandTriggerCommand CommandTriggerType = iota CommandTriggerStartsWith CommandTriggerContains CommandTriggerRegex CommandTriggerExact )
func TriggerTypeFromForm ¶
func TriggerTypeFromForm(str string) CommandTriggerType
func (CommandTriggerType) String ¶
func (t CommandTriggerType) String() string
type CustomCommand ¶
type CustomCommand struct { TriggerType CommandTriggerType `json:"trigger_type"` TriggerTypeForm string `json:"-" schema:"type"` Trigger string `json:"trigger" schema:"trigger" valid:",1,1000"` // TODO: Retire the legacy Response field. Response string `json:"response,omitempty" schema:"response" valid:",3000"` Responses []string `json:"responses" schema:"responses" valid:",3000"` CaseSensitive bool `json:"case_sensitive" schema:"case_sensitive"` ID int `json:"id"` // If set, then the following channels are required, otherwise they are ignored RequireChannels bool `json:"require_channels" schema:"require_channels"` Channels []int64 `json:"channels" schema:"channels"` // If set, then one of the following channels are required, otherwise they are ignored RequireRoles bool `json:"require_roles" schema:"require_roles"` Roles []int64 `json:"roles" schema:"roles"` }
func FindCommands ¶
func FindCommands(ccs []*CustomCommand, data *dcmd.Data) (foundCCS []*CustomCommand, provided bool)
func GetCommands ¶
func (*CustomCommand) Migrate ¶ added in v0.29.1
func (cc *CustomCommand) Migrate() *CustomCommand
Migrate modifies a CustomCommand to remove legacy fields.
func (*CustomCommand) RunsForUser ¶
func (cc *CustomCommand) RunsForUser(m *discordgo.Member) bool
func (*CustomCommand) RunsInChannel ¶
func (cc *CustomCommand) RunsInChannel(channel int64) bool
type CustomCommandSlice ¶
type CustomCommandSlice []*CustomCommand
func (CustomCommandSlice) Len ¶
func (c CustomCommandSlice) Len() int
Len is the number of elements in the collection.
func (CustomCommandSlice) Less ¶
func (c CustomCommandSlice) Less(i, j int) bool
Less reports whether the element with index i should sort before the element with index j.
func (CustomCommandSlice) Swap ¶
func (c CustomCommandSlice) Swap(i, j int)
Swap swaps the elements with indexes i and j.