handler

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: Apache-2.0 Imports: 6 Imported by: 3

README

Go Reference Go Report Go Version License Handler Version Discord

Handler

Handler is a simple Application Command, Component and Modal handler library for DisGo.

Getting Started

Installing
go get github.com/disgoorg/handler
Usage

See the example here.

Documentation

Documentation is wip and can be found under

  • Go Reference

Troubleshooting

For help feel free to open an issue or reach out on Discord

Contributing

Contributions are welcomed but for bigger changes we recommend first reaching out via Discord or create an issue to discuss your problems, intentions and ideas.

License

Distributed under the License. See LICENSE for more information.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutocompleteHandler

type AutocompleteHandler func(event *events.AutocompleteInteractionCreate) error

type Check added in v0.2.0

type Check[T any] func(ctx T) bool

func CheckAllOf added in v0.2.0

func CheckAllOf[T any](checks ...Check[T]) Check[T]

func CheckAnyOf added in v0.2.0

func CheckAnyOf[T any](checks ...Check[T]) Check[T]

func (Check[T]) And added in v0.2.0

func (c Check[T]) And(check Check[T]) Check[T]

func (Check[T]) Or added in v0.2.0

func (c Check[T]) Or(check Check[T]) Check[T]

type Command

type Command struct {
	Create               discord.ApplicationCommandCreate
	Check                Check[*events.ApplicationCommandInteractionCreate]
	AutocompleteCheck    Check[*events.AutocompleteInteractionCreate]
	CommandHandlers      map[string]CommandHandler
	AutocompleteHandlers map[string]AutocompleteHandler
}

type CommandHandler

type CommandHandler func(event *events.ApplicationCommandInteractionCreate) error

type Component

type Component struct {
	Name    string
	Check   Check[*events.ComponentInteractionCreate]
	Handler ComponentHandler
}

type ComponentHandler

type ComponentHandler func(event *events.ComponentInteractionCreate) error

type Handler

type Handler struct {
	Logger log.Logger

	Commands   map[string]Command
	Components map[string]Component
	Modals     map[string]Modal
}

func New

func New(logger log.Logger) *Handler

func (*Handler) AddCommands

func (h *Handler) AddCommands(commands ...Command)

func (*Handler) AddComponents

func (h *Handler) AddComponents(components ...Component)

func (*Handler) AddModals

func (h *Handler) AddModals(modals ...Modal)

func (*Handler) OnEvent

func (h *Handler) OnEvent(event bot.Event)

func (*Handler) SyncCommands

func (h *Handler) SyncCommands(client bot.Client, guildIDs ...snowflake.ID)
type Modal struct {
	Name    string
	Check   Check[*events.ModalSubmitInteractionCreate]
	Handler ModalHandler
}

type ModalHandler

type ModalHandler func(event *events.ModalSubmitInteractionCreate) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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