gumi

package module
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2021 License: MIT Imports: 9 Imported by: 7

README

gumi

DiscordGo command framework

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// RegexUserMention defines the regex a user mention has to match
	RegexUserMention = regexp.MustCompile("<@!?(\\d+)>")

	// RegexRoleMention defines the regex a role mention has to match
	RegexRoleMention = regexp.MustCompile("<@&(\\d+)>")

	// RegexChannelMention defines the regex a channel mention has to match
	RegexChannelMention = regexp.MustCompile("<#(\\d+)>")
)

Functions

This section is empty.

Types

type Argument added in v0.3.0

type Argument struct {
	Raw string
}

Argument represents a single argument

func (*Argument) AsBool added in v0.3.0

func (argument *Argument) AsBool() (bool, error)

AsBool parses the given argument into a boolean

func (*Argument) AsChannelMentionID added in v0.3.0

func (argument *Argument) AsChannelMentionID() string

AsChannelMentionID returns the ID of the mentioned channel or an empty string if it is no mention

func (*Argument) AsInt added in v0.3.0

func (argument *Argument) AsInt() (int, error)

AsInt parses the given argument into an int32

func (*Argument) AsInt64 added in v0.3.0

func (argument *Argument) AsInt64() (int64, error)

AsInt64 parses the given argument into an int64

func (*Argument) AsRoleMentionID added in v0.3.0

func (argument *Argument) AsRoleMentionID() string

AsRoleMentionID returns the ID of the mentioned role or an empty string if it is no mention

func (*Argument) AsUserMentionID added in v0.3.0

func (argument *Argument) AsUserMentionID() string

AsUserMentionID returns the ID of the mentioned user or an empty string if it is no mention

type Arguments added in v0.3.0

type Arguments struct {
	Raw       string
	Arguments []*Argument
}

Arguments represents arguments used in a command.

func ParseArguments added in v0.3.0

func ParseArguments(raw string) *Arguments

func (*Arguments) AsSingle added in v0.3.0

func (arguments *Arguments) AsSingle() *Argument

AsSingle parses the given arguments as a single one

func (*Arguments) Get added in v0.3.0

func (arguments *Arguments) Get(n int) *Argument

Get returns the n'th argument

func (*Arguments) Len added in v0.3.0

func (arguments *Arguments) Len() int

Len returns the length of the arguments

func (*Arguments) Remove added in v0.3.0

func (arguments *Arguments) Remove(n int)

Remove removes the n'th argument

type Command

type Command struct {
	Name        string
	Group       string
	Aliases     []string
	Description string
	Usage       string
	Example     string
	Flags       map[string]string
	GuildOnly   bool
	NSFW        bool
	AuthorOnly  bool
	Permissions int64
	RateLimiter *RateLimiter
	Exec        ExecutionHandler
}

type Ctx added in v0.3.0

type Ctx struct {
	Session *discordgo.Session
	Event   *discordgo.MessageCreate
	Args    *Arguments
	Router  *Router
	Command *Command
}

func (*Ctx) Reply added in v0.3.0

func (ctx *Ctx) Reply(text string) error

Reply responds with the given text message

func (*Ctx) ReplyEmbed added in v0.3.0

func (ctx *Ctx) ReplyEmbed(embed *discordgo.MessageEmbed) error

ReplyEmbed responds with the given embed message

func (*Ctx) ReplyTextEmbed added in v0.3.0

func (ctx *Ctx) ReplyTextEmbed(text string, embed *discordgo.MessageEmbed) error

ReplyTextEmbed responds with the given text and embed message

type ExecutionHandler added in v0.3.0

type ExecutionHandler func(*Ctx) error

ExecutionHandler represents a handler for a context execution

type RateLimiter added in v0.3.0

type RateLimiter struct {
	Cooldown time.Duration
	// contains filtered or unexported fields
}

func NewRateLimiter added in v0.3.0

func NewRateLimiter(cooldown time.Duration) *RateLimiter

func (*RateLimiter) Contains added in v0.3.0

func (r *RateLimiter) Contains(key string) bool

func (*RateLimiter) Expires added in v0.3.0

func (r *RateLimiter) Expires(key string) (time.Duration, error)

func (*RateLimiter) Set added in v0.3.0

func (r *RateLimiter) Set(key string)

type Router added in v0.3.0

type Router struct {
	Commands                map[string]*Command
	CaseSensitive           bool
	AuthorID                string
	Storage                 *Storage
	PrefixResolver          func(*discordgo.Session, *discordgo.MessageCreate) []string
	NotCommandCallback      func(*Ctx) error
	OnErrorCallback         func(*Ctx, error)
	OnRateLimitCallback     func(*Ctx) error
	OnNoPermissionsCallback func(*Ctx) error
	OnNSFWCallback          func(*Ctx) error
	OnExecuteCallback       func(*Ctx) error
	OnPanicCallBack         func(ctx *Ctx, recover interface{})
}

func Create added in v0.3.0

func Create(r *Router) *Router

func (*Router) Handler added in v0.3.0

func (r *Router) Handler() func(*discordgo.Session, *discordgo.MessageCreate)

func (*Router) Initialize added in v0.3.0

func (r *Router) Initialize(session *discordgo.Session)

func (*Router) RegisterCmd added in v0.3.0

func (r *Router) RegisterCmd(command *Command)

type Storage added in v0.4.0

type Storage struct {
	// contains filtered or unexported fields
}

Storage wraps a map[string]interface to provide thread safe access endpoints.

func (*Storage) Delete added in v0.4.0

func (s *Storage) Delete(key string)

Delete removes a key-value pair from the map.

func (*Storage) Get added in v0.4.0

func (s *Storage) Get(key string) (interface{}, bool)

Get tries to get a value from the map.

func (*Storage) MustGet added in v0.4.0

func (s *Storage) MustGet(key string) interface{}

MustGet wraps Get but only returns the value, if found, or nil otherwise.

func (*Storage) Set added in v0.4.0

func (s *Storage) Set(key string, val interface{})

Set sets a value to the map by key.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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