interactions

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: May 17, 2023 License: MIT Imports: 12 Imported by: 0

README

Postcord Interactions

Go Reference

Interactions is a simple, batteries included HTTP interactions library for Discord. It is designed to make is fast and easy to create a new Discord server integration using Discords new interactions system.

Getting Started

Add Interactions to your project

go get -u github.com/kelwing/wumpgo/interactions

Command Routing

If you're looking for a more batteries included solution that includes command and interaction routing. Check out our router package.

Documentation

Documentation is still a work in progress.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FailUnknownError

func FailUnknownError(w http.ResponseWriter, jr *json.Encoder)

Types

type App

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

App is the primary interactions server

func New

func New(publicKey string, opts ...InteractionOption) (*App, error)

Create a new interactions server instance

func (*App) AutocompleteHandler

func (a *App) AutocompleteHandler(handler HandlerFunc)

func (*App) CommandHandler

func (a *App) CommandHandler(handler HandlerFunc)

CommandHandler sets the function to handle slash command events

func (*App) ComponentHandler

func (a *App) ComponentHandler(handler HandlerFunc)

ComponentHandler sets the function to handle Component events.

func (*App) HTTPHandler

func (a *App) HTTPHandler() http.HandlerFunc

HTTPHandler exposes a net/http handler to process incoming interactions

func (*App) ModalHandler

func (a *App) ModalHandler(handler HandlerFunc)

func (*App) ProcessRequest

func (a *App) ProcessRequest(ctx context.Context, data []byte) (resp *objects.InteractionResponse, err error)

ProcessRequest is used internally to process a validated request. It is exposed to allow users to tied Postcord in with any web framework of their choosing. Ensure you only pass validated requests.

func (*App) Rest

func (a *App) Rest() rest.RESTClient

Rest exposes the internal Rest client so you can make calls to the Discord API

func (*App) ServeHTTP

func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP makes App implement the http.Handler interface

type InteractionOption

type InteractionOption func(*App)

func WithClient

func WithClient(c rest.RESTClient) InteractionOption

func WithLogger

func WithLogger(l zerolog.Logger) InteractionOption

Jump to

Keyboard shortcuts

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