interactions

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ValueParseFailedErr = errors.New("value parse failed")
)

Functions

This section is empty.

Types

type ActionData

type ActionData struct {
	Resolved      ResolvedData        `json:"resolved,omitempty"`
	Name          string              `json:"name"`
	TargetID      string              `json:"target_id,omitempty"`
	CustomID      string              `json:"custom_id,omitempty"`
	Options       OptionList          `json:"options,omitempty"`
	Values        []string            `json:"values,omitempty"`
	Components    ComponentList       `json:"components,omitempty"`
	ID            snowflake.Snowflake `json:"id"`
	Type          uint                `json:"type"`
	ComponentType components.Type     `json:"component_type,omitempty"`
}

type ActionType

type ActionType uint8
const (
	PingAction ActionType = iota + 1
	CommandAction
	MessageComponentAction
	AutocompleteAction
	ModalSubmitAction
)

type CallbackType

type CallbackType uint8
const (
	PongCallback                     CallbackType = iota + 1
	ChannelMessageWithSourceCallback CallbackType = iota + 3
	DeferredChannelMessageWithSourceCallback
	DeferredUpdateMessageCallback
	UpdateMessageCallback
	AutocompleteResultCallback
	ModalCallback
)

type ComponentList

type ComponentList []components.Component

func (ComponentList) Get

func (x ComponentList) Get(id string) (c components.Component, found bool)

func (ComponentList) Has

func (x ComponentList) Has(id string) bool

type ExpandableReplyBuilder

type ExpandableReplyBuilder[B any] interface {
	discord.BaseMessageBuilder[B]
	Ephemeral() B
	Execute() (err error)
}

type FollowUpCreateBuilder

type FollowUpCreateBuilder interface {
	discord.ExpandableWebhookExecuteBuilder[FollowUpCreateBuilder]
	Execute() (msg FollowUpMessage, err error)
}

type FollowUpMessage

type FollowUpMessage struct {
	*discord.Message
	// contains filtered or unexported fields
}

func (FollowUpMessage) Delete

func (x FollowUpMessage) Delete() error

func (FollowUpMessage) Edit

type FollowUpUpdateBuilder

type FollowUpUpdateBuilder interface {
	discord.BaseMessageBuilder[FollowUpUpdateBuilder]
	Execute() (msg FollowUpMessage, err error)
}

type Interaction

type Interaction struct {
	Token         string                 `json:"token"`
	Locale        string                 `json:"locale,omitempty"`
	Member        discord.MemberWithUser `json:"member,omitempty"`
	Data          ActionData             `json:"data,omitempty"`
	User          discord.User           `json:"user,omitempty"`
	Message       discord.Message        `json:"message"`
	GuildID       snowflake.Snowflake    `json:"guild_id,omitempty"`
	ChannelID     snowflake.Snowflake    `json:"channel_id,omitempty"`
	ID            snowflake.Snowflake    `json:"id,omitempty"`
	ApplicationID snowflake.Snowflake    `json:"application_id,omitempty"`
	Type          ActionType             `json:"type,omitempty"`
}

func (*Interaction) AutocompleteReply

func (i *Interaction) AutocompleteReply(choices []slash.Choice) error

func (*Interaction) ComponentMessageUpdate

func (i *Interaction) ComponentMessageUpdate() InteractionUpdateBuilder

func (*Interaction) CreateFollowUp

func (i *Interaction) CreateFollowUp() FollowUpCreateBuilder

func (*Interaction) CreateModal

func (i *Interaction) CreateModal(id string, title string) *ModalBuilder

func (*Interaction) CustomReply

func (i *Interaction) CustomReply() OriginalCustomBuilder

func (*Interaction) Defer

func (i *Interaction) Defer(loading bool, ephemeral bool) error

Defer loading false works only for component-based interactions!

func (*Interaction) Delete

func (i *Interaction) Delete() error

func (*Interaction) EditOriginalReply

func (i *Interaction) EditOriginalReply() OriginalUpdateBuilder

func (*Interaction) FetchOriginalResponse

func (i *Interaction) FetchOriginalResponse() error

func (*Interaction) InGuild

func (i *Interaction) InGuild() bool

func (*Interaction) IsAutocomplete

func (i *Interaction) IsAutocomplete() bool

func (*Interaction) IsButton

func (i *Interaction) IsButton() bool

func (*Interaction) IsCommand

func (i *Interaction) IsCommand() bool

func (*Interaction) IsMessageComponent

func (i *Interaction) IsMessageComponent() bool

func (*Interaction) IsModalSubmit

func (i *Interaction) IsModalSubmit() bool

func (*Interaction) IsSelectMenu

func (i *Interaction) IsSelectMenu() bool

