Safe Haskell | None |
---|---|
Language | Haskell2010 |
Calamity commands This module only exports the DSL and core types for using commands
Synopsis
- module Calamity.Commands.Dsl
- module Calamity.Commands.Error
- module Calamity.Commands.Handler
- module Calamity.Commands.Utils
- module Calamity.Commands.ParsePrefix
- module Calamity.Commands.Parser
- module Calamity.Commands.Help
- data Context
Documentation
module Calamity.Commands.Dsl
module Calamity.Commands.Error
module Calamity.Commands.Handler
module Calamity.Commands.Utils
module Calamity.Commands.Parser
module Calamity.Commands.Help
Invokation context for commands
Instances
Commands
This module provides abstractions for writing declarative commands, that support grouping, pre-invokation checks, and automatic argument parsing by using a type level list of parameter types.
A DSL is provided in Dsl
for constructing commands
declaratively.
You can implement Parser
for your own types to allow them to be used in the
parameter list of commands.
A default help command is provided in Help
which can be
added just by using helpCommand
inside the command declaration DSL.
Custom Events
the event handler registered by addCommands
will fire the following custom events:
"command-error" (
Context
,CommandError
)Fired when a command returns an error.
"command-not-found" [
Text
]Fired when a valid prefix is used, but the command is not found.
"command-invoked"
Context
Fired when a command is successfully invoked.
Registered Metrics
Counter:
"commands_invoked" [name]
Incremented on each command invokation, the parameter
name
is the path/name of the invoked command.
Examples
An example of using commands:
addCommands
$ dohelpCommand
command
@'[User
] "utest" $ ctx u -> dovoid
$tell
ctx $ "got user: "<>
showtl
ugroup
"admin" $ docommand
@'[] "bye" $ ctx -> dovoid
$tell
ctx "bye!"stopBot