# README
crouter
A simple command handler for discordgo.
Usage
import "github.com/Starshine113/crouter"
// ... session initialisation code ...
// create the router
r := crouter.NewRouter(dg, []string{botOwner}, []string{"?", "!"})
// add the message create handler
dg.AddHandler(r.MessageCreate)
// add a command
r.AddCommand(&crouter.Command{
Name: "Ping",
Summary: "Check if the bot is running",
Command: func(ctx *crouter.Ctx) (err error) {
ping := ctx.Session.HeartbeatLatency().Round(time.Millisecond)
_, err = ctx.Sendf("Ping! Average latency: %s", ping)
return err
},
})
// add intents (or just add crouter.RequiredIntents to your existing intents)
dg.Identify.Intents = discordgo.MakeIntent(crouter.RequiredIntents)
// open the session
err = dg.Open()
// ...
A more complete example can be found in the example/
directory.
# Packages
No description provided by the author
# Functions
HasAnyPrefix checks if the string has *any* of the given prefixes.
HasAnySuffix checks if the string has *any* of the given suffixes.
NewPermCache returns a new initialised permission cache.
NewRouter creates a Router object.
PermToString turns a discordgo permission constant into a string.
PrettyDurationString turns a duration into a string representation (maximum of days).
SprintfAll takes a slice of strings and uses them as input for Sprintf, returning a slice of strings.
TrimPrefixesSpace trims all given prefixes as well as whitespace from the given string.
Version returns the current crouter version.
# Constants
ErrorEmoji is the emoji used for errors.
RequiredIntents are the intents required for the router.
SuccessEmoji is the emoji used to designate a successful action.
WarnEmoji is the emoji used to warn that a command failed.
# Variables
ErrBotMissingPerms is returned when the bot is missing permissions required to send a message.
Errors for parsing.
Errors for parsing.
Errors for parsing.
Errors for parsing.
Errors relating to missing permissions.
Errors relating to missing permissions.
Errors when creating Context.
Errors relating to missing permissions.
Errors.
Errors.
ErrorUnknownType is returned when an unknown type argument is passed to Send.
Errors for parsing.