contract

package module
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2022 License: BSD-3-Clause Imports: 4 Imported by: 14

README

contract

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeInteractionHttpHandlerFunc added in v0.3.9

func MakeInteractionHttpHandlerFunc(f func(Interaction) (*Response, error)) http.HandlerFunc

func MakeJobHttpHandlerFunc added in v0.1.0

func MakeJobHttpHandlerFunc(f func(Job) (*Response, error)) http.HandlerFunc

func MakeRequestHttpHandlerFunc added in v0.1.0

func MakeRequestHttpHandlerFunc(f func(Request) (*Response, error)) http.HandlerFunc

Types

type ActionsRow added in v0.3.7

type ActionsRow struct {
	Buttons     []*Button     `json:"buttons,omitempty" yaml:"buttons,omitempty"`
	SelectMenus []*SelectMenu `json:"selectMenus,omitempty" yaml:"selectMenus,omitempty"`
	TextInputs  []*TextInput  `json:"textInputs,omitempty" yaml:"textInputs,omitempty"`
}

type Application added in v0.3.1

type Application struct {
	Id          string `json:"id,omitempty" yaml:"id,omitempty"`
	Name        string `json:"name,omitempty" yaml:"name,omitempty"`
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	Icon        string `json:"icon,omitempty" yaml:"icon,omitempty"`
	Owner       User   `json:"owner,omitempty" yaml:"owner,omitempty"`
}

type Button added in v0.3.7

type Button struct {
	Label    string         `json:"label" yaml:"label,omitempty"`
	Style    uint           `json:"style" yaml:"style,omitempty"`
	Disabled bool           `json:"disabled" yaml:"disabled,omitempty"`
	Emoji    ComponentEmoji `json:"emoji" yaml:"emoji,omitempty"`
	Url      string         `json:"url,omitempty" yaml:"url,omitempty"`
	CustomId string         `json:"customId,omitempty" yaml:"customId,omitempty"`
}

type ComponentEmoji added in v0.3.7

type ComponentEmoji struct {
	Id       string `json:"id,omitempty" yaml:"id,omitempty"`
	Name     string `json:"name,omitempty" yaml:"name,omitempty"`
	Animated bool   `json:"animated,omitempty" yaml:"animated,omitempty"`
}

type Components added in v0.3.7

type Components struct {
	ActionsRows []*ActionsRow `json:"actionsRows,omitempty" yaml:"actionsRows,omitempty"`
	Buttons     []*Button     `json:"buttons,omitempty" yaml:"buttons,omitempty"`
	SelectMenus []*SelectMenu `json:"selectMenus,omitempty" yaml:"selectMenus,omitempty"`
	TextInputs  []*TextInput  `json:"textInputs,omitempty" yaml:"textInputs,omitempty"`
}

type Embed

type Embed struct {
	Url          string        `json:"url,omitempty" yaml:"url,omitempty"`
	Title        string        `json:"title,omitempty" yaml:"title,omitempty"`
	Description  string        `json:"description,omitempty" yaml:"description,omitempty"`
	Timestamp    string        `json:"timestamp,omitempty" yaml:"timestamp,omitempty"`
	Color        int           `json:"color,omitempty" yaml:"color,omitempty"`
	Footer       *EmbedFooter  `json:"footer,omitempty" yaml:"footer,omitempty"`
	ImageUrl     string        `json:"imageUrl,omitempty" yaml:"imageUrl,omitempty"`
	ThumbnailUrl string        `json:"thumbnailUrl,omitempty" yaml:"thumbnailUrl,omitempty"`
	VideoUrl     string        `json:"videoUrl,omitempty" yaml:"videoUrl,omitempty"`
	Author       *EmbedAuthor  `json:"author,omitempty" yaml:"author,omitempty"`
	Fields       []*EmbedField `json:"fields,omitempty" yaml:"fields,omitempty"`
}

type EmbedAuthor

type EmbedAuthor struct {
	Url  string `json:"url,omitempty" yaml:"url,omitempty"`
	Name string `json:"name,omitempty" yaml:"name,omitempty"`
}

type EmbedField

type EmbedField struct {
	Name   string `json:"name,omitempty" yaml:"name,omitempty"`
	Value  string `json:"value,omitempty" yaml:"value,omitempty"`
	Inline bool   `json:"inline,omitempty" yaml:"inline,omitempty"`
}

type EmbedFooter

type EmbedFooter struct {
	Text    string `json:"text,omitempty" yaml:"text,omitempty"`
	IconUrl string `json:"iconUrl,omitempty" yaml:"iconUrl,omitempty"`
}

type Error added in v0.0.2

type Error struct {
	Message string `json:"message,omitempty" yaml:"message,omitempty"`
}

type File

type File struct {
	Name        string `json:"name,omitempty" yaml:"name,omitempty"`
	ContentType string `json:"contentType,omitempty" yaml:"contentType,omitempty"`
	Bytes       []byte `json:"bytes,omitempty" yaml:"bytes,omitempty"`
}

