Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidCommand = errors.New("error: invalid command")
)
Functions ¶
This section is empty.
Types ¶
type BufferedMessageWriter ¶
type BufferedMessageWriter struct { sync.RWMutex Session *discordgo.Session Channel string // contains filtered or unexported fields }
func NewBufferedMessageWriter ¶
func NewBufferedMessageWriter(session *discordgo.Session, channel string) *BufferedMessageWriter
func (*BufferedMessageWriter) Flush ¶
func (w *BufferedMessageWriter) Flush() (n int, err error)
type ErrorInvalidArgs ¶
type ErrorInvalidArgs struct { Session *discordgo.Session Event *discordgo.MessageCreate Message string Err error }
ErrorInvalidArgs indicates invalid arguments were passed in a command. You can call Unwrap() to get the underlying error.
func (ErrorInvalidArgs) Error ¶
func (err ErrorInvalidArgs) Error() string
func (ErrorInvalidArgs) Unwrap ¶
func (err ErrorInvalidArgs) Unwrap() error
Unwrap returns the underlying error behind ErrorInvalidArgs.
type Handler ¶
type Handler struct { // Root command factory for the bot. This needs to be set. RootFactory func(session *discordgo.Session, event *discordgo.MessageCreate) *cobra.Command // List of global prefixes for the bot. Prefixes []string // Function to load prefixes for a specific message. Use this to allow guild-specific prefixes. PrefixFunc func(session *discordgo.Session, event *discordgo.MessageCreate) []string // If the prefix function returns a list of prefixes, do these override the global list or append to it? PrefixFuncOverridesGlobals bool // Function that is called when the message event errors for some reason. ErrFunc func(err error) // Implement your own writer. Uses a BufferedMessageWriter by default. This is used for example by usage functions. OutWriterFactory func(s *discordgo.Session, channel string) io.Writer // contains filtered or unexported fields }
Handler represents a dgcobra Command Handler. This builds upon a RootCommandFactory.
To use this, use NewHandler() and add a prefix and a root command factory. Then call Handler.Start(). Examples in examples folder of this repository.
func NewHandler ¶
NewHandler creates a new handler with a given session.
type MessageWriter ¶
MessageWriter is a writer implementation for a discord channel. This is used for example by cobra to output usage and help.
func NewMessageWriter ¶
func NewMessageWriter(session *discordgo.Session, channel string) *MessageWriter
NewMessageWriter creates a message writer based on a given session and channel. Each write calls ChannelMessageSend on the session.