Documentation
¶
Index ¶
- func ContentTooLong(content string) bool
- func EmbedDescriptionTooLong(embed *disgord.Embed) bool
- func MsgQueryBuilder(s disgord.Session, msg *disgord.Message) disgord.MessageQueryBuilder
- func SendPaginated(ctx context.Context, params *WidgetParams, session disgord.Session, ...) error
- func SuppressEmbeds(session disgord.Session, msg *disgord.Message) (*disgord.Message, error)
- func UnsuppressEmbeds(session disgord.Session, msg *disgord.Message) (*disgord.Message, error)
- type AllowPredicateType
- type Bot
- type Command
- type Context
- func (ctx *Context) DeleteMsg(msg *disgord.Message) error
- func (ctx *Context) EditMsg(msg *disgord.Message, content string) (*disgord.Message, error)
- func (ctx *Context) MakeErrorEmbed(msg string) *disgord.Embed
- func (ctx *Context) React(msg *disgord.Message, emoji interface{}) error
- func (ctx *Context) Send(data ...interface{}) (*disgord.Message, error)
- func (ctx *Context) SendIncorrectUsageMsg() (*disgord.Message, error)
- func (ctx *Context) SendTimed(deleteAfter time.Duration, data ...interface{}) (*disgord.Message, error)
- func (ctx *Context) SendWidget(params *WidgetParams) error
- type DelCallbackType
- type Info
- type Message
- type Messager
- type MsgCallbackType
- type Page
- type Pages
- type WidgetParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContentTooLong ¶
ContentTooLong checks whether the given message content is longer than the acceptable limit.
func EmbedDescriptionTooLong ¶
EmbedDescriptionTooLong checks whether the given embed has description longer than the acceptable limit.
func MsgQueryBuilder ¶
MsgQueryBuilder returns a message query builder for the given message.
func SendPaginated ¶
func SendPaginated( ctx context.Context, params *WidgetParams, session disgord.Session, channelID disgord.Snowflake, ) error
SendPaginated sends a paginated message.
func SuppressEmbeds ¶
SuppressEmbeds suppresses all embeds on the given message.
Types ¶
type AllowPredicateType ¶
type AllowPredicateType func(*disgord.MessageReactionAdd) bool
AllowPredicateType is the predicate type that returns whether the operation on react is allowed.
type Bot ¶
Bot is a simple wrapper over a disgord Client. It is not protected by a mutex.
func (*Bot) AddCommand ¶
AddCommand adds a Command to the bot.
func (*Bot) OnMessageCreate ¶
func (bot *Bot) OnMessageCreate(handler func(*Context, *disgord.MessageCreate))
OnMessageCreate attaches a handler that is called on the message create event.
type Command ¶
Command represents a bot command.
func (*Command) IncorrectUsageMsg ¶
IncorrectUsageMsg returns a message that may be sent if the command is invoked with incorrect arguments.
type Context ¶
type Context struct { Bot *Bot Session disgord.Session Message *disgord.Message Command *Command Args []string Logger disgord.Logger }
Context is passed to all command handlers and contains fields relevant to the current command invocation.
func (*Context) MakeErrorEmbed ¶
MakeErrorEmbed prepares an error embed with the bot's support URL if it exists.
func (*Context) SendIncorrectUsageMsg ¶
SendIncorrectUsageMsg sends the incorrect usage message for the current command.
func (*Context) SendTimed ¶
func (ctx *Context) SendTimed( deleteAfter time.Duration, data ...interface{}, ) (*disgord.Message, error)
SendTimed sends a message and deletes it after a delay. Ignores any error if the delete fails.
func (*Context) SendWidget ¶
func (ctx *Context) SendWidget(params *WidgetParams) error
SendPaginated sends a paginated widget in the current channel.
type DelCallbackType ¶
type DelCallbackType func(*disgord.MessageReactionAdd)
DelCallbackType is the callback function type invoked on delete.
type Messager ¶
type Messager interface { Send(ctx context.Context, channelID disgord.Snowflake, params *disgord.CreateMessageParams) (*disgord.Message, error) Edit(ctx context.Context, msg *disgord.Message, content string, embed *disgord.Embed) (*disgord.Message, error) React(ctx context.Context, msg *disgord.Message, reaction string) error Unreact(ctx context.Context, msg *disgord.Message, reaction string) error UnreactUser(ctx context.Context, msg *disgord.Message, reaction string, userID disgord.Snowflake) error Delete(ctx context.Context, msg *disgord.Message) error AddReactListener(filter disgord.Middleware, ctrl disgord.HandlerCtrl, handler disgord.HandlerMessageReactionAdd) }
Messager wraps a disgord.Session to do message stuff. Used by widgets. Disgord's fluent interface is nice to use but such a pain to mock. Maybe switch to discordgo.
type MsgCallbackType ¶
MsgCallbackType is the callback function type invoked on message create.
type Page ¶
type Page struct { // The message for this page. Default *Message // The expanded message for this page, optional. Expanded *Message }
Page is a single widget page.
type Pages ¶
type Pages struct { Get func(pageNum int) *Page Total int First int Files []disgord.CreateMessageFileParams }
Pages is a set of pages, numbered 1 to Total. First is shown first.
type WidgetParams ¶
type WidgetParams struct { Pages *Pages // Optional callback invoked when the message is created. MsgCallback MsgCallbackType // After this duration the message will not be monitored. Lifetime time.Duration // Optional callback to be invoked when the message is deleted. DelCallback DelCallbackType // Optional check called before performing any operation (delete, prev, next). Defaults to // always allowed. AllowOp AllowPredicateType }
WidgetParams aggregates the params required for a paginated widget.