Documentation ¶
Index ¶
- Constants
- Variables
- func CheckLimits(in ...string) bool
- func CheckMatch(globalPrefix string, cmd *CustomCommand, msg string) (match bool, stripped string, args []string)
- func ExecuteCustomCommand(cmd *CustomCommand, cmdArgs []string, stripped string, s *discordgo.Session, ...) (resp string, tmplCtx *templates.Context, err 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 MaxCommandsForContext(ctx context.Context) int
- func RegisterPlugin()
- func StringCommands(ccs []*CustomCommand) string
- type CommandTriggerType
- type CustomCommand
- type CustomCommandSlice
- type Plugin
Constants ¶
View Source
const ( MaxCommands = 100 MaxCommandsPremium = 250 MaxUserMessages = 20 )
Variables ¶
View Source
var (
RegexCache *ccache.Cache
)
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 ExecuteCustomCommand ¶
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 MaxCommandsForContext ¶ added in v1.6.0
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 GetCommands(guild int64) ([]*CustomCommand, int, error)
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(ms *dstate.MemberState) bool
func (*CustomCommand) RunsInChannel ¶
func (cc *CustomCommand) RunsInChannel(channel int64) bool
func (*CustomCommand) Save ¶
func (cc *CustomCommand) Save(guildID int64) error
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.
Click to show internal directories.
Click to hide internal directories.