type Intent added in v0.3.3

type Intent struct {
	Id       string    `json:"id,omitempty" yaml:"id,omitempty"`
	ServerID string    `json:"serverId,omitempty" yaml:"serverId,omitempty"`
	Name     string    `json:"name,omitempty" yaml:"name,omitempty"`
	Regex    string    `json:"regex,omitempty" yaml:"regex,omitempty"`
	Mention  bool      `json:"mention,omitempty" yaml:"mention,omitempty"`
	Endpoint string    `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
	Help     string    `json:"help,omitempty" yaml:"help,omitempty"`
	Enabled  bool      `json:"enabled,omitempty" yaml:"enabled,omitempty"`
	Type     string    `json:"type,omitempty" yaml:"type,omitempty"`
	Response *Response `json:"response,omitempty" yaml:"response,omitempty"`
}

type Interaction added in v0.3.9

type Interaction struct {
	Identifier string   `json:"identifier,omitempty" yaml:"identifier,omitempty"`
	Source     string   `json:"source,omitempty" yaml:"source,omitempty"`
	MessageId  string   `json:"messageId,omitempty" yaml:"messageId,omitempty"`
	Bot        User     `json:"bot,omitempty" yaml:"bot,omitempty"`
	User       User     `json:"user,omitempty" yaml:"user,omitempty"`
	ChannelId  string   `json:"channelId,omitempty" yaml:"channelId,omitempty"`
	ServerId   string   `json:"serverId,omitempty" yaml:"serverId,omitempty"`
	IsDirect   bool     `json:"isDirect,omitempty" yaml:"isDirect,omitempty"`
	Values     []string `json:"values,omitempty" yaml:"values,omitempty"`
	Type       string   `json:"type,omitempty" yaml:"type,omitempty"`
}

type Job added in v0.0.4

type Job struct {
	Id          string   `json:"id,omitempty" yaml:"id,omitempty"`
	UserId      string   `json:"userId,omitempty" yaml:"userId,omitempty"`
	InstanceId  string   `json:"instanceId,omitempty" yaml:"instanceId,omitempty"`
	Source      string   `json:"source,omitempty" yaml:"source,omitempty"`
	Content     string   `json:"content,omitempty" yaml:"content,omitempty"`
	Endpoint    string   `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
	Destination string   `json:"destination,omitempty" yaml:"destination,omitempty"`
	Schedule    Schedule `json:"schedule,omitempty" yaml:"schedule,omitempty"`
	Enabled     bool     `json:"enabled,omitempty" yaml:"enabled,omitempty"`
	Created     int32    `json:"created,omitempty" yaml:"created,omitempty"`
}

type JwtClaims added in v0.3.5

type JwtClaims struct {
	jwt.StandardClaims
	ContextId string `json:"ctx,omitempty"`
	IntentId  string `json:"iid,omitempty"`
	AuthorId  string `json:"aid,omitempty"`
	ChannelId string `json:"cid,omitempty"`
	ServerId  string `json:"sid,omitempty"`
	Platform  string `json:"plt,omitempty"`
}

JwtClaims represents custom jwt claims for treediagram

func ParseJwtClaims added in v0.3.5

func ParseJwtClaims(tokenString string, secret []byte) (JwtClaims, error)

ParseJwtClaims parses claims from and validates a string token

func (JwtClaims) SignedTokenString added in v0.3.5

func (c JwtClaims) SignedTokenString(secret []byte) (string, error)

SignedTokenString generates a signed jwt token string

func (JwtClaims) Token added in v0.3.5

func (c JwtClaims) Token() *jwt.Token

Token provides access to the underlying jwt.Token

type Message

type Message struct {
	Content          string      `json:"content,omitempty" yaml:"content,omitempty"`
	Embed            *Embed      `json:"embed,omitempty" yaml:"embed,omitempty"`
	Reactions        []string    `json:"reactions,omitempty" yaml:"reactions,omitempty"`
	Files            []*File     `json:"files,omitempty" yaml:"files,omitempty"`
	Compontents      *Components `json:"components,omitempty" yaml:"components,omitempty"`
	Tts              bool        `json:"tts,omitempty" yaml:"tts,omitempty"`
	IsPrivateMessage bool        `json:"isPrivateMessage,omitempty" yaml:"isPrivateMessage,omitempty"`
	IsRedirect       bool        `json:"isRedirect,omitempty" yaml:"isRedirect,omitempty"`
	EditMessageId    string      `json:"editMessageId,omitempty" yaml:"editMessageId,omitempty"`
}

type Reaction added in v0.1.3

type Reaction struct {
	ChannelId string `json:"channelId,omitempty" yaml:"channelId,omitempty"`
	MessageId string `json:"messageId,omitempty" yaml:"messageId,omitempty"`
	EmojiId   string `json:"emojiId,omitempty" yaml:"emojiId,omitempty"`
}

type Request

