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 Thumbnail(url, description string, opts ...ThumbnailOption) Component
- type ContainerOption
- func AccentColor(color int) ContainerOption
- func Actions(buttons ...Component) ContainerOption
- func Divider(opts ...DividerOption) ContainerOption
- func File(url string, opts ...FileOption) ContainerOption
- func Gallery(items ...MediaItem) ContainerOption
- func Section(opts ...SectionOption) ContainerOption
- type DividerOption
- type FileOption
- type MediaItem
- type SectionOption
- 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 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 Actions ¶
func Actions(buttons ...Component) ContainerOption
Actions creates an action row with buttons for use inside containers
func Divider ¶
func Divider(opts ...DividerOption) ContainerOption
Divider creates a separator component
func Gallery ¶
func Gallery(items ...MediaItem) ContainerOption
Gallery creates a media gallery component
func Section ¶
func Section(opts ...SectionOption) ContainerOption
Section creates a section component
type DividerOption ¶
type DividerOption interface {
// contains filtered or unexported methods
}
DividerOption configures a Divider (Separator)
func Spacing ¶
func Spacing(size discordgo.SeparatorSpacingSize) DividerOption
Spacing sets the divider spacing (1 = small, 2 = large)
func WithDivider ¶
func WithDivider(show bool) DividerOption
WithDivider sets whether to show the divider line
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 ThumbnailOption ¶
type ThumbnailOption interface {
// contains filtered or unexported methods
}
ThumbnailOption configures a Thumbnail