Documentation
¶
Overview ¶
Package dmsg provides a type-safe builder for Discord Components v2 messages.
It wraps discordgo types with a functional options pattern for clean, composable message construction. The API prevents common mistakes by using typed options that can only be applied to their corresponding components.
Basic usage:
response := dmsg.Response(
dmsg.Container(
dmsg.AccentColor(5763719),
dmsg.Section(
dmsg.Text("## Hello World"),
),
),
)
The package supports all Discord Components v2 features including containers, sections, buttons, thumbnails, galleries, and more.
Index ¶
- func Ephemeral(components ...Component) *discordgo.InteractionResponse
- func Response(components ...Component) *discordgo.InteractionResponse
- func Spoiler() interface{ ... }
- func Update(components ...Component) *discordgo.InteractionResponse
- type ButtonOption
- type ButtonStyle
- type Component
- func ActionRow(buttons ...Component) Component
- func Button(label, customID string, opts ...ButtonOption) Component
- func Container(opts ...ContainerOption) Component
- func LinkButton(label, url string, opts ...ButtonOption) Component
- func Separator(opts ...SeparatorOption) Component
- func TextDisplay(content string) Component
- func Thumbnail(url, description string, opts ...ThumbnailOption) Component
- type ContainerOption
- func AccentColor(color int) ContainerOption
- func ContainerActionRow(buttons ...Component) ContainerOption
- func ContainerFile(url string, opts ...FileOption) ContainerOption
- func ContainerGallery(items ...MediaItem) ContainerOption
- func ContainerSection(opts ...SectionOption) ContainerOption
- func ContainerSeparator(opts ...SeparatorOption) ContainerOption
- type FileOption
- type MediaItem
- type SectionOption
- type SeparatorOption
- type ThumbnailOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Ephemeral ¶
func Ephemeral(components ...Component) *discordgo.InteractionResponse
Ephemeral creates an ephemeral interaction response
func Response ¶
func Response(components ...Component) *discordgo.InteractionResponse
Response creates a standard interaction response
func Spoiler ¶
func Spoiler() interface {
ContainerOption
ThumbnailOption
FileOption
}
Spoiler marks a component as a spoiler (Container, Thumbnail, or File)
func Update ¶
func Update(components ...Component) *discordgo.InteractionResponse
Update creates an update message response
Types ¶
type ButtonOption ¶
type ButtonOption interface {
// contains filtered or unexported methods
}
ButtonOption configures a Button
type ButtonStyle ¶
type ButtonStyle int
ButtonStyle represents button visual styles
const ( Primary ButtonStyle = 1 Secondary ButtonStyle = 2 Success ButtonStyle = 3 Danger ButtonStyle = 4 )
type Component ¶
type Component = discordgo.MessageComponent
Component is any Discord message component
func Button ¶
func Button(label, customID string, opts ...ButtonOption) Component
Button creates an action button
func Container ¶
func Container(opts ...ContainerOption) Component
Container creates a container component
func LinkButton ¶
func LinkButton(label, url string, opts ...ButtonOption) Component
LinkButton creates a link button
func Separator ¶ added in v0.2.0
func Separator(opts ...SeparatorOption) Component
Separator creates a separator component for use at top-level
func TextDisplay ¶ added in v0.2.0
TextDisplay creates a text display component for use at top-level
func Thumbnail ¶
func Thumbnail(url, description string, opts ...ThumbnailOption) Component
Thumbnail creates a thumbnail component
type ContainerOption ¶
type ContainerOption interface {
// contains filtered or unexported methods
}
ContainerOption configures a Container
func AccentColor ¶
func AccentColor(color int) ContainerOption
AccentColor sets the container's accent color
func ContainerActionRow ¶ added in v0.2.0
func ContainerActionRow(buttons ...Component) ContainerOption
ContainerActionRow creates an action row with buttons for use inside containers
func ContainerFile ¶ added in v0.2.0
func ContainerFile(url string, opts ...FileOption) ContainerOption
ContainerFile creates a file component for use inside containers
func ContainerGallery ¶ added in v0.2.0
func ContainerGallery(items ...MediaItem) ContainerOption
ContainerGallery creates a media gallery component for use inside containers
func ContainerSection ¶ added in v0.2.0
func ContainerSection(opts ...SectionOption) ContainerOption
ContainerSection creates a section component for use inside containers
func ContainerSeparator ¶ added in v0.2.0
func ContainerSeparator(opts ...SeparatorOption) ContainerOption
ContainerSeparator creates a separator component for use inside containers
type FileOption ¶
type FileOption interface {
// contains filtered or unexported methods
}
FileOption configures a File
type SectionOption ¶
type SectionOption interface {
// contains filtered or unexported methods
}
SectionOption configures a Section
func SectionAccessory ¶ added in v0.2.0
func SectionAccessory(component Component) SectionOption
SectionAccessory sets the section's accessory (Button or Thumbnail)
func SectionText ¶ added in v0.2.0
func SectionText(content string) SectionOption
SectionText creates a text display component for use inside sections
type SeparatorOption ¶ added in v0.2.0
type SeparatorOption interface {
// contains filtered or unexported methods
}
SeparatorOption configures a Separator
func Spacing ¶
func Spacing(size discordgo.SeparatorSpacingSize) SeparatorOption
Spacing sets the separator spacing (1 = small, 2 = large)
func WithDivider ¶
func WithDivider(show bool) SeparatorOption
WithDivider sets whether to show the divider line
type ThumbnailOption ¶
type ThumbnailOption interface {
// contains filtered or unexported methods
}
ThumbnailOption configures a Thumbnail