Documentation ¶
Index ¶
- Constants
- func Start(opts ...ServerOption)
- func WriteJSON(w http.ResponseWriter, status int, v interface{})
- type AllowedMentions
- type Authenticator
- type Authorizer
- type Embed
- type ErrorResponse
- type InteractionApplicationCommandCallbackData
- type InteractionResponse
- type InteractionResponseType
- type InteractionType
- type Server
- func (s *Server) Err(w http.ResponseWriter, r *http.Request, status int, err error)
- func (s *Server) ErrInternal(w http.ResponseWriter, r *http.Request, err error)
- func (s *Server) Handler() http.Handler
- func (s *Server) IsValid() error
- func (s *Server) Middleware(next http.Handler) http.Handler
- func (s *Server) Set(opts ...ServerOption)
- type ServerOption
- type WhitelistGetter
- type Whitelister
Constants ¶
const ( Ping = 1 ApplicationCommand = 2 )
InteractionTypes https://discord.com/developers/docs/interactions/slash-commands#interaction-interactiontype
Variables ¶
This section is empty.
Functions ¶
func WriteJSON ¶
func WriteJSON(w http.ResponseWriter, status int, v interface{})
WriteJSON marshals the object provided as json and writes it to the http.ResponseWriter
Types ¶
type AllowedMentions ¶
type AllowedMentions struct { }
AllowedMentions ... https://discord.com/developers/docs/resources/channel#embed-object-embed-structure
type Authenticator ¶
Authenticator of http requests
type Authorizer ¶
Authorizer of http requests
type Embed ¶
type Embed struct { }
Embed ... https://discord.com/developers/docs/resources/channel#embed-object-embed-structure
type ErrorResponse ¶
type ErrorResponse struct { Error string `json:"error"` Request logRequest `json:"request"` }
ErrorResponse is the standard http error response
func NewErrorResponse ¶
func NewErrorResponse(r *http.Request, err error) ErrorResponse
NewErrorResponse ..
type InteractionApplicationCommandCallbackData ¶
type InteractionApplicationCommandCallbackData struct { TTS *bool `json:"tts,omitempty"` // is the response TTS Content string `json:"content"` // message content Embeds []Embed `json:"embeds,omitempty"` // supports up to 10 embeds AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"` // allowed mentions object }
InteractionApplicationCommandCallbackData ... https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionapplicationcommandcallbackdata
type InteractionResponse ¶
type InteractionResponse struct { Type InteractionResponseType `json:"type"` Data *InteractionApplicationCommandCallbackData `json:"data,omitempty"` }
InteractionResponse ... https://discord.com/developers/docs/interactions/slash-commands#interaction-response
type InteractionResponseType ¶
type InteractionResponseType int
InteractionResponseType ...
const ( // ACK a Ping Pong InteractionResponseType = 1 // ACK a command without sending a message, eating the user's input Acknowledge InteractionResponseType = 2 // respond with a message, eating the user's input ChannelMessage InteractionResponseType = 3 // respond with a message, showing the user's input ChannelMessageWithSource InteractionResponseType = 4 // ACK a command without sending a message, showing the user's input AcknowledgeWithSource InteractionResponseType = 5 )
Discord InteractionResponseTypes https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionresponsetype
type Server ¶
type Server struct { Authorizer Authenticator WhitelistGetter WhitelistGetter // contains filtered or unexported fields }
Server of the apps
func (*Server) ErrInternal ¶
ErrInternal handles internal server error
func (*Server) Middleware ¶
Middleware is the apps main middleware.
type ServerOption ¶
type ServerOption func(*Server)
ServerOption is an option server parameter
func WithDiscordPublicKey ¶
func WithDiscordPublicKey(key string) (ServerOption, error)
WithDiscordPublicKey is a ServerOption
func WithWhitelist ¶
func WithWhitelist(w Whitelister) ServerOption
WithWhitelist add a whitelist.json file path the server
type WhitelistGetter ¶
WhitelistGetter gets users in a whitelist
type Whitelister ¶
type Whitelister interface { WhitelistGetter }
Whitelister is a wrapper interface for managing whitelist