jsonapi

package
v23.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Err = errors.New("error response")

Err is the error that is wrapped and returned when there is a non-200 api response

Functions

This section is empty.

Types

type DiscordJSONClient

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

func NewDiscordJSONClient

func NewDiscordJSONClient(deps dependencies, apiURL string) *DiscordJSONClient

func (*DiscordJSONClient) BulkOverwriteGlobalCommands

func (d *DiscordJSONClient) BulkOverwriteGlobalCommands(ctx context.Context, aid string, cmds []entity.ApplicationCommand) (resCmds []entity.ApplicationCommand, err error)

func (*DiscordJSONClient) BulkOverwriteGuildCommandPermissions added in v23.2.0

func (d *DiscordJSONClient) BulkOverwriteGuildCommandPermissions(ctx context.Context, aid string, gid snowflake.Snowflake, perms []entity.ApplicationCommandPermissions) (resPerms []entity.ApplicationCommandPermissions, err error)

func (*DiscordJSONClient) BulkOverwriteGuildCommands

func (d *DiscordJSONClient) BulkOverwriteGuildCommands(ctx context.Context, aid string, gid snowflake.Snowflake, cmds []entity.ApplicationCommand) (resCmds []entity.ApplicationCommand, err error)

func (*DiscordJSONClient) CreateReaction

func (d *DiscordJSONClient) CreateReaction(ctx context.Context, cid, mid snowflake.Snowflake, emoji string) (resp *http.Response, err error)

func (*DiscordJSONClient) DeferInteractionResponse added in v23.5.0

func (d *DiscordJSONClient) DeferInteractionResponse(ctx context.Context, ixID snowflake.Snowflake, ixToken string) error

func (*DiscordJSONClient) GetGateway

func (d *DiscordJSONClient) GetGateway(ctx context.Context) (entity.Gateway, error)

func (*DiscordJSONClient) GetGlobalCommands

func (d *DiscordJSONClient) GetGlobalCommands(ctx context.Context, aid string) (cmds []entity.ApplicationCommand, err error)

func (*DiscordJSONClient) GetGuildCommands

func (d *DiscordJSONClient) GetGuildCommands(ctx context.Context, aid string, gid snowflake.Snowflake) (cmds []entity.ApplicationCommand, err error)

func (*DiscordJSONClient) GetGuildMember

func (d *DiscordJSONClient) GetGuildMember(ctx context.Context, gid, uid snowflake.Snowflake) (respData entity.GuildMember, err error)

func (*DiscordJSONClient) GetInteractionResponse

func (d *DiscordJSONClient) GetInteractionResponse(ctx context.Context, aid snowflake.Snowflake, ixToken string) (respData entity.Message, err error)

func (*DiscordJSONClient) GetMessage

func (d *DiscordJSONClient) GetMessage(ctx context.Context, cid, mid snowflake.Snowflake) (respData entity.Message, err error)

func (*DiscordJSONClient) SendInteractionAutocomplete added in v23.1.0

func (d *DiscordJSONClient) SendInteractionAutocomplete(ctx context.Context, ixID snowflake.Snowflake, ixToken string, m marshaler) error

func (*DiscordJSONClient) SendInteractionMessage

func (d *DiscordJSONClient) SendInteractionMessage(ctx context.Context, ixID snowflake.Snowflake, ixToken string, m marshaler) error

func (*DiscordJSONClient) SendMessage

func (d *DiscordJSONClient) SendMessage(ctx context.Context, cid snowflake.Snowflake, m marshaler) (respData entity.Message, err error)

func (*DiscordJSONClient) SetDebug

func (d *DiscordJSONClient) SetDebug(val bool)

type Embed

type Embed struct {
	Title       string       `json:"title,omitempty"`
	Description string       `json:"description,omitempty"`
	URL         string       `json:"url,omitempty"`
	Timestamp   string       `json:"timestamp,omitempty"`
	Color       int          `json:"color,omitempty"`
	Fields      []EmbedField `json:"fields,omitempty"`
	Footer      EmbedFooter  `json:"footer,omitempty"`
}

Embed is a json object that represents an embed in a MessageWithEmbed

type EmbedField

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

EmbedField is a json object that represents a field in an Embed

type EmbedFooter

type EmbedFooter struct {
	Text string `json:"text"`
}

EmbedFooter is a json object that represents the footer of an embed

type HTTPClient

HTTPClient is the interface of an http client

type InteractionAutocompleteResponse added in v23.1.0

type InteractionAutocompleteResponse struct {
	Choices []entity.ApplicationCommandOptionChoice `json:"choices"`
}

func (InteractionAutocompleteResponse) MarshalToJSON added in v23.1.0

func (m InteractionAutocompleteResponse) MarshalToJSON() ([]byte, error)

type InteractionCallbackMessage

type InteractionCallbackMessage struct {
	Type InteractionCallbackType `json:"type"`
	Data stdjson.RawMessage      `json:"data,omitempty"`
}

type InteractionCallbackType

type InteractionCallbackType int
const (
	CallbackTypePong                   InteractionCallbackType = 1
	CallbackTypeChannelMessage         InteractionCallbackType = 4
	CallbackTypeDeferredChannelMessage InteractionCallbackType = 5
	CallbackTypeDeferredUpdate         InteractionCallbackType = 6
	CallbackTypeUpdate                 InteractionCallbackType = 7
	CallbackTypeAutocomplete           InteractionCallbackType = 8
)

type Logger

type Logger = interface {
	Log(keyvals ...interface{}) error
	Message(string, ...interface{})
	Err(string, error, ...interface{})
	Printf(string, ...interface{})
}

type Message

type Message struct {
	Content string            `json:"content"`
	Tts     bool              `json:"tts"`
	ReplyTo *MessageReference `json:"message_reference,omitempty"`
	Flags   int               `json:"flags,omitempty"`
}

Message is the json object that is sent to the discord api to post a plain-text message to a server

func (Message) MarshalToJSON

func (m Message) MarshalToJSON() ([]byte, error)

type MessageReference

type MessageReference struct {
	MessageID string `json:"message_id,omitempty"`
	ChannelID string `json:"channel_id,omitempty"`
	GuildID   string `json:"guild_id,omitempty"`
}

type MessageWithEmbed

type MessageWithEmbed struct {
	Content string            `json:"content"`
	Tts     bool              `json:"tts"`
	Embeds  []Embed           `json:"embeds"`
	ReplyTo *MessageReference `json:"message_reference,omitempty"`
	Flags   int               `json:"flags,omitempty"`
}

MessageWithEmbed is the json object that is sent to the discord api to post an embed message to a server

func (MessageWithEmbed) MarshalToJSON

func (m MessageWithEmbed) MarshalToJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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