Documentation
¶
Overview ¶
Package discordkit provides an interaction framework built on top of discordgo. discordgo owns Discord models and transport; DiscordKit provides routing, typed command options, component validation, forms and response lifecycle.
Register routes before connecting a discordgo.Session. Attach a Router with Session.AddHandler(router.Handle). Handlers return errors to Router.OnError. Recovery is enabled by default. Access Context.Session for raw discordgo APIs.
Index ¶
- Variables
- func AttachmentOption(name, description string) *simpleOptionBuilder
- func BooleanOption(name, description string) *simpleOptionBuilder
- func BuildCommands(builders ...*CommandBuilder) ([]*discordgo.ApplicationCommand, error)
- func Components(nodes ...Component) []discordgo.MessageComponent
- func MentionableOption(name, description string) *simpleOptionBuilder
- func RoleOption(name, description string) *simpleOptionBuilder
- func UserOption(name, description string) *simpleOptionBuilder
- func ValidateMessageComponents(components []discordgo.MessageComponent) error
- func ValidateModalComponents(components []discordgo.MessageComponent) error
- type ButtonBuilder
- func (b *ButtonBuilder) Danger() *ButtonBuilder
- func (b *ButtonBuilder) Disabled() *ButtonBuilder
- func (b *ButtonBuilder) Emoji(e discordgo.ComponentEmoji) *ButtonBuilder
- func (b *ButtonBuilder) Primary() *ButtonBuilder
- func (b *ButtonBuilder) Secondary() *ButtonBuilder
- func (b *ButtonBuilder) Success() *ButtonBuilder
- type ChannelOptionBuilder
- type ChannelSelectBuilder
- func (b *ChannelSelectBuilder) ChannelTypes(types ...discordgo.ChannelType) *ChannelSelectBuilder
- func (b *ChannelSelectBuilder) DefaultValues(values ...discordgo.SelectMenuDefaultValue) *ChannelSelectBuilder
- func (b *ChannelSelectBuilder) Disabled() *ChannelSelectBuilder
- func (b *ChannelSelectBuilder) MaxValues(n int) *ChannelSelectBuilder
- func (b *ChannelSelectBuilder) MinValues(n int) *ChannelSelectBuilder
- func (b *ChannelSelectBuilder) Placeholder(p string) *ChannelSelectBuilder
- type ChoiceValue
- type CommandBuilder
- func (b *CommandBuilder) Build() (*discordgo.ApplicationCommand, error)
- func (b *CommandBuilder) Contexts(contexts ...discordgo.InteractionContextType) *CommandBuilder
- func (b *CommandBuilder) DefaultMemberPermissions(perms int64) *CommandBuilder
- func (b *CommandBuilder) DescriptionLocalizations(m map[discordgo.Locale]string) *CommandBuilder
- func (b *CommandBuilder) IntegrationTypes(types ...discordgo.ApplicationIntegrationType) *CommandBuilder
- func (b *CommandBuilder) MustBuild() *discordgo.ApplicationCommand
- func (b *CommandBuilder) NSFW() *CommandBuilder
- func (b *CommandBuilder) NameLocalizations(m map[discordgo.Locale]string) *CommandBuilder
- func (b *CommandBuilder) Options(options ...Option) *CommandBuilder
- type Component
- type ContainerBuilder
- type Context
- func (c *Context) Attachment(name string) (*discordgo.MessageAttachment, bool)
- func (c *Context) Autocomplete(choices ...ChoiceValue) error
- func (c *Context) Bool(name string) (bool, bool)
- func (c *Context) Channel(name string) (*discordgo.Channel, bool)
- func (c *Context) ChannelID() string
- func (c *Context) Context() context.Context
- func (c *Context) Defer(ephemeral bool) error
- func (c *Context) DeferUpdate() error
- func (c *Context) DeleteResponse() error
- func (c *Context) Edit(spec MessageSpec) (*discordgo.Message, error)
- func (c *Context) Ephemeral(spec MessageSpec) error
- func (c *Context) EphemeralText(content string) error
- func (c *Context) Float(name string) (float64, bool)
- func (c *Context) FocusedOption() (*discordgo.ApplicationCommandInteractionDataOption, bool)
- func (c *Context) Followup(spec MessageSpec) (*discordgo.Message, error)
- func (c *Context) FollowupEdit(messageID string, spec MessageSpec) (*discordgo.Message, error)
- func (c *Context) Form() *FormData
- func (c *Context) GuildID() string
- func (c *Context) Int(name string) (int64, bool)
- func (c *Context) IsDM() bool
- func (c *Context) IsGuild() bool
- func (c *Context) Locale() discordgo.Locale
- func (c *Context) Member() *discordgo.Member
- func (c *Context) MemberOption(name string) (*discordgo.Member, bool)
- func (c *Context) Mentionable(name string) (Mentionable, bool)
- func (c *Context) MustAttachment(name string) *discordgo.MessageAttachment
- func (c *Context) MustBool(name string) bool
- func (c *Context) MustChannel(name string) *discordgo.Channel
- func (c *Context) MustFloat(name string) float64
- func (c *Context) MustInt(name string) int64
- func (c *Context) MustMemberOption(name string) *discordgo.Member
- func (c *Context) MustMentionable(name string) Mentionable
- func (c *Context) MustParam(name string) string
- func (c *Context) MustRole(name string) *discordgo.Role
- func (c *Context) MustString(name string) string
- func (c *Context) MustUserOption(name string) *discordgo.User
- func (c *Context) Option(name string) (*discordgo.ApplicationCommandInteractionDataOption, bool)
- func (c *Context) Param(name string) (string, bool)
- func (c *Context) Reply(spec MessageSpec) error
- func (c *Context) ReplyText(content string) error
- func (c *Context) RequireAttachment(name string) (*discordgo.MessageAttachment, error)
- func (c *Context) RequireBool(name string) (bool, error)
- func (c *Context) RequireChannel(name string) (*discordgo.Channel, error)
- func (c *Context) RequireFloat(name string) (float64, error)
- func (c *Context) RequireInt(name string) (int64, error)
- func (c *Context) RequireMemberOption(name string) (*discordgo.Member, error)
- func (c *Context) RequireMentionable(name string) (Mentionable, error)
- func (c *Context) RequireParam(name string) (string, error)
- func (c *Context) RequireRole(name string) (*discordgo.Role, error)
- func (c *Context) RequireString(name string) (string, error)
- func (c *Context) RequireUserOption(name string) (*discordgo.User, error)
- func (c *Context) Role(name string) (*discordgo.Role, bool)
- func (c *Context) SetContext(ctx context.Context)
- func (c *Context) ShowModal(m Modal) error
- func (c *Context) String(name string) (string, bool)
- func (c *Context) Update(spec MessageSpec) error
- func (c *Context) User() *discordgo.User
- func (c *Context) UserOption(name string) (*discordgo.User, bool)
- type CustomID
- type EntitySelectBuilder
- func (b *EntitySelectBuilder) DefaultValues(values ...discordgo.SelectMenuDefaultValue) *EntitySelectBuilder
- func (b *EntitySelectBuilder) Disabled() *EntitySelectBuilder
- func (b *EntitySelectBuilder) MaxValues(n int) *EntitySelectBuilder
- func (b *EntitySelectBuilder) MinValues(n int) *EntitySelectBuilder
- func (b *EntitySelectBuilder) Placeholder(p string) *EntitySelectBuilder
- type FieldBuilder
- type FileBuilder
- type FileUploadBuilder
- type FormData
- func (f *FormData) Files(customID string) ([]*discordgo.MessageAttachment, bool)
- func (f *FormData) MustString(customID string) string
- func (f *FormData) RequireFiles(customID string) ([]*discordgo.MessageAttachment, error)
- func (f *FormData) RequireString(customID string) (string, error)
- func (f *FormData) RequireStrings(customID string) ([]string, error)
- func (f *FormData) String(customID string) (string, bool)
- func (f *FormData) Strings(customID string) ([]string, bool)
- type GalleryBuilder
- type GalleryItem
- type Group
- type Handler
- type IntegerOptionBuilder
- func (b *IntegerOptionBuilder) Autocomplete() *IntegerOptionBuilder
- func (b *IntegerOptionBuilder) Choices(choices ...ChoiceValue) *IntegerOptionBuilder
- func (b *IntegerOptionBuilder) Max(n int64) *IntegerOptionBuilder
- func (b *IntegerOptionBuilder) Min(n int64) *IntegerOptionBuilder
- func (b *IntegerOptionBuilder) NameLocalizations(m map[discordgo.Locale]string) *IntegerOptionBuilder
- func (b *IntegerOptionBuilder) Required() *IntegerOptionBuilder
- type Mentionable
- type MessageSpec
- func (m MessageSpec) InteractionResponseData() (*discordgo.InteractionResponseData, error)
- func (m MessageSpec) MessageEdit(channelID, messageID string) (*discordgo.MessageEdit, error)
- func (m MessageSpec) WebhookEdit() (*discordgo.WebhookEdit, error)
- func (m MessageSpec) WebhookParams() (*discordgo.WebhookParams, error)
- type Middleware
- type Modal
- type ModalBuilder
- type NumberOptionBuilder
- func (b *NumberOptionBuilder) Autocomplete() *NumberOptionBuilder
- func (b *NumberOptionBuilder) Choices(choices ...ChoiceValue) *NumberOptionBuilder
- func (b *NumberOptionBuilder) Max(n float64) *NumberOptionBuilder
- func (b *NumberOptionBuilder) Min(n float64) *NumberOptionBuilder
- func (b *NumberOptionBuilder) NameLocalizations(m map[discordgo.Locale]string) *NumberOptionBuilder
- func (b *NumberOptionBuilder) Required() *NumberOptionBuilder
- type Option
- type PanicError
- type RouteBuilder
- type Router
- func (r *Router) Autocomplete(path, option string, h Handler, m ...Middleware) error
- func (r *Router) Command(path string, h Handler, m ...Middleware) error
- func (r *Router) Component(path string, h Handler, m ...Middleware) error
- func (r *Router) Dispatch(c *Context) error
- func (r *Router) Group(prefix string, m ...Middleware) *Group
- func (r *Router) Handle(s *discordgo.Session, i *discordgo.InteractionCreate)
- func (r *Router) Modal(path string, h Handler, m ...Middleware) error
- func (r *Router) OnError(h func(*Context, error))
- func (r *Router) Use(m ...Middleware)
- type RowBuilder
- type SectionBuilder
- type SelectOptionBuilder
- type SeparatorBuilder
- type StringOptionBuilder
- func (b *StringOptionBuilder) Autocomplete() *StringOptionBuilder
- func (b *StringOptionBuilder) Choices(choices ...ChoiceValue) *StringOptionBuilder
- func (b *StringOptionBuilder) MaxLen(n int) *StringOptionBuilder
- func (b *StringOptionBuilder) MinLen(n int) *StringOptionBuilder
- func (b *StringOptionBuilder) NameLocalizations(m map[discordgo.Locale]string) *StringOptionBuilder
- func (b *StringOptionBuilder) Required() *StringOptionBuilder
- type StringSelectBuilder
- func (b *StringSelectBuilder) Disabled() *StringSelectBuilder
- func (b *StringSelectBuilder) MaxValues(n int) *StringSelectBuilder
- func (b *StringSelectBuilder) MinValues(n int) *StringSelectBuilder
- func (b *StringSelectBuilder) Options(options ...*SelectOptionBuilder) *StringSelectBuilder
- func (b *StringSelectBuilder) Placeholder(p string) *StringSelectBuilder
- func (b *StringSelectBuilder) Required() *StringSelectBuilder
- type SubCommandBuilder
- type SubCommandGroupBuilder
- type SyncOptions
- type SyncPlan
- type TextDisplayBuilder
- type TextInputBuilder
- func (b *TextInputBuilder) MaxLen(n int) *TextInputBuilder
- func (b *TextInputBuilder) MinLen(n int) *TextInputBuilder
- func (b *TextInputBuilder) Paragraph() *TextInputBuilder
- func (b *TextInputBuilder) Placeholder(p string) *TextInputBuilder
- func (b *TextInputBuilder) Required(required bool) *TextInputBuilder
- func (b *TextInputBuilder) Value(v string) *TextInputBuilder
- type ThumbnailBuilder
Constants ¶
This section is empty.
Variables ¶
var ( ErrRouteNotFound = errors.New("discordkit: route not found") ErrRouteConflict = errors.New("discordkit: route conflict") ErrInvalidCustomID = errors.New("discordkit: invalid custom ID") ErrAlreadyResponded = errors.New("discordkit: interaction already acknowledged") ErrNotResponded = errors.New("discordkit: interaction has not been acknowledged") ErrInvalidInteraction = errors.New("discordkit: operation is invalid for this interaction") ErrInvalidComponent = errors.New("discordkit: invalid component") ErrInvalidMessage = errors.New("discordkit: invalid message") ErrMissingOption = errors.New("discordkit: option missing or invalid") ErrInvalidCommand = errors.New("discordkit: invalid command") )
Sentinel errors identify failures that callers can handle with errors.Is.
Functions ¶
func AttachmentOption ¶
func AttachmentOption(name, description string) *simpleOptionBuilder
AttachmentOption starts an attachment option builder.
func BooleanOption ¶
func BooleanOption(name, description string) *simpleOptionBuilder
BooleanOption starts a boolean option builder.
func BuildCommands ¶
func BuildCommands(builders ...*CommandBuilder) ([]*discordgo.ApplicationCommand, error)
BuildCommands builds a set of command builders, returning the first error.
func Components ¶
func Components(nodes ...Component) []discordgo.MessageComponent
Components finalizes DSL nodes into a discordgo component slice, ready for a MessageSpec. Validation happens when the MessageSpec is resolved.
func MentionableOption ¶
func MentionableOption(name, description string) *simpleOptionBuilder
MentionableOption starts a mentionable (user or role) option builder.
func RoleOption ¶
func RoleOption(name, description string) *simpleOptionBuilder
RoleOption starts a role option builder.
func UserOption ¶
func UserOption(name, description string) *simpleOptionBuilder
UserOption starts a user option builder.
func ValidateMessageComponents ¶
func ValidateMessageComponents(components []discordgo.MessageComponent) error
ValidateMessageComponents checks a message component tree against Discord's structural rules and the 40-component limit. It returns ErrInvalidComponent.
func ValidateModalComponents ¶
func ValidateModalComponents(components []discordgo.MessageComponent) error
ValidateModalComponents checks a modal component tree. Modern modals use Label wrappers around a single text input, string select or file upload.
Types ¶
type ButtonBuilder ¶
type ButtonBuilder struct {
// contains filtered or unexported fields
}
ButtonBuilder builds an interactive, link or premium button.
func Button ¶
func Button(label, customID string) *ButtonBuilder
Button creates an interactive button with the given custom ID.
func LinkButton ¶
func LinkButton(label, url string) *ButtonBuilder
LinkButton creates a link button that opens a URL.
func PremiumButton ¶
func PremiumButton(skuID string) *ButtonBuilder
PremiumButton creates a premium upsell button for a SKU.
func (*ButtonBuilder) Danger ¶
func (b *ButtonBuilder) Danger() *ButtonBuilder
func (*ButtonBuilder) Disabled ¶
func (b *ButtonBuilder) Disabled() *ButtonBuilder
Disabled disables the button.
func (*ButtonBuilder) Emoji ¶
func (b *ButtonBuilder) Emoji(e discordgo.ComponentEmoji) *ButtonBuilder
Emoji sets a button emoji.
func (*ButtonBuilder) Primary ¶
func (b *ButtonBuilder) Primary() *ButtonBuilder
Primary, Secondary, Success and Danger set an interactive button's style.
func (*ButtonBuilder) Secondary ¶
func (b *ButtonBuilder) Secondary() *ButtonBuilder
func (*ButtonBuilder) Success ¶
func (b *ButtonBuilder) Success() *ButtonBuilder
type ChannelOptionBuilder ¶
type ChannelOptionBuilder struct {
// contains filtered or unexported fields
}
ChannelOptionBuilder builds a channel command option with channel type limits.
func ChannelOption ¶
func ChannelOption(name, description string) *ChannelOptionBuilder
ChannelOption starts a channel option builder.
func (*ChannelOptionBuilder) ChannelTypes ¶
func (b *ChannelOptionBuilder) ChannelTypes(types ...discordgo.ChannelType) *ChannelOptionBuilder
ChannelTypes restricts selectable channel types.
func (*ChannelOptionBuilder) NameLocalizations ¶
func (b *ChannelOptionBuilder) NameLocalizations(m map[discordgo.Locale]string) *ChannelOptionBuilder
NameLocalizations sets localized names.
func (*ChannelOptionBuilder) Required ¶
func (b *ChannelOptionBuilder) Required() *ChannelOptionBuilder
Required marks the option as required.
type ChannelSelectBuilder ¶
type ChannelSelectBuilder struct {
// contains filtered or unexported fields
}
ChannelSelectBuilder builds a channel select menu.
func ChannelSelect ¶
func ChannelSelect(customID string) *ChannelSelectBuilder
ChannelSelect creates a channel select menu.
func (*ChannelSelectBuilder) ChannelTypes ¶
func (b *ChannelSelectBuilder) ChannelTypes(types ...discordgo.ChannelType) *ChannelSelectBuilder
ChannelTypes restricts selectable channel types.
func (*ChannelSelectBuilder) DefaultValues ¶
func (b *ChannelSelectBuilder) DefaultValues(values ...discordgo.SelectMenuDefaultValue) *ChannelSelectBuilder
DefaultValues sets auto-populated default channels.
func (*ChannelSelectBuilder) Disabled ¶
func (b *ChannelSelectBuilder) Disabled() *ChannelSelectBuilder
Disabled disables the select menu.
func (*ChannelSelectBuilder) MaxValues ¶
func (b *ChannelSelectBuilder) MaxValues(n int) *ChannelSelectBuilder
MaxValues sets the maximum number of selections.
func (*ChannelSelectBuilder) MinValues ¶
func (b *ChannelSelectBuilder) MinValues(n int) *ChannelSelectBuilder
MinValues sets the minimum number of selections.
func (*ChannelSelectBuilder) Placeholder ¶
func (b *ChannelSelectBuilder) Placeholder(p string) *ChannelSelectBuilder
Placeholder sets placeholder text.
type ChoiceValue ¶
type ChoiceValue struct {
// contains filtered or unexported fields
}
ChoiceValue is a single predefined choice for a command option or an autocomplete response. Build one with Choice.
func Choice ¶
func Choice(name string, value any) ChoiceValue
Choice creates a named choice. The value must be a string, integer or float.
func (ChoiceValue) Localized ¶
func (c ChoiceValue) Localized(localizations map[discordgo.Locale]string) ChoiceValue
Localized attaches name localizations to a choice.
type CommandBuilder ¶
type CommandBuilder struct {
// contains filtered or unexported fields
}
CommandBuilder builds a *discordgo.ApplicationCommand with compile-time typed option builders and validation deferred to Build.
func Command ¶
func Command(name, description string, options ...Option) *CommandBuilder
Command starts a chat (slash) command builder. Options may also be added with Options for readability.
func MessageCommand ¶
func MessageCommand(name string) *CommandBuilder
MessageCommand starts a message context menu command builder.
func UserCommand ¶
func UserCommand(name string) *CommandBuilder
UserCommand starts a user context menu command builder.
func (*CommandBuilder) Build ¶
func (b *CommandBuilder) Build() (*discordgo.ApplicationCommand, error)
Build validates and returns the discordgo command.
func (*CommandBuilder) Contexts ¶
func (b *CommandBuilder) Contexts(contexts ...discordgo.InteractionContextType) *CommandBuilder
Contexts sets the interaction contexts where the command is available.
func (*CommandBuilder) DefaultMemberPermissions ¶
func (b *CommandBuilder) DefaultMemberPermissions(perms int64) *CommandBuilder
DefaultMemberPermissions sets the default member permission bitmask required to see and use the command.
func (*CommandBuilder) DescriptionLocalizations ¶
func (b *CommandBuilder) DescriptionLocalizations(m map[discordgo.Locale]string) *CommandBuilder
DescriptionLocalizations sets localized command descriptions.
func (*CommandBuilder) IntegrationTypes ¶
func (b *CommandBuilder) IntegrationTypes(types ...discordgo.ApplicationIntegrationType) *CommandBuilder
IntegrationTypes sets the installation contexts for the command.
func (*CommandBuilder) MustBuild ¶
func (b *CommandBuilder) MustBuild() *discordgo.ApplicationCommand
MustBuild is Build with panic on error, for static command declarations.
func (*CommandBuilder) NSFW ¶
func (b *CommandBuilder) NSFW() *CommandBuilder
NSFW marks the command as age-restricted.
func (*CommandBuilder) NameLocalizations ¶
func (b *CommandBuilder) NameLocalizations(m map[discordgo.Locale]string) *CommandBuilder
NameLocalizations sets localized command names.
func (*CommandBuilder) Options ¶
func (b *CommandBuilder) Options(options ...Option) *CommandBuilder
Options appends command options.
type Component ¶
type Component interface {
// contains filtered or unexported methods
}
Component is a DSL node that finalizes into a concrete discordgo component. Every builder in this package implements it, and Raw wraps an existing discordgo component as an escape hatch.
func Raw ¶
func Raw(c discordgo.MessageComponent) Component
Raw lets callers drop a discordgo component directly into the DSL, so an unsupported Discord feature never blocks use of DiscordKit.
type ContainerBuilder ¶
type ContainerBuilder struct {
// contains filtered or unexported fields
}
ContainerBuilder builds a container with an optional accent color.
func Container ¶
func Container(children ...Component) *ContainerBuilder
Container groups components with a colored side bar.
func (*ContainerBuilder) AccentColor ¶
func (b *ContainerBuilder) AccentColor(color int) *ContainerBuilder
AccentColor sets the container accent color.
func (*ContainerBuilder) Spoiler ¶
func (b *ContainerBuilder) Spoiler() *ContainerBuilder
Spoiler marks the container as a spoiler.
type Context ¶
type Context struct {
Session *discordgo.Session
Interaction *discordgo.InteractionCreate
// contains filtered or unexported fields
}
Context represents one interaction. Session and Interaction are escape hatches. Do not copy Context after use. Raw response calls bypass its lifecycle tracking.
func NewContext ¶
func NewContext(s *discordgo.Session, i *discordgo.InteractionCreate) *Context
NewContext creates a pending interaction context. Router normally calls this.
func (*Context) Attachment ¶
func (c *Context) Attachment(name string) (*discordgo.MessageAttachment, bool)
Attachment returns a resolved attachment option.
func (*Context) Autocomplete ¶
func (c *Context) Autocomplete(choices ...ChoiceValue) error
Autocomplete responds to an autocomplete interaction with up to 25 choices.
func (*Context) Defer ¶
Defer acknowledges a command interaction and shows a loading state. Edit the original response later with Edit. Pass ephemeral to hide the loading state.
func (*Context) DeferUpdate ¶
DeferUpdate acknowledges a component interaction without changing the message. Edit the message later with Edit. Only valid for component interactions.
func (*Context) DeleteResponse ¶
DeleteResponse deletes the original interaction response.
func (*Context) Edit ¶
func (c *Context) Edit(spec MessageSpec) (*discordgo.Message, error)
Edit edits the original interaction response after Reply or Defer.
func (*Context) Ephemeral ¶
func (c *Context) Ephemeral(spec MessageSpec) error
Ephemeral sends an initial response visible only to the invoking user.
func (*Context) EphemeralText ¶
EphemeralText is a convenience for a plain text ephemeral response.
func (*Context) FocusedOption ¶
func (c *Context) FocusedOption() (*discordgo.ApplicationCommandInteractionDataOption, bool)
FocusedOption returns the currently focused autocomplete option.
func (*Context) Followup ¶
func (c *Context) Followup(spec MessageSpec) (*discordgo.Message, error)
Followup sends an additional message after the interaction is acknowledged.
func (*Context) FollowupEdit ¶
FollowupEdit edits a previously sent followup message by ID.
func (*Context) Form ¶
Form parses the modal submission attached to the context. It returns an empty FormData for non-modal interactions.
func (*Context) MemberOption ¶
MemberOption joins a resolved member with its user without mutating discordgo data.
func (*Context) Mentionable ¶
func (c *Context) Mentionable(name string) (Mentionable, bool)
Mentionable returns a resolved mentionable without assuming it is a user.
func (*Context) MustAttachment ¶
func (c *Context) MustAttachment(name string) *discordgo.MessageAttachment
MustAttachment panics when the value is absent or invalid.
func (*Context) MustChannel ¶
MustChannel panics when the value is absent or invalid.
func (*Context) MustMemberOption ¶
MustMemberOption panics when the value is absent or invalid.
func (*Context) MustMentionable ¶
func (c *Context) MustMentionable(name string) Mentionable
MustMentionable panics when the value is absent or invalid.
func (*Context) MustString ¶
MustString panics when the value is absent or invalid.
func (*Context) MustUserOption ¶
MustUserOption panics when the value is absent or invalid.
func (*Context) Option ¶
func (c *Context) Option(name string) (*discordgo.ApplicationCommandInteractionDataOption, bool)
Option returns a leaf option from the selected subcommand, without fetching data.
func (*Context) Reply ¶
func (c *Context) Reply(spec MessageSpec) error
Reply sends an initial response as a new message. It fails with ErrAlreadyResponded if the interaction was already acknowledged.
func (*Context) RequireAttachment ¶
func (c *Context) RequireAttachment(name string) (*discordgo.MessageAttachment, error)
RequireAttachment returns an error when the value is absent or invalid.
func (*Context) RequireBool ¶
RequireBool returns an error when the value is absent or invalid.
func (*Context) RequireChannel ¶
RequireChannel returns an error when the value is absent or invalid.
func (*Context) RequireFloat ¶
RequireFloat returns an error when the value is absent or invalid.
func (*Context) RequireInt ¶
RequireInt returns an error when the value is absent or invalid.
func (*Context) RequireMemberOption ¶
RequireMemberOption returns an error when the value is absent or invalid.
func (*Context) RequireMentionable ¶
func (c *Context) RequireMentionable(name string) (Mentionable, error)
RequireMentionable returns an error when the value is absent or invalid.
func (*Context) RequireParam ¶
RequireParam returns an error when the value is absent or invalid.
func (*Context) RequireRole ¶
RequireRole returns an error when the value is absent or invalid.
func (*Context) RequireString ¶
RequireString returns an error when the value is absent or invalid.
func (*Context) RequireUserOption ¶
RequireUserOption returns an error when the value is absent or invalid.
func (*Context) SetContext ¶
SetContext sets the request context before response operations; nil means Background.
func (*Context) ShowModal ¶
ShowModal opens a modal as the initial response. Not valid for modal submit or autocomplete interactions.
func (*Context) Update ¶
func (c *Context) Update(spec MessageSpec) error
Update replaces the message a component belongs to. Only valid as the initial response to a component interaction.
type CustomID ¶
type CustomID string
CustomID identifies an interactive component or modal. Validate before sending.
type EntitySelectBuilder ¶
type EntitySelectBuilder struct {
// contains filtered or unexported fields
}
EntitySelectBuilder builds a user, role or mentionable auto-populated select.
func MentionableSelect ¶
func MentionableSelect(customID string) *EntitySelectBuilder
MentionableSelect creates a mentionable (user or role) select menu.
func RoleSelect ¶
func RoleSelect(customID string) *EntitySelectBuilder
RoleSelect creates a role select menu.
func UserSelect ¶
func UserSelect(customID string) *EntitySelectBuilder
UserSelect creates a user select menu.
func (*EntitySelectBuilder) DefaultValues ¶
func (b *EntitySelectBuilder) DefaultValues(values ...discordgo.SelectMenuDefaultValue) *EntitySelectBuilder
DefaultValues sets auto-populated default values.
func (*EntitySelectBuilder) Disabled ¶
func (b *EntitySelectBuilder) Disabled() *EntitySelectBuilder
Disabled disables the select menu.
func (*EntitySelectBuilder) MaxValues ¶
func (b *EntitySelectBuilder) MaxValues(n int) *EntitySelectBuilder
MaxValues sets the maximum number of selections.
func (*EntitySelectBuilder) MinValues ¶
func (b *EntitySelectBuilder) MinValues(n int) *EntitySelectBuilder
MinValues sets the minimum number of selections.
func (*EntitySelectBuilder) Placeholder ¶
func (b *EntitySelectBuilder) Placeholder(p string) *EntitySelectBuilder
Placeholder sets placeholder text.
type FieldBuilder ¶
type FieldBuilder struct {
// contains filtered or unexported fields
}
FieldBuilder wraps a single modal input in a Label.
func Field ¶
func Field(label string, input Component) *FieldBuilder
Field wraps a modal input (text input, string select or file upload) with a visible label, producing a discordgo.Label.
func (*FieldBuilder) Description ¶
func (b *FieldBuilder) Description(d string) *FieldBuilder
Description adds helper text below the label.
type FileBuilder ¶
type FileBuilder struct {
// contains filtered or unexported fields
}
FileBuilder builds a file display component.
func File ¶
func File(url string) *FileBuilder
File displays an uploaded file referenced by attachment://name.
func (*FileBuilder) Spoiler ¶
func (b *FileBuilder) Spoiler() *FileBuilder
Spoiler marks the file as a spoiler.
type FileUploadBuilder ¶
type FileUploadBuilder struct {
// contains filtered or unexported fields
}
FileUploadBuilder builds a file upload input for a modal field.
func FileUpload ¶
func FileUpload(customID string) *FileUploadBuilder
FileUpload creates a file upload input for a modal field.
func (*FileUploadBuilder) FileTypes ¶
func (b *FileUploadBuilder) FileTypes(types ...string) *FileUploadBuilder
FileTypes restricts accepted uploads by extension, e.g. "png", "pdf". This is a DiscordKit request-only extension over discordgo's FileUpload.
func (*FileUploadBuilder) MaxValues ¶
func (b *FileUploadBuilder) MaxValues(n int) *FileUploadBuilder
MaxValues sets the maximum number of files.
func (*FileUploadBuilder) MinValues ¶
func (b *FileUploadBuilder) MinValues(n int) *FileUploadBuilder
MinValues sets the minimum number of files.
func (*FileUploadBuilder) Required ¶
func (b *FileUploadBuilder) Required(required bool) *FileUploadBuilder
Required sets whether at least one file must be uploaded.
type FormData ¶
type FormData struct {
// contains filtered or unexported fields
}
FormData provides typed, reflection-free access to a modal submission.
func (*FormData) Files ¶
func (f *FormData) Files(customID string) ([]*discordgo.MessageAttachment, bool)
Files returns the resolved attachments uploaded to a file upload input.
func (*FormData) MustString ¶
MustString panics when the field is absent.
func (*FormData) RequireFiles ¶
func (f *FormData) RequireFiles(customID string) ([]*discordgo.MessageAttachment, error)
RequireFiles returns an error when the field is absent.
func (*FormData) RequireString ¶
RequireString returns an error when the field is absent.
func (*FormData) RequireStrings ¶
RequireStrings returns an error when the field is absent.
type GalleryBuilder ¶
type GalleryBuilder struct {
// contains filtered or unexported fields
}
GalleryBuilder builds a media gallery.
func Gallery ¶
func Gallery(items ...GalleryItem) *GalleryBuilder
Gallery creates a media gallery of 1-10 items.
type GalleryItem ¶
type GalleryItem struct {
// contains filtered or unexported fields
}
GalleryItem is a single media gallery entry.
func MediaItem ¶
func MediaItem(url string) GalleryItem
MediaItem creates a gallery item from a media URL.
func (GalleryItem) Description ¶
func (g GalleryItem) Description(d string) GalleryItem
Description sets alt text on a gallery item.
func (GalleryItem) Spoiler ¶
func (g GalleryItem) Spoiler() GalleryItem
Spoiler marks a gallery item as a spoiler.
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group shares a route prefix and middleware. Command prefixes use spaces; custom ID prefixes use slashes. A group does not create a separate router.
func (*Group) Autocomplete ¶
func (g *Group) Autocomplete(p, o string, h Handler, m ...Middleware) error
Autocomplete registers an autocomplete handler in the group.
func (*Group) Command ¶
func (g *Group) Command(p string, h Handler, m ...Middleware) error
Command registers a command in the group.
type IntegerOptionBuilder ¶
type IntegerOptionBuilder struct {
// contains filtered or unexported fields
}
IntegerOptionBuilder builds an integer command option.
func IntegerOption ¶
func IntegerOption(name, description string) *IntegerOptionBuilder
IntegerOption starts an integer option builder.
func (*IntegerOptionBuilder) Autocomplete ¶
func (b *IntegerOptionBuilder) Autocomplete() *IntegerOptionBuilder
Autocomplete enables dynamic autocomplete. Mutually exclusive with Choices.
func (*IntegerOptionBuilder) Choices ¶
func (b *IntegerOptionBuilder) Choices(choices ...ChoiceValue) *IntegerOptionBuilder
Choices restricts the option to a predefined set. Mutually exclusive with Autocomplete.
func (*IntegerOptionBuilder) Max ¶
func (b *IntegerOptionBuilder) Max(n int64) *IntegerOptionBuilder
Max sets the maximum value.
func (*IntegerOptionBuilder) Min ¶
func (b *IntegerOptionBuilder) Min(n int64) *IntegerOptionBuilder
Min sets the minimum value.
func (*IntegerOptionBuilder) NameLocalizations ¶
func (b *IntegerOptionBuilder) NameLocalizations(m map[discordgo.Locale]string) *IntegerOptionBuilder
NameLocalizations sets localized names.
func (*IntegerOptionBuilder) Required ¶
func (b *IntegerOptionBuilder) Required() *IntegerOptionBuilder
Required marks the option as required.
type Mentionable ¶
Mentionable is a resolved user-or-role union. Valid reports its invariant.
func (Mentionable) Valid ¶
func (m Mentionable) Valid() bool
Valid reports whether exactly one of User and Role is present.
type MessageSpec ¶
type MessageSpec struct {
Content string
Components []discordgo.MessageComponent
Embeds []*discordgo.MessageEmbed
Files []*discordgo.File
Attachments []*discordgo.MessageAttachment
AllowedMentions *discordgo.MessageAllowedMentions
Poll *discordgo.Poll
Ephemeral bool
}
MessageSpec is the single source of truth for an outgoing message or interaction response. It converts, without duplicating rules, into every discordgo payload shape used across the response lifecycle.
When Components contains Components V2 layout components, MessageSpec applies the IS_COMPONENTS_V2 flag, converts Content into a leading TextDisplay, and rejects payloads that Discord forbids (legacy embeds and polls).
func (MessageSpec) InteractionResponseData ¶
func (m MessageSpec) InteractionResponseData() (*discordgo.InteractionResponseData, error)
InteractionResponseData converts the spec into interaction response data, applying Components V2 normalization and flags.
func (MessageSpec) MessageEdit ¶
func (m MessageSpec) MessageEdit(channelID, messageID string) (*discordgo.MessageEdit, error)
MessageEdit converts the spec into a channel message edit for the given channel and message IDs.
func (MessageSpec) WebhookEdit ¶
func (m MessageSpec) WebhookEdit() (*discordgo.WebhookEdit, error)
WebhookEdit converts the spec into a webhook edit payload used to edit the original interaction response or a followup message.
func (MessageSpec) WebhookParams ¶
func (m MessageSpec) WebhookParams() (*discordgo.WebhookParams, error)
WebhookParams converts the spec into followup webhook params. Discord's webhook create endpoint has no poll field, so a poll is rejected here.
type Middleware ¶
Middleware wraps a Handler. The first middleware registered runs outermost.
func Logging ¶
func Logging(logger *slog.Logger) Middleware
Logging logs latency and errors without interaction tokens, content or options.
func Recovery ¶
func Recovery() Middleware
Recovery converts handler panics to PanicError; it never replies to a user. Router applies Recovery automatically, outside all configured middleware.
func RequireGuild ¶
func RequireGuild() Middleware
RequireGuild rejects interactions outside a guild.
func RequirePermissions ¶
func RequirePermissions(permissions int64) Middleware
RequirePermissions checks the invoking member's interaction permissions. Administrator bypasses the bit check. This does not check the bot's permissions.
type Modal ¶
type Modal struct {
// contains filtered or unexported fields
}
Modal is a validated modal ready to be shown with Context.ShowModal.
type ModalBuilder ¶
type ModalBuilder struct {
// contains filtered or unexported fields
}
ModalBuilder builds a modal from field components.
func Form ¶
func Form(customID, title string, fields ...Component) *ModalBuilder
Form starts a modal builder using modern Label-wrapped fields.
func (*ModalBuilder) Build ¶
func (b *ModalBuilder) Build() (Modal, error)
Build validates and returns the modal.
func (*ModalBuilder) Fields ¶
func (b *ModalBuilder) Fields(fields ...Component) *ModalBuilder
Fields appends additional fields to the form.
func (*ModalBuilder) MustBuild ¶
func (b *ModalBuilder) MustBuild() Modal
MustBuild is Build with panic on error, for static modal declarations.
type NumberOptionBuilder ¶
type NumberOptionBuilder struct {
// contains filtered or unexported fields
}
NumberOptionBuilder builds a floating-point command option.
func NumberOption ¶
func NumberOption(name, description string) *NumberOptionBuilder
NumberOption starts a number (float) option builder.
func (*NumberOptionBuilder) Autocomplete ¶
func (b *NumberOptionBuilder) Autocomplete() *NumberOptionBuilder
Autocomplete enables dynamic autocomplete. Mutually exclusive with Choices.
func (*NumberOptionBuilder) Choices ¶
func (b *NumberOptionBuilder) Choices(choices ...ChoiceValue) *NumberOptionBuilder
Choices restricts the option to a predefined set. Mutually exclusive with Autocomplete.
func (*NumberOptionBuilder) Max ¶
func (b *NumberOptionBuilder) Max(n float64) *NumberOptionBuilder
Max sets the maximum value.
func (*NumberOptionBuilder) Min ¶
func (b *NumberOptionBuilder) Min(n float64) *NumberOptionBuilder
Min sets the minimum value.
func (*NumberOptionBuilder) NameLocalizations ¶
func (b *NumberOptionBuilder) NameLocalizations(m map[discordgo.Locale]string) *NumberOptionBuilder
NameLocalizations sets localized names.
func (*NumberOptionBuilder) Required ¶
func (b *NumberOptionBuilder) Required() *NumberOptionBuilder
Required marks the option as required.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is a command option builder that produces a discordgo option.
type PanicError ¶
PanicError describes a recovered panic. Stack is only for server-side logging. Error intentionally excludes the panic value, which might contain secrets.
func (*PanicError) Error ¶
func (e *PanicError) Error() string
func (*PanicError) Unwrap ¶
func (e *PanicError) Unwrap() error
Unwrap exposes a panic error to errors.Is and errors.As.
type RouteBuilder ¶
type RouteBuilder struct {
// contains filtered or unexported fields
}
RouteBuilder binds named path parameters without treating parameter values as paths.
func Route ¶
func Route(pattern string) *RouteBuilder
Route starts a custom ID from a pattern such as /jobs/:jobID/save.
func (*RouteBuilder) Build ¶
func (b *RouteBuilder) Build() (CustomID, error)
Build validates the pattern and all bindings, and enforces the final ID limit.
func (*RouteBuilder) MustBuild ¶
func (b *RouteBuilder) MustBuild() CustomID
MustBuild is Build with panic on error, for static application configuration.
func (*RouteBuilder) Param ¶
func (b *RouteBuilder) Param(name, value string) *RouteBuilder
Param sets a raw, unescaped parameter. Build escapes each value exactly once.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is a shared routing core for commands, components, modals and autocomplete. Recovery is always outermost. Registration and dispatch are concurrency safe.
func NewRouter ¶
func NewRouter(middleware ...Middleware) *Router
NewRouter creates a router. Middleware executes in the order supplied.
func (*Router) Autocomplete ¶
func (r *Router) Autocomplete(path, option string, h Handler, m ...Middleware) error
Autocomplete registers a command path and focused option name.
func (*Router) Command ¶
func (r *Router) Command(path string, h Handler, m ...Middleware) error
Command registers a slash or context command path, e.g. "jobs search".
func (*Router) Component ¶
func (r *Router) Component(path string, h Handler, m ...Middleware) error
Component registers a custom ID route, with optional named path parameters.
func (*Router) Dispatch ¶
Dispatch routes an interaction and returns handler errors. It does not call OnError.
func (*Router) Group ¶
func (r *Router) Group(prefix string, m ...Middleware) *Group
Group creates a group whose registrations share this router.
func (*Router) Handle ¶
func (r *Router) Handle(s *discordgo.Session, i *discordgo.InteractionCreate)
Handle is a discordgo InteractionCreate handler. Attach using Session.AddHandler.
func (*Router) Modal ¶
func (r *Router) Modal(path string, h Handler, m ...Middleware) error
Modal registers a modal submission route.
func (*Router) OnError ¶
OnError sets the error hook. A nil hook uses structured server-side logging. Error hooks should not panic. No stack trace or automatic error reply is sent.
func (*Router) Use ¶
func (r *Router) Use(m ...Middleware)
Use appends global middleware, including for previously registered routes.
type RowBuilder ¶
type RowBuilder struct {
// contains filtered or unexported fields
}
RowBuilder builds an action row.
func Row ¶
func Row(children ...Component) *RowBuilder
Row groups interactive components. A row with a select must contain only it.
type SectionBuilder ¶
type SectionBuilder struct {
// contains filtered or unexported fields
}
SectionBuilder builds a section: 1-3 text displays plus an accessory.
func Section ¶
func Section(texts ...Component) *SectionBuilder
Section groups text displays with a button or thumbnail accessory.
func (*SectionBuilder) Accessory ¶
func (b *SectionBuilder) Accessory(a Component) *SectionBuilder
Accessory sets the section accessory (a button or thumbnail).
type SelectOptionBuilder ¶
type SelectOptionBuilder struct {
// contains filtered or unexported fields
}
SelectOptionBuilder builds a string select option.
func SelectOption ¶
func SelectOption(label, value string) *SelectOptionBuilder
SelectOption creates a string select option.
func (*SelectOptionBuilder) Default ¶
func (b *SelectOptionBuilder) Default() *SelectOptionBuilder
Default marks the option selected by default.
func (*SelectOptionBuilder) Description ¶
func (b *SelectOptionBuilder) Description(d string) *SelectOptionBuilder
Description sets the option description.
func (*SelectOptionBuilder) Emoji ¶
func (b *SelectOptionBuilder) Emoji(e discordgo.ComponentEmoji) *SelectOptionBuilder
Emoji sets the option emoji.
type SeparatorBuilder ¶
type SeparatorBuilder struct {
// contains filtered or unexported fields
}
SeparatorBuilder builds a separator.
func (*SeparatorBuilder) Divider ¶
func (b *SeparatorBuilder) Divider(on bool) *SeparatorBuilder
Divider toggles the visible divider line.
func (*SeparatorBuilder) Large ¶
func (b *SeparatorBuilder) Large() *SeparatorBuilder
Large sets large spacing; the default spacing is small.
type StringOptionBuilder ¶
type StringOptionBuilder struct {
// contains filtered or unexported fields
}
StringOptionBuilder builds a string command option.
func StringOption ¶
func StringOption(name, description string) *StringOptionBuilder
StringOption starts a string option builder.
func (*StringOptionBuilder) Autocomplete ¶
func (b *StringOptionBuilder) Autocomplete() *StringOptionBuilder
Autocomplete enables dynamic autocomplete. Mutually exclusive with Choices.
func (*StringOptionBuilder) Choices ¶
func (b *StringOptionBuilder) Choices(choices ...ChoiceValue) *StringOptionBuilder
Choices restricts the option to a predefined set. Mutually exclusive with Autocomplete.
func (*StringOptionBuilder) MaxLen ¶
func (b *StringOptionBuilder) MaxLen(n int) *StringOptionBuilder
MaxLen sets the maximum string length.
func (*StringOptionBuilder) MinLen ¶
func (b *StringOptionBuilder) MinLen(n int) *StringOptionBuilder
MinLen sets the minimum string length.
func (*StringOptionBuilder) NameLocalizations ¶
func (b *StringOptionBuilder) NameLocalizations(m map[discordgo.Locale]string) *StringOptionBuilder
NameLocalizations sets localized names.
func (*StringOptionBuilder) Required ¶
func (b *StringOptionBuilder) Required() *StringOptionBuilder
Required marks the option as required.
type StringSelectBuilder ¶
type StringSelectBuilder struct {
// contains filtered or unexported fields
}
StringSelectBuilder builds a string select menu with manual options.
func StringSelect ¶
func StringSelect(customID string) *StringSelectBuilder
StringSelect creates a string select menu.
func (*StringSelectBuilder) Disabled ¶
func (b *StringSelectBuilder) Disabled() *StringSelectBuilder
Disabled disables the select menu.
func (*StringSelectBuilder) MaxValues ¶
func (b *StringSelectBuilder) MaxValues(n int) *StringSelectBuilder
MaxValues sets the maximum number of selections.
func (*StringSelectBuilder) MinValues ¶
func (b *StringSelectBuilder) MinValues(n int) *StringSelectBuilder
MinValues sets the minimum number of selections.
func (*StringSelectBuilder) Options ¶
func (b *StringSelectBuilder) Options(options ...*SelectOptionBuilder) *StringSelectBuilder
Options sets the selectable options. Only string selects accept manual options.
func (*StringSelectBuilder) Placeholder ¶
func (b *StringSelectBuilder) Placeholder(p string) *StringSelectBuilder
Placeholder sets placeholder text.
func (*StringSelectBuilder) Required ¶
func (b *StringSelectBuilder) Required() *StringSelectBuilder
Required marks the select as required within a modal label.
type SubCommandBuilder ¶
type SubCommandBuilder struct {
// contains filtered or unexported fields
}
SubCommandBuilder builds a subcommand option.
func SubCommand ¶
func SubCommand(name, description string, options ...Option) *SubCommandBuilder
SubCommand starts a subcommand with its own leaf options.
func (*SubCommandBuilder) NameLocalizations ¶
func (b *SubCommandBuilder) NameLocalizations(m map[discordgo.Locale]string) *SubCommandBuilder
NameLocalizations sets localized names.
type SubCommandGroupBuilder ¶
type SubCommandGroupBuilder struct {
// contains filtered or unexported fields
}
SubCommandGroupBuilder builds a subcommand group option.
func SubCommandGroup ¶
func SubCommandGroup(name, description string, subcommands ...*SubCommandBuilder) *SubCommandGroupBuilder
SubCommandGroup starts a subcommand group containing subcommands.
func (*SubCommandGroupBuilder) NameLocalizations ¶
func (b *SubCommandGroupBuilder) NameLocalizations(m map[discordgo.Locale]string) *SubCommandGroupBuilder
NameLocalizations sets localized names.
type SyncOptions ¶
type SyncOptions struct {
// GuildID scopes synchronization to a guild. Empty means global commands.
GuildID string
// Delete removes remote commands that are no longer declared. When false,
// obsolete commands are reported but left in place.
Delete bool
}
SyncOptions configures command synchronization scope and deletion behavior.
type SyncPlan ¶
type SyncPlan struct {
Create []*discordgo.ApplicationCommand
Update []*discordgo.ApplicationCommand
Unchanged []*discordgo.ApplicationCommand
Delete []*discordgo.ApplicationCommand
}
SyncPlan is the result of diffing declared commands against remote commands. It is computed without any Discord API calls and is safe to inspect in tests.
func DiffCommands ¶
func DiffCommands(remote, desired []*discordgo.ApplicationCommand, deleteObsolete bool) SyncPlan
DiffCommands computes the synchronization plan between remote and desired commands, matching by name and type. When deleteObsolete is false, obsolete remote commands are omitted from Delete. This function performs no I/O.
func SyncCommands ¶
func SyncCommands(s *discordgo.Session, appID string, desired []*discordgo.ApplicationCommand, opts SyncOptions) (SyncPlan, error)
SyncCommands synchronizes declared commands with Discord: creating missing commands, updating divergent ones, and optionally deleting obsolete ones. It returns the plan that was applied. Commands with no diff are left untouched.
type TextDisplayBuilder ¶
type TextDisplayBuilder struct {
// contains filtered or unexported fields
}
TextDisplayBuilder builds a Components V2 text display.
type TextInputBuilder ¶
type TextInputBuilder struct {
// contains filtered or unexported fields
}
TextInputBuilder builds a text input for a modal field.
func TextInput ¶
func TextInput(customID string) *TextInputBuilder
TextInput creates a short text input. The visible label belongs to the Field.
func (*TextInputBuilder) MaxLen ¶
func (b *TextInputBuilder) MaxLen(n int) *TextInputBuilder
MaxLen sets the maximum length.
func (*TextInputBuilder) MinLen ¶
func (b *TextInputBuilder) MinLen(n int) *TextInputBuilder
MinLen sets the minimum length.
func (*TextInputBuilder) Paragraph ¶
func (b *TextInputBuilder) Paragraph() *TextInputBuilder
Paragraph switches to a multi-line paragraph style.
func (*TextInputBuilder) Placeholder ¶
func (b *TextInputBuilder) Placeholder(p string) *TextInputBuilder
Placeholder sets placeholder text.
func (*TextInputBuilder) Required ¶
func (b *TextInputBuilder) Required(required bool) *TextInputBuilder
Required sets whether the input must be filled.
func (*TextInputBuilder) Value ¶
func (b *TextInputBuilder) Value(v string) *TextInputBuilder
Value sets a prefilled value.
type ThumbnailBuilder ¶
type ThumbnailBuilder struct {
// contains filtered or unexported fields
}
ThumbnailBuilder builds a thumbnail accessory.
func Thumbnail ¶
func Thumbnail(url string) *ThumbnailBuilder
Thumbnail creates a thumbnail from a media URL.
func (*ThumbnailBuilder) Description ¶
func (b *ThumbnailBuilder) Description(d string) *ThumbnailBuilder
Description sets alt text.
func (*ThumbnailBuilder) Spoiler ¶
func (b *ThumbnailBuilder) Spoiler() *ThumbnailBuilder
Spoiler marks the thumbnail as a spoiler.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
basic
command
Command basic is a minimal DiscordKit bot: one slash command, synced on start.
|
Command basic is a minimal DiscordKit bot: one slash command, synced on start. |
|
components
command
Command components shows a Components V2 message, a component route with a typed custom ID, and a modal form round-trip.
|
Command components shows a Components V2 message, a component route with a typed custom ID, and a modal form round-trip. |