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 ActionRow(buttons ...Component) interface{ ... }
- func Ephemeral(components ...Component) *discordgo.InteractionResponse
- func Response(components ...Component) *discordgo.InteractionResponse
- func Section(opts ...SectionOption) interface{ ... }
- func Separator(opts ...SeparatorOption) interface{ ... }
- func Spoiler() interface{ ... }
- func TextDisplay(content string) interface{ ... }
- func Update(components ...Component) *discordgo.InteractionResponse
- type ButtonOption
- type ButtonStyle
- type Component
- type ContainerOption
- type FileOption
- type MediaItem
- type SectionOption
- type SeparatorOption
- type ThumbnailOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActionRow ¶
func ActionRow(buttons ...Component) interface { Component ContainerOption }
ActionRow creates an action row with buttons (can be used top-level or in containers)
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 Section ¶
func Section(opts ...SectionOption) interface { Component ContainerOption }
Section creates a section component (can be used top-level or in containers)
func Separator ¶ added in v0.2.0
func Separator(opts ...SeparatorOption) interface { Component ContainerOption }
Separator creates a separator component (can be used top-level or in containers)
func Spoiler ¶
func Spoiler() interface {
ContainerOption
ThumbnailOption
FileOption
}
Spoiler marks a component as a spoiler (Container, Thumbnail, or File)
func TextDisplay ¶ added in v0.2.0
func TextDisplay(content string) interface { Component ContainerOption SectionOption }
TextDisplay creates a text display component (can be used top-level, in containers, or in sections)
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 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 File ¶
func File(url string, opts ...FileOption) ContainerOption
File creates a file component (for use in containers)
func Gallery ¶
func Gallery(items ...MediaItem) ContainerOption
Gallery creates a media gallery component (for use in 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 Accessory ¶
func Accessory(component Component) SectionOption
Accessory sets the section's accessory (Button or Thumbnail)
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