Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Verify reports whether sig is a valid signature of message by publicKey. It Verify = func(publicKey PublicKey, message []byte, sig []byte) bool { return ed25519.Verify(publicKey, message, sig) } // SignatureSize is the size, in bytes, of signatures generated and verified by this package. SignatureSize = ed25519.SignatureSize )
Functions ¶
func HandleInteraction ¶ added in v0.13.10
func HandleInteraction(publicKey PublicKey, logger log.Logger, handleFunc EventHandlerFunc) http.HandlerFunc
HandleInteraction handles an interaction from Discord's Outgoing Webhooks. It verifies and parses the interaction and then calls the passed EventHandlerFunc.
func VerifyRequest ¶
VerifyRequest implements the verification side of the discord interactions api signing algorithm, as documented here: https://discord.com/developers/docs/interactions/slash-commands#security-and-authorization Credit: https://github.com/bsdlp/discord-interactions-go/blob/main/interactions/verify.go
Types ¶
type Config ¶
type Config struct { Logger log.Logger HTTPServer *http.Server ServeMux *http.ServeMux URL string Address string CertFile string KeyFile string }
Config lets you configure your Server instance.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a Config with sensible defaults.
type ConfigOpt ¶
type ConfigOpt func(config *Config)
ConfigOpt is a type alias for a function that takes a Config and is used to configure your Server.
func WithAddress ¶
WithAddress sets the Address of the Config.
func WithHTTPServer ¶
WithHTTPServer sets the http.Server of the Config.
func WithLogger ¶
WithLogger sets the Logger of the Config.
func WithServeMux ¶
WithServeMux sets the http.ServeMux of the Config.
type EventHandlerFunc ¶
type EventHandlerFunc func(responseFunc RespondFunc, event EventInteractionCreate)
EventHandlerFunc is used to handle events from Discord's Outgoing Webhooks
type EventInteractionCreate ¶ added in v0.13.10
type EventInteractionCreate struct {
discord.Interaction
}
EventInteractionCreate is the event payload when an interaction is created via Discord's Outgoing Webhooks
func (*EventInteractionCreate) UnmarshalJSON ¶ added in v0.13.10
func (e *EventInteractionCreate) UnmarshalJSON(data []byte) error
type RespondFunc ¶ added in v0.8.9
type RespondFunc func(response discord.InteractionResponse) error
RespondFunc is used to respond to Discord's Outgoing Webhooks