type Request struct {
	Id          string              `json:"id,omitempty" yaml:"id,omitempty"`
	ContextId   string              `json:"contextId,omitempty" yaml:"contextId,omitempty"`
	IntentId    string              `json:"intentId,omitempty" yaml:"intentId,omitempty"`
	Source      string              `json:"source,omitempty" yaml:"source,omitempty"`
	Bot         User                `json:"bot,omitempty" yaml:"bot,omitempty"`
	Author      User                `json:"author,omitempty" yaml:"author,omitempty"`
	ChannelId   string              `json:"channelId,omitempty" yaml:"channelId,omitempty"`
	ServerId    string              `json:"serverId,omitempty" yaml:"serverId,omitempty"`
	Servers     []Server            `json:"servers,omitempty" yaml:"servers,omitempty"`
	Mentions    []User              `json:"mentions,omitempty" yaml:"mentions,omitempty"`
	Content     string              `json:"content,omitempty" yaml:"content,omitempty"`
	Application Application         `json:"application,omitempty" yaml:"application,omitempty"`
	QueryParams map[string][]string `json:"queryParams,omitempty"`
}

func (Request) JwtClaims added in v0.3.5

func (r Request) JwtClaims(expiresIn time.Duration) JwtClaims

JwtClaims returns jwt claims populated with values from request

func (Request) Server added in v0.2.0

func (r Request) Server() Server

Server returns the full server for the ServerId

type Response

type Response struct {
	Messages  []*Message  `json:"messages,omitempty" yaml:"messages,omitempty"`
	Reactions []*Reaction `json:"reactions,omitempty" yaml:"reactions,omitempty"`
	Jobs      []*Job      `json:"jobs,omitempty" yaml:"jobs,omitempty"`
}

func StringResponse added in v0.1.1

func StringResponse(content string) *Response

type Schedule added in v0.0.5

type Schedule struct {
	Minute     string `json:"minute,omitempty" yaml:"minute,omitempty"`
	Hour       string `json:"hour,omitempty" yaml:"hour,omitempty"`
	DayOfMonth string `json:"dayOfMonth,omitempty" yaml:"dayOfMonth,omitempty"`
	Month      string `json:"month,omitempty" yaml:"month,omitempty"`
	DayOfWeek  string `json:"dayOfWeek,omitempty" yaml:"dayOfWeek,omitempty"`
	Year       string `json:"year,omitempty" yaml:"year,omitempty"`
}

type SelectMenu added in v0.3.7

type SelectMenu struct {
	CustomId    string             `json:"customId,omitempty" yaml:"customId,omitempty"`
	Placeholder string             `json:"placeholder" yaml:"placeholder,omitempty"`
	MinValues   *int               `json:"minValues,omitempty" yaml:"minValues,omitempty"`
	MaxValues   int                `json:"maxValues,omitempty" yaml:"maxValues,omitempty"`
	Options     []SelectMenuOption `json:"options" yaml:"options,omitempty"`
	Disabled    bool               `json:"disabled" yaml:"disabled,omitempty"`
}

type SelectMenuOption added in v0.3.7

type SelectMenuOption struct {
	Label       string         `json:"label,omitempty" yaml:"label,omitempty"`
	Value       string         `json:"value" yaml:"value,omitempty"`
	Description string         `json:"description" yaml:"description,omitempty"`
	Emoji       ComponentEmoji `json:"emoji" yaml:"emoji,omitempty"`
	Default     bool           `json:"default" yaml:"default,omitempty"`
}

type Server

type Server struct {
	Id              string `json:"id,omitempty" yaml:"id,omitempty"`
	Name            string `json:"name,omitempty" yaml:"name,omitempty"`
	OwnerId         string `json:"ownerId,omitempty" yaml:"ownerId,omitempty"`
	Description     string `json:"description,omitempty" yaml:"description,omitempty"`
	UserCount       int32  `json:"userCount,omitempty" yaml:"userCount,omitempty"`
	IconUrl         string `json:"iconUrl,omitempty" yaml:"iconUrl,omitempty"`
	SystemChannelId string `json:"systemChannelId,omitempty" yaml:"systemChannelId,omitempty"`
}

type TextInput added in v0.3.7

type TextInput struct {
	CustomId    string `json:"customId" yaml:"customId,omitempty"`
	Label       string `json:"label" yaml:"label,omitempty"`
	Style       uint   `json:"style" yaml:"style,omitempty"`
	Placeholder string `json:"placeholder,omitempty" yaml:"placeholder,omitempty"`
	Value       string `json:"value,omitempty" yaml:"value,omitempty"`
	Required    bool   `json:"required,omitempty" yaml:"required,omitempty"`
	MinLength   int    `json:"minLength,omitempty" yaml:"minLength,omitempty"`
	MaxLength   int    `json:"maxLength,omitempty" yaml:"maxLength,omitempty"`
}

type User

type User struct {
	Id            string `json:"id,omitempty" yaml:"id,omitempty"`
	Name          string `json:"name,omitempty" yaml:"name,omitempty"`
	Discriminator string `json:"discriminator" yaml:"discriminator"`
}

Jump to

Keyboard shortcuts

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