Documentation
¶
Overview ¶
Package route contains a command router for a Snart Bot.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Log = minori.GetLogger("route")
Log is the logger for the route package.
Functions ¶
Types ¶
type Ctx ¶
type Ctx struct {
Prefix string
CleanPrefix string
Session *dg.Session
Message *dg.Message
Flags *Flags
Route *Route
}
Ctx holds a command context.
type Flags ¶
Flags holds a FlagSet for a Ctx.
type Okay ¶
Okay is a function which checks if a Ctx should be used.
var GuildAdmin Okay = func(c *Ctx) bool { _f := "GuildAdmin" perm, err := c.Session.UserChannelPermissions(c.Message.Author.ID, c.Message.ChannelID) if err != nil { err = fmt.Errorf("perm: %w", err) Log.Error(_f, err) return false } return perm&(dg.PermissionAdministrator| dg.PermissionManageServer) > 0 }
GuildAdmin is an Okay that checks if the user has administrator privileges on the guild.
type Reply ¶
type Reply struct {
*dg.MessageSend
Session *dg.Session
ChannelID string
}
Reply wraps a message to be sent to a given ChannelID using a given Session.
type Route ¶
type Route struct {
Name string
Match string
Cat string
Desc string
Okay Okay
Func func(*Ctx) error
// contains filtered or unexported fields
}
Route is a command route.
Click to show internal directories.
Click to hide internal directories.