command

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: MIT Imports: 2 Imported by: 1

Documentation

Overview

Package command defines application commands and handlers for the bot.

Index

Constants

View Source
const Ephemeral = 1 << 6

Ephemeral flag used for event messages that should only be shown to the user.

Variables

This section is empty.

Functions

This section is empty.

Types

type Definition

type Definition struct {
	Name        string
	Description string
	Handler     Handler

	SubCommands []*Definition
	Options     []*discordgo.ApplicationCommandOption
}

Definition of a command providing all the details required to register and handle it.

func (Definition) Translate

func (c Definition) Translate() *discordgo.ApplicationCommand

Translate the Definition to the internal discordgo format.

type Dispatcher

type Dispatcher map[string]Handler

Dispatcher contains the set of handlers which it will Dispatch interactions to.

func (Dispatcher) Dispatch

func (d Dispatcher) Dispatch(event Event)

Dispatch an interaction, either to a top level command, or a bottom level sub command.

func (Dispatcher) Register

func (d Dispatcher) Register(definition *Definition)

Register a command definition with the dispatcher.

type Event

type Event struct {
	Session     *discordgo.Session
	Interaction *discordgo.InteractionCreate
	// contains filtered or unexported fields
}

Event from Discord.

func (Event) Command

func (e Event) Command() string

Command at the end of the command set.

func (*Event) Commands

func (e *Event) Commands() []string

Commands issued to get to this event. There will always be at least 1 command in the returned list.

func (Event) Respond

func (e Event) Respond(response *discordgo.InteractionResponse)

Respond to an event.

func (Event) User added in v0.0.9

func (e Event) User() string

User ID of the user who initiated this command.

type Handler

type Handler func(event Event) error

Handler for a command.

Jump to

Keyboard shortcuts

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