Documentation ¶
Overview ¶
Package route contains a command Route for Snart.
Index ¶
- Constants
- Variables
- type Cmd
- type CmdStore
- type Func
- type Prefix
- type PrefixStore
- func (p *PrefixStore) Del(g discord.GuildID)
- func (p *PrefixStore) ForLine(g discord.GuildID, me discord.User, mme *discord.Member, line string) (Prefix, bool)
- func (p *PrefixStore) Get(g discord.GuildID) (string, bool)
- func (p *PrefixStore) Load() error
- func (p *PrefixStore) Set(g discord.GuildID, pfxv string)
- func (p *PrefixStore) Store() error
- type Reply
- type Route
- type Trigger
Constants ¶
const GlobalGuildID = discord.NullGuildID
GlobalGuildID is the GuildID used for global configurations.
const KeyPrefix = "prefix"
KeyPrefix is the Confy key used to load/store prefixes.
Variables ¶
var ( // ErrCmdNotFound occurs when an unknown command is called. ErrCmdNotFound = errors.New("command not found") // ErrNoCmd occurs when there is no command after the prefix. ErrNoCmd = errors.New("no command") )
var ErrNoLinePrefix = errors.New("no prefix in line")
ErrNoLinePrefix occurs when a line doesn't start with a valid prefix.
Functions ¶
This section is empty.
Types ¶
type CmdStore ¶ added in v0.9.1
type CmdStore struct {
// contains filtered or unexported fields
}
CmdStore is a concurrent-safe store of Cmds.
func NewCmdStore ¶ added in v0.12.0
func NewCmdStore() *CmdStore
NewCmdStore creates a usable CmdStore.
func (*CmdStore) ByCat ¶ added in v0.12.0
ByCat creates a map of sorted Cmd categories, and a sorted list of category names.
If hidden is true, Cmds with the Hide flag will be included.
type PrefixStore ¶ added in v0.9.1
PrefixStore describes a concurrent-safe store of Guild-specific command prefixes.
func OpenPrefixStore ¶ added in v0.12.0
func OpenPrefixStore(c confy.Confy) (*PrefixStore, error)
OpenPrefixStore creates a usable PrefixStore and calls Load.
func (*PrefixStore) Del ¶ added in v0.12.0
func (p *PrefixStore) Del(g discord.GuildID)
Del removes the prefix for the given GuildID from the PrefixStore.
func (*PrefixStore) ForLine ¶ added in v0.13.0
func (p *PrefixStore) ForLine( g discord.GuildID, me discord.User, mme *discord.Member, line string, ) (Prefix, bool)
ForLine finds the first suitable prefix that matches the given line.
func (*PrefixStore) Get ¶ added in v0.12.0
func (p *PrefixStore) Get(g discord.GuildID) (string, bool)
Get allows looking up a Prefix by GuildID.
func (*PrefixStore) Load ¶ added in v0.12.0
func (p *PrefixStore) Load() error
Load updates the PrefixStore with data from the Confy.
func (*PrefixStore) Set ¶ added in v0.12.0
func (p *PrefixStore) Set(g discord.GuildID, pfxv string)
Set allows storing a prefix for a given GuildID.
func (*PrefixStore) Store ¶ added in v0.12.0
func (p *PrefixStore) Store() error
Store updates the Confy with data from the PrefixStore.
type Reply ¶
type Reply struct { api.SendMessageData Trigger *Trigger }
Reply wraps a message to be sent to a given ChannelID using a given Session.
type Route ¶
Route handles storing and looking up Cmds.
func (*Route) Handle ¶ added in v0.3.0
func (r *Route) Handle(m *gateway.MessageCreateEvent)
Handle is a MessageCreate handler function for the Route.
type Trigger ¶ added in v0.3.0
type Trigger struct { Route *Route Message discord.Message Prefix Prefix Command Cmd FlagSet *flag.FlagSet Args []string Flags interface{} Output *strings.Builder }
Trigger holds the context that triggered a Command.