kommando

package module
v0.0.0-...-88fec0b Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

kommando

A wip discordgo command handler.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command interface {
	// Name returns the name of the command
	Name() string

	// Description returns the description of the command
	Description() string

	// Exec executes the command, pass the discordgo.Interaction
	Exec(ctx Context) (err error)
}

Command is an interface that all commands must implement

type Context

type Context interface {
	Responder

	Channel() (channel *discordgo.Channel, err error)

	Guild() (guild *discordgo.Guild, err error)

	User() (user *discordgo.User, err error)

	Options() []*discordgo.ApplicationCommandInteractionDataOption

	Command() Command

	SlashCommand() SlashCommand
}

Context holds our data from the interaction neatly in one object

type Ctx

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

func (*Ctx) Channel

func (c *Ctx) Channel() (channel *discordgo.Channel, err error)

func (*Ctx) Command

func (c *Ctx) Command() Command

func (*Ctx) GetEphemeral

func (r *Ctx) GetEphemeral() bool

func (*Ctx) GetEvent

func (r *Ctx) GetEvent() *discordgo.InteractionCreate

func (*Ctx) GetKommando

func (r *Ctx) GetKommando() *Kommando

func (*Ctx) GetSession

func (r *Ctx) GetSession() *discordgo.Session

func (*Ctx) Guild

func (c *Ctx) Guild() (guild *discordgo.Guild, err error)

func (*Ctx) Options

func (*Ctx) Respond

func (r *Ctx) Respond(res *discordgo.InteractionResponse) (err error)

func (*Ctx) RespondEmbed

func (r *Ctx) RespondEmbed(embed *discordgo.MessageEmbed) (err error)

func (*Ctx) RespondError

func (r *Ctx) RespondError(content, title string) (err error)

func (*Ctx) RespondMessage

func (r *Ctx) RespondMessage(content string) (err error)

func (*Ctx) SetEphemeral

func (r *Ctx) SetEphemeral(v bool)

func (*Ctx) SlashCommand

func (c *Ctx) SlashCommand() SlashCommand

func (*Ctx) User

func (c *Ctx) User() (user *discordgo.User, err error)

type EmbedColors

type EmbedColors struct {
	Default int

	Error int
}

type Kommando

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

func New

func New(s *discordgo.Session, options ...Options) (h *Kommando, err error)

func (*Kommando) RegisterCommands

func (c *Kommando) RegisterCommands(cmds ...Command) (err error)

func (*Kommando) UnregisterCommands

func (c *Kommando) UnregisterCommands()

type Options

type Options struct {
	State state.State

	CommandStore store.CommandStore

	EmbedColors EmbedColors

	OnSystemError  func(err error)
	OnCommandError func(ctx Context, err error)
}

type Responder

type Responder interface {
	Respond(r *discordgo.InteractionResponse) (err error)

	RespondMessage(content string) (err error)

	RespondEmbed(embed *discordgo.MessageEmbed) (err error)

	RespondError(content, title string) (err error)

	GetSession() *discordgo.Session

	GetEvent() *discordgo.InteractionCreate

	GetKommando() *Kommando

	GetEphemeral() bool

	SetEphemeral(v bool)
}

Responder handles responding and follow up messages

type SlashCommand

type SlashCommand interface {
	Command

	Version() string

	Options() []*discordgo.ApplicationCommandOption
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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