Documentation
¶
Overview ¶
Package dgr provides a typed routing layer for discordgo interactions.
It registers Discord application commands from Go structs, parses interaction options into typed Context values, and provides helpers for replies and simple button components.
Index ¶
- func RegMessageCtx(d *Dgr, name string, handler func(c *Context[discordgo.Message]))
- func RegMessageCtxE(d *Dgr, name string, handler func(c *Context[discordgo.Message])) error
- func RegMsgCreate(d *Dgr, channelIDs []string, handler func(c *MsgCreateCtx))
- func RegMsgCreateE(d *Dgr, channelIDs []string, handler func(c *MsgCreateCtx)) error
- func RegSlash[T any](target SlashTarget, name string, description string, ...)
- func RegSlashE[T any](target SlashTarget, name string, description string, ...) error
- func RegUserCtx(d *Dgr, name string, handler func(c *Context[discordgo.User]))
- func RegUserCtxE(d *Dgr, name string, handler func(c *Context[discordgo.User])) error
- type Button
- type ButtonComponent
- type ButtonInvoker
- type ButtonRow
- type Choice
- type CommandGroup
- type Context
- type Dgr
- type InteractionUser
- type Mentionable
- type MentionableType
- type MsgCreateCtx
- type ReplyOption
- type SelectedChoice
- type SlashTarget
- type SubCommandGroup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegMessageCtx ¶
func RegMessageCtxE ¶
func RegMsgCreate ¶
func RegMsgCreate(d *Dgr, channelIDs []string, handler func(c *MsgCreateCtx))
func RegMsgCreateE ¶
func RegMsgCreateE(d *Dgr, channelIDs []string, handler func(c *MsgCreateCtx)) error
func RegSlash ¶
func RegSlash[T any](target SlashTarget, name string, description string, handler func(c *Context[T]))
Types ¶
type Button ¶
type Button[T any] struct { Text string CustomID string Style discordgo.ButtonStyle Handler func(c *Context[T]) Args T // contains filtered or unexported fields }
func (*Button[T]) Invoke ¶
func (b *Button[T]) Invoke(s *discordgo.Session, i *discordgo.Interaction)
func (*Button[T]) ToButtonComponent ¶
func (*Button[T]) ToComponent ¶
func (b *Button[T]) ToComponent() discordgo.MessageComponent
type ButtonComponent ¶
type ButtonInvoker ¶
type ButtonInvoker interface {
Invoke(s *discordgo.Session, i *discordgo.Interaction)
}
type ButtonRow ¶
type ButtonRow struct {
Buttons []ButtonComponent
}
func (*ButtonRow) ToComponent ¶
func (r *ButtonRow) ToComponent() discordgo.MessageComponent
type CommandGroup ¶
type CommandGroup struct {
// contains filtered or unexported fields
}
type Context ¶
type Context[T any] struct { Session *discordgo.Session Interaction *discordgo.Interaction Args T // contains filtered or unexported fields }
func (*Context[T]) NewButtonRow ¶
func (c *Context[T]) NewButtonRow(buttons ...ButtonComponent) (*ButtonRow, error)
type Dgr ¶
func (*Dgr) SyncCommands ¶
type Mentionable ¶
type Mentionable struct {
User *InteractionUser
Role *discordgo.Role
Type MentionableType
}
type MentionableType ¶
type MentionableType string
const ( MentionableTypeUser MentionableType = "USER" MentionableTypeRole MentionableType = "ROLE" )
type MsgCreateCtx ¶
type ReplyOption ¶
type ReplyOption func(*discordgo.InteractionResponseData)
func WithButton ¶
func WithButton[T any](button *Button[T]) ReplyOption
func WithButtons ¶
func WithButtons(row *ButtonRow) ReplyOption
func WithEmbeds ¶
func WithEmbeds(embeds ...*discordgo.MessageEmbed) ReplyOption
func WithEphemeral ¶
func WithEphemeral() ReplyOption
type SelectedChoice ¶
func SelectedChoiceOf ¶
func SelectedChoiceOf[T any](structPtr *T) *SelectedChoice
type SlashTarget ¶
type SlashTarget interface {
// contains filtered or unexported methods
}
type SubCommandGroup ¶
type SubCommandGroup struct {
// contains filtered or unexported fields
}
func SubGroup ¶
func SubGroup(group *CommandGroup, name string, description string) *SubCommandGroup
func SubGroupE ¶
func SubGroupE(group *CommandGroup, name string, description string) (*SubCommandGroup, error)
Click to show internal directories.
Click to hide internal directories.