31 lines
1.0 KiB
Go
31 lines
1.0 KiB
Go
|
package bolt
|
||
|
|
||
|
import "time"
|
||
|
|
||
|
type Command struct {
|
||
|
Trigger string //.command that triggers payload NOT including the '.'
|
||
|
Payload Payload //payload function to run when a command is detected
|
||
|
Timeout time.Duration //the amount of time before command can run again
|
||
|
LastRun time.Time //timestamp of last command run
|
||
|
Roles []string //roles that can use command
|
||
|
}
|
||
|
|
||
|
// payload function type handling commands. The returned error is parsed and, if no error,
|
||
|
// is detected then the response string (res) will be sent in response to the command message
|
||
|
type Payload func(msg Message) (res string, err error)
|
||
|
|
||
|
// contains the basic information needed for a message command
|
||
|
type Message struct {
|
||
|
Author Author
|
||
|
Words []string //words from message split on whitespace
|
||
|
Message string //entire message content
|
||
|
Channel string //channel message was sent in
|
||
|
Server string //guild message was sent in
|
||
|
}
|
||
|
|
||
|
// username and roles of message authors
|
||
|
type Author struct {
|
||
|
Username string
|
||
|
Roles []string
|
||
|
}
|