func (*Interaction) ModalValue added in v0.1.10

func (i *Interaction) ModalValue(id string) (string, error)

func (*Interaction) SendMessageReply

func (i *Interaction) SendMessageReply() ReplyBuilder

func (*Interaction) UserID

func (i *Interaction) UserID() snowflake.Snowflake

UserID might be present (or not) in multiple places - this method gets it wherever it exists.

type InteractionCallbackFlags

type InteractionCallbackFlags uint8
const (
	EphemeralFlag InteractionCallbackFlags = 1 << 6
)

type InteractionResponse

type InteractionResponse struct {
	Data *ResponseData `json:"data,omitempty"`
	Type CallbackType  `json:"type"`
}

type InteractionUpdateBuilder

type InteractionUpdateBuilder interface {
	discord.BaseMessageBuilder[InteractionUpdateBuilder]
	Execute() (err error)
}

type ModalBuilder

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

func NewModalBuilder

func NewModalBuilder(i *Interaction, id string, title string) *ModalBuilder

func (*ModalBuilder) AddTextField

func (x *ModalBuilder) AddTextField(id string, label string) *TextFieldBuilder

func (*ModalBuilder) Execute

func (x *ModalBuilder) Execute() error

type Option

type Option struct {
	Value   interface{}      `json:"value,omitempty"`
	Name    string           `json:"name"`
	Options OptionList       `json:"options,omitempty"`
	Type    slash.OptionType `json:"type"`
	Focused bool             `json:"focused,omitempty"`
}

func (*Option) Attachment

func (o *Option) Attachment() (att discord.Attachment, err error)

func (*Option) Bool

func (o *Option) Bool() (bool, error)

func (*Option) Default

func (o *Option) Default(x interface{}) *Option

func (*Option) Float

func (o *Option) Float() (float64, error)

func (*Option) Int

func (o *Option) Int() (int, error)

func (*Option) Nil

func (o *Option) Nil() bool

func (*Option) Snowflake

func (o *Option) Snowflake() (snowflake.ID, error)

func (*Option) String

func (o *Option) String() (string, error)

type OptionList

type OptionList []*Option

func (OptionList) Get

func (x OptionList) Get(name string) *Option

func (OptionList) Has

func (x OptionList) Has(name string) bool

type OriginalCustomBuilder

type OriginalCustomBuilder interface {
	Type(t CallbackType)
	Data(x ResponseData)
	Execute() (err error)
}

type OriginalUpdateBuilder

type OriginalUpdateBuilder interface {
	discord.BaseMessageBuilder[OriginalUpdateBuilder]
	Execute() (err error)
}

type ResolvedData

type ResolvedData struct {
	Users map[snowflake.ID]discord.User `json:"users,omitempty"`
	// Always partial - missing: deaf and mute
	Members map[snowflake.ID]discord.Member `json:"members,omitempty"`
	Roles   map[snowflake.ID]discord.Role   `json:"roles,omitempty"`
	// Always partial - only id, name, type, permissions, thread_metadata and parent_id fields are included
	Channels map[snowflake.ID]discord.Channel     `json:"channels,omitempty"`
	Messages map[snowflake.ID]discord.BaseMessage `json:"messages,omitempty"`
}

type ResponseData

type ResponseData struct {
	discord.MessageCreate
	//AllowedMentions discord.MessageAllowedMentions `json:"allowed_mentions,omitempty"`
	Choices *[]slash.Choice          `json:"choices,omitempty"`
	Flags   InteractionCallbackFlags `json:"flags,omitempty"`
}

type TextFieldBuilder

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

func NewTextFieldBuilder

func NewTextFieldBuilder(id string, label string) *TextFieldBuilder

func (*TextFieldBuilder) MultiLine

func (x *TextFieldBuilder) MultiLine() *TextFieldBuilder

func (*TextFieldBuilder) NotRequired

func (x *TextFieldBuilder) NotRequired() *TextFieldBuilder

type TextFieldData

type TextFieldData struct {
	Value       *string        `json:"value,omitempty"`
	Placeholder *string        `json:"placeholder,omitempty"`
	Label       string         `json:"label,omitempty"`
	ID          string         `json:"custom_id,omitempty"`
	Min         uint16         `json:"min_length,omitempty"`
	Max         uint16         `json:"max_length,omitempty"`
	Type        uint8          `json:"type"`
	Required    bool           `json:"required,omitempty"`
	Style       TextFieldStyle `json:"style,omitempty"`
}

type TextFieldStyle

type TextFieldStyle uint8
const (
	SingleLineStyle TextFieldStyle = iota + 1
	MultiLineStyle
)

Jump to

Keyboard shortcuts

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