config

package
v0.0.0-...-1d592cf Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Name             string            `json:"name"`
	Description      string            `json:"description"`
	Method           string            `json:"method"`
	URL              string            `json:"url"`
	Body             Params            `json:"body,omitempty"`
	BodyTemplate     string            `json:"body_template,omitempty"`
	Query            Params            `json:"query,omitempty"`
	Form             Params            `json:"form,omitempty"`
	Headers          Headers           `json:"headers,omitempty"`
	ParseJSON        ParseJSONResponse `json:"parse_json,omitempty"`
	ResponseTemplate string            `json:"response_template,omitempty"`
}

func (*Command) ToApplicationCommand

func (c *Command) ToApplicationCommand() (*discordgo.ApplicationCommand, error)

type Commands

type Commands []Command

func LoadConfigs

func LoadConfigs(dir string) (Commands, error)

LoadConfigs loads all .json files in the given directory and returns them as a list of Command structs.

func (Commands) FindByName

func (c Commands) FindByName(name string) *Command

func (Commands) ToApplicationCommands

func (c Commands) ToApplicationCommands() ([]*discordgo.ApplicationCommand, error)

type Headers

type Headers map[string]string

type Param

type Param struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Type        string   `json:"type"`
	Required    bool     `json:"required,omitempty"`
	Options     []string `json:"options,omitempty"`
	Default     any      `json:"default,omitempty"`
}

func (*Param) ToApplicationCommandOption

func (p *Param) ToApplicationCommandOption() (*discordgo.ApplicationCommandOption, error)

type Params

type Params []Param

func (Params) ToApplicationCommandOptions

func (p Params) ToApplicationCommandOptions() ([]*discordgo.ApplicationCommandOption, error)

type ParseJSONResponse

type ParseJSONResponse map[string]string

func (*ParseJSONResponse) Parse

func (p *ParseJSONResponse) Parse(body []byte) (map[string]string, error)

Jump to

Keyboard shortcuts

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