Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BehaviourSettings ¶
type BehaviourSettings struct { // DeleteMessageSuccess represents whether the bot should delete commands // upon success of finding and/or executing it. DeleteMessageSuccess bool // DeleteMessageUnknown represents whether the bot should delete any commands with // the correct prefix, even when it doesn't know what command it is. DeleteMessageUnknown bool // ReactMessageUnknown represents whether the bot should react to commands it does not recognise. ReactMessageUnknown string // HandleTts represents whether or not it should respond to TTS. HandleTts bool }
BehaviourSettings represent settings related to how the bot should behave.
type Command ¶
type Command struct { // Handler represents the function that will handle the command. Handler func(context *CommandContext) // Names represent the name and aliases this command can be used with. // // Names[0] is the main name, while the rest are counted as aliases. // If there is no name upon registration, this will produce an error. Names []string // Predicates represent the different conditions that are required the be fullfilled // before the command will be executed as usual. Predicates []func(context *CommandContext) bool }
Command represents a command used within Discord.
If the prefix is "!", then "!h" and "!help" would require: ```go
Command { Handler: func(context *CommandContext) { context.DoStuff() }, Names: []string{"h", "help"}, }
```
type CommandContext ¶
type CommandContext struct { // Implementation represents the implementation of the command. // // This can be used to get the inner instance of the command, should it be needed. Implementation *Command // Event represents the event of the message itself. Event *discordgo.MessageCreate // Session represents the session instance of the bot. Session *discordgo.Session // Label represents the label used to execute the command, of the registered names. Label string }
CommandContext represents the context of the command execution.
This is handed to the command's handler.
type CommandManager ¶
type CommandManager struct { Prefix string Commands []Command Behaviour BehaviourSettings }
func CreateManager ¶
func CreateManager() CommandManager
func (*CommandManager) AddCommand ¶
func (manager *CommandManager) AddCommand(commands ...Command)
func (*CommandManager) ChatListener ¶
func (manager *CommandManager) ChatListener(session *discordgo.Session, event *discordgo.MessageCreate)
Click to show internal directories.
Click to hide internal directories.