Skip to content
This repository has been archived by the owner on Nov 26, 2021. It is now read-only.

starshine-sys/crouter

Repository files navigation

This is outdated! You shouldn't use it--if you desperately wanna use our spaghetti, try bcr

crouter

Go Reference

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.

About

Simple command handler/router for discordgo

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages