dgc

package
v0.0.0-...-e6be692 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InteractionResponseEphemeral uint64 = 1 << 6

Functions

func DefaultErrorHandler

func DefaultErrorHandler(err error, s *discordgo.Session, i *discordgo.InteractionCreate) error

DefaultErrorHandler is the default command error handler

func GetUser

GetUser returns the user that created the interaction either in a DM or guild

func Responded

Responded checks if the current interaction has been responded to

Types

type Command

type Command struct {
	Name        string
	Description string
	Options     []*discordgo.ApplicationCommandOption

	Run func(s *discordgo.Session, i *discordgo.InteractionCreate) error
}

Command represents a Discord slash command

type Commander

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

Commander represents Discord slash commands

func NewCommander

func NewCommander() *Commander

NewCommander returns a new command collection

func (*Commander) AddCommand

func (m *Commander) AddCommand(c *Command)

AddCommand adds a new slash command

func (*Commander) Handler

Handler handles interaction create events from Discord

func (*Commander) Install

func (m *Commander) Install(s *discordgo.Session, guild string) error

Install creates the commands in given guild. If guild is empty, it will install the commands globally.

func (*Commander) OnError

func (m *Commander) OnError(h ErrorHandler)

OnError sets the error handler when an error is returned from a command

func (*Commander) Uninstall

func (m *Commander) Uninstall(s *discordgo.Session, guild string) error

Uninstall removes the commands in given guild. If guild is empty, it will remove the commands globally.

type ErrorHandler

type ErrorHandler func(error, *discordgo.Session, *discordgo.InteractionCreate) error

ErrorHandler represents an error handler function

Jump to

Keyboard shortcuts

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