commands

package
v0.0.0-...-761d34b Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 3 Imported by: 0

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
	Options     []Option
	Callback    CommandCallback
}

type CommandCallback

type CommandCallback func(*Context)

type Commands

type Commands struct {
	Config      Config
	Handler     Handler
	Prefix      PrefixGetter
	GlobalCheck GlobalCheck
	Commands    []*Command
	API         *regolt.API
	Socket      *regolt.Socket
	// contains filtered or unexported fields
}

func New

func New(api *regolt.API, socket *regolt.Socket, config Config) *Commands

func (*Commands) Handle

func (c *Commands) Handle(ctx *Context)

func (*Commands) Install

func (c *Commands) Install() *Commands

func (*Commands) InstallSelfBot

func (c *Commands) InstallSelfBot() error

type Config

type Config struct {
	GlobalCheck  GlobalCheck
	Handler      Handler
	Commands     []*Command
	Prefixes     []string
	Prefix       string
	PrefixGetter PrefixGetter
}

type Context

type Context struct {
	LightContext
	Command *Command
	Prefix  string
	Scanner *Scanner
	Label   string
	Options map[string]any
}

func (*Context) Integer

func (ctx *Context) Integer(name string, defaultValue ...int64) int64

func (*Context) String

func (ctx *Context) String(name string, defaultValue ...string) string

func (*Context) Uinteger

func (ctx *Context) Uinteger(name string, defaultValue ...uint64) uint64

type DisallowedEscape

type DisallowedEscape struct {
	Which string
}

func (DisallowedEscape) Error

func (de DisallowedEscape) Error() string

type GlobalCheck

type GlobalCheck func(*LightContext) bool

type Greedy

type Greedy struct {
	Option Option
}

func (Greedy) GetDescription

func (g Greedy) GetDescription() string

func (Greedy) GetName

func (g Greedy) GetName() string

func (Greedy) Parse

func (g Greedy) Parse(ctx *Context) (any, error)

type Handler

type Handler interface {
	HandleCommand(*Context)
}

type LightContext

type LightContext struct {
	Manager *Commands
	Message *regolt.Message
}

func (*LightContext) ReactWith

func (ctx *LightContext) ReactWith(s string) error

func (*LightContext) Respond

func (ctx *LightContext) Respond(sm *regolt.SendMessage) (*regolt.Message, error)

type Option

type Option interface {
	GetName() string
	GetDescription() string
	Parse(*Context) (any, error)
}

type OptionRequired

type OptionRequired struct {
	Name string
}

func (OptionRequired) Error

func (opt OptionRequired) Error() string

type PrefixGetter

type PrefixGetter func(*LightContext) []string

type Scanner

type Scanner struct {
	Manager  *Commands
	Position int
	Target   string
}

func (*Scanner) Back

func (s *Scanner) Back()

func (*Scanner) CanNext

func (s *Scanner) CanNext() bool

func (*Scanner) GetByte

func (s *Scanner) GetByte() (byte, bool)

func (*Scanner) Transaction

func (s *Scanner) Transaction(f func(s *Scanner) bool)

type SignedIntOption

type SignedIntOption struct {
	Name        string
	Description string
	Base        int
	BitSize     int
	Required    bool
}

func (SignedIntOption) GetDescription

func (o SignedIntOption) GetDescription() string

func (SignedIntOption) GetName

func (o SignedIntOption) GetName() string

func (SignedIntOption) Parse

func (sio SignedIntOption) Parse(ctx *Context) (any, error)

type StringOption

type StringOption struct {
	Name             string
	Description      string
	DisallowNewlines bool
	Raw              bool
	Required         bool
}

func (StringOption) GetDescription

func (o StringOption) GetDescription() string

func (StringOption) GetName

func (o StringOption) GetName() string

func (StringOption) Parse

func (so StringOption) Parse(ctx *Context) (any, error)

type UnsignedIntOption

type UnsignedIntOption struct {
	Name        string
	Description string
	Base        int
	BitSize     int
	Required    bool
}

func (UnsignedIntOption) GetDescription

func (o UnsignedIntOption) GetDescription() string

func (UnsignedIntOption) GetName

func (o UnsignedIntOption) GetName() string

func (UnsignedIntOption) Parse

func (uio UnsignedIntOption) Parse(ctx *Context) (any, error)

Jump to

Keyboard shortcuts

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