Documentation ¶
Overview ¶
Package interactive contains basic API for creating menus with buttons and selects.
menu := NewInteractive(manager, interaction) yes := func(i *interactions.Interaction) bool { i.ComponentMessageUpdate().Content("Message successfully deleted!").Execute() return false } no := func(i *interactions.Interaction) bool { i.ComponentMessageUpdate().Content("Message deletion has been canceled!").Execute() return false } interaction.SendMessageReply(). Content("Are you sure you want to delete this message?"). ActionRow( components.NewButton(components.ButtonStyleSuccess).SetCustomID("yes").SetLabel("Yes!"), components.NewButton(components.ButtonStyleDanger).SetCustomID("nope").SetLabel("Nope!")). Execute() menu.SetFilter(func(i *interactions.Interaction) bool { return i.UserID() == interaction.UserID() }) menu.Start(interactive.Actions{ "yes": yes, "nope": no, })
The boolean output variable in action handler means if you want to listen for another interaction (if false, stops listening and exits a loop).
Index ¶
- type Actions
- type Handler
- type Interactive
- func (i *Interactive) Close()
- func (i *Interactive) OnTimeout(handler func(i *Interactive))
- func (i *Interactive) ResetTimeout()
- func (i *Interactive) SetFilter(handler func(i *interactions.Interaction) bool)
- func (i *Interactive) Start(actions Actions) error
- func (i *Interactive) WithTimeout(time time.Duration) *Interactive
- type Manager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler func(i *interactions.Interaction) bool
Return false if you no longer want to listen for interactions.
type Interactive ¶
type Interactive struct {
// contains filtered or unexported fields
}
func NewInteractive ¶
func NewInteractive(manager *Manager, i *interactions.Interaction) *Interactive
func (*Interactive) Close ¶
func (i *Interactive) Close()
func (*Interactive) OnTimeout ¶
func (i *Interactive) OnTimeout(handler func(i *Interactive))
func (*Interactive) ResetTimeout ¶
func (i *Interactive) ResetTimeout()
func (*Interactive) SetFilter ¶
func (i *Interactive) SetFilter(handler func(i *interactions.Interaction) bool)
func (*Interactive) Start ¶
func (i *Interactive) Start(actions Actions) error
func (*Interactive) WithTimeout ¶
func (i *Interactive) WithTimeout(time time.Duration) *Interactive
Click to show internal directories.
Click to hide internal directories.