gumi

package module
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2020 License: MIT Imports: 6 Imported by: 7

README

gumi

DiscordGo command framework

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Name        string
	Aliases     []string
	Description string
	GuildOnly   bool
	NSFW        bool
	Exec        GumiExec
	Help        *HelpSettings
}

func NewCommand

func NewCommand(name string, exec GumiExec, opts ...CommandOption) *Command

type CommandOption

type CommandOption func(*Command)

func CommandDescription

func CommandDescription(desc string) CommandOption

func GuildOnly

func GuildOnly() CommandOption

func WithAliases

func WithAliases(aliases ...string) CommandOption

func WithHelp

func WithHelp(hs *HelpSettings) CommandOption

type ErrorHandler

type ErrorHandler func(e error) *discordgo.MessageSend

ErrorHandler is a function that handles all errors caused by user commands, if nil uses default.

type Group

type Group struct {
	Name        string
	Description string
	NSFW        bool
	Commands    map[string]*Command
	IsVisible   bool
}

func (*Group) AddCommand

func (g *Group) AddCommand(name string, exec GumiExec, opts ...CommandOption) *Command

type GroupOption

type GroupOption func(*Group)

func GroupDescription

func GroupDescription(desc string) GroupOption

func GroupNSFW

func GroupNSFW() GroupOption

type Gumi

type Gumi struct {
	Groups map[string]*Group
	//UngroupedCommands map[string]*GumiCommand
	DefaultPrefixes []string
	HelpCommand     HelpHandler
	ErrorHandler    ErrorHandler
	PrefixHandler   PrefixResolver
}

Gumi is a command framework for DiscordGo

func NewGumi

func NewGumi(opts ...Option) *Gumi

NewGumi creates a new Gumi instance

func (*Gumi) AddGroup

func (g *Gumi) AddGroup(name string, opts ...GroupOption) *Group

AddGroup creates a new group with given name and parameters. Please don't directly modify it, use functions instead.

func (*Gumi) GeneralGroup

func (g *Gumi) GeneralGroup() *Group

GeneralGroup returns a group autogenerated for help command and should be used for general-purpose commands. Although, you can modify it for your needs.

func (*Gumi) Handle

func (g *Gumi) Handle(s *discordgo.Session, m *discordgo.MessageCreate)

Handle invokes a command handler for Gumi instance, should be called from within MessageCreate event in discordgo application.

func (*Gumi) SetErrorHandler

func (g *Gumi) SetErrorHandler(eh ErrorHandler) *Gumi

SetErrorHandler sets an ErrorHandler for Gumi instance

func (*Gumi) SetHelpCommand

func (g *Gumi) SetHelpCommand(hc HelpHandler) *Gumi

SetHelpCommand sets a HelpHandler for Gumi instance

func (*Gumi) SetPrefixHandler

func (g *Gumi) SetPrefixHandler(ph PrefixResolver) *Gumi

SetPrefixHandler sets a PrefixHandler for GumiInstance

type GumiExec

type GumiExec func(*discordgo.Session, *discordgo.MessageCreate, []string) error

type HelpHandler

HelpHandler ...

type HelpSettings

type HelpSettings struct {
	IsVisible    bool
	ExtendedHelp []*discordgo.MessageEmbedField
}

HelpSettings are settings needed for default help command.

func NewHelpSettings

func NewHelpSettings() *HelpSettings

func (*HelpSettings) AddField

func (hs *HelpSettings) AddField(name, value string, inline bool) *HelpSettings

type Option

type Option func(*Gumi)

Option is a type alias for optional functions

func WithErrorHandler

func WithErrorHandler(eh ErrorHandler) Option

func WithHelpHandler

func WithHelpHandler(hh HelpHandler) Option

func WithPrefixResolver

func WithPrefixResolver(pr PrefixResolver) Option

func WithPrefixes

func WithPrefixes(prefixes ...string) Option

type PrefixResolver

type PrefixResolver func(*Gumi, *discordgo.Session, *discordgo.MessageCreate) []string

PrefixResolver ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL