command

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CmdStore []Command

Contains all slash commands for this bot

Functions

func GetCmdDefs

func GetCmdDefs() []*discordgo.ApplicationCommand

// GetCmdDefs return all slash command definitions.

func GetCmdHandler

func GetCmdHandler() map[string]Command

GetCmdHandler returns a map of command name to all their handler function.

func GetComponentHandler

func GetComponentHandler() map[string]HandlerFunc

GetComponentHandler returns a map of component ID and the handler function.

func Register

func Register(c Command)

Register registers a new slash command.

func RegisterCommands

func RegisterCommands(sess *discordgo.Session) (registeredCommands []*discordgo.ApplicationCommand)

RegisterCommands register an array of commands to a discord session. Returns a list of all the registered commands.

this function will panic if registration of a command fails.

func RemoveCommands

func RemoveCommands(sess *discordgo.Session, registeredCommands []*discordgo.ApplicationCommand)

RemoveCommands removes all registered slash commands from all servers the bot is in

Types

type Command

type Command struct {
	// // Name of the slash command
	// Name string
	// Command definition
	ApplicationCommand func() *discordgo.ApplicationCommand
	// Handler for handling slash command interactions. This function should edit an interaction response. Returns a log message, and error if any
	EditInteractionResponse HandlerFunc
	// Handler for handling slash command interactions. This function should send a direct interaction response. Returns a log message, and error if any
	InteractionRespond HandlerFunc
	// Handler for auto completion requests. Returns a log message, and error if any
	InteractionApplicationCommandAutocomplete HandlerFunc
	// Command components, with their handler
	Components []struct {
		// Custom component ID
		ComponentID string
		// Handler for component interactions
		ComponentHandler HandlerFunc
	}
}

type HandlerFunc

type HandlerFunc func(sess *discordgo.Session, i *discordgo.InteractionCreate) (successMsg string, err error)

A handler function type for slash commands

Jump to

Keyboard shortcuts

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