Documentation ¶
Index ¶
- Constants
- Variables
- func ChannelMessageSendEmbedReply(session *discordgo.Session, channelID string, embed *discordgo.MessageEmbed, ...) (*discordgo.Message, error)
- func CombinePermissions(perms ...int) int
- func IsMention(content string) bool
- type Argument
- type Command
- func (c *Command) AddAliases(aliases ...string) *Command
- func (c *Command) AddMiddlewares(middlewares ...CommandMiddleware) *Command
- func (c *Command) AddSubCommand(command *Command) *Command
- func (c *Command) SetDescription(description string) *Command
- func (c *Command) SetExecutor(executor CommandExecutor) *Command
- func (c *Command) SetName(name string) *Command
- type CommandExecutor
- type CommandFoundExecutor
- type CommandMiddleware
- type CommandNotFoundExecutor
- type Context
- type HelpSettings
- type Mention
- type MentionType
- type Pagination
- type PaginationPage
- type PrefixSettings
- type Router
Constants ¶
const ( ColorBlurple = 0x7289DA ColorFullWhite = 0xFFFFFF ColorDarkButNotBlack = 0x2C2F33 ColorNotQuiteBlack = 0x23272A ColorCrimson = 0xDC143C ColorDarkSalmon = 0xE9967A ColorLightCoral = 0xF08080 ColorPink = 0xFFC0CB ColorHotPink = 0xFF69B4 ColorDeepPink = 0xFF1493 ColorTomato = 0xFF6347 ColorGold = 0xFFD700 ColorLemonChiffon = 0xFFFACD ColorPapayawhip = 0xFFEFD5 ColorMoccasin = 0xFFE4B5 ColorDarkKhaki = 0xBDB76B ColorViolet = 0xEE82EE ColorMediumOrchid = 0xBA55D3 ColorIndigo = 0x4B0082 ColorSlateBlue = 0x6A5ACD ColorChartreuse = 0x7FFF00 ColorSeaGreen = 0x2E8B57 ColorAqua = 0x00FFFF ColorSteelBlue = 0x4682B4 ColorMaroon = 0x800000 ColorTeal = 0x008080 ColorMidnightBlue = 0x191970 ColorChocolate = 0xD2691E )
const ( EmojiFastBackward = "\u23EA" EmojiBackwardArrow = "\u2B05\uFE0F" EmojiForwardArrow = "\u27A1\uFE0F" EmojiFastForward = "\u23E9" )
Variables ¶
var ArgumentRegex = regexp.MustCompile(`[^" \n\r\t` + "`" + `]+|"[^"\n\r\t` + "`" + `]*"`)
Ugly as hell
var MentionChannelRegex = regexp.MustCompile(`<#(?P<Identifier>\d+)>`)
var MentionCustomEmojiAnimatedRegex = regexp.MustCompile(`<a:(?P<EmojiName>\w+):(?P<Identifier>\d+)>`)
var MentionCustomEmojiRegex = regexp.MustCompile(`<:(?P<EmojiName>\w+):(?P<Identifier>\d+)>`)
var MentionRoleRegex = regexp.MustCompile(`<@&(?P<Identifier>\d+)>`)
var MentionUserNicknameRegex = regexp.MustCompile(`<@!(?P<Identifier>\d+)>`)
var MentionUserRegex = regexp.MustCompile(`<@(?P<Identifier>\d+)>`)
Functions ¶
func ChannelMessageSendEmbedReply ¶
func ChannelMessageSendEmbedReply(session *discordgo.Session, channelID string, embed *discordgo.MessageEmbed, reference *discordgo.MessageReference) (*discordgo.Message, error)
func CombinePermissions ¶ added in v0.0.4
Types ¶
type Argument ¶
type Argument struct {
// contains filtered or unexported fields
}
func ParseArguments ¶
ParseArguments takes in an input string and parses out valid arguments for use in commands
func (Argument) GetBool ¶
GetBool attempts to parse the argument as a bool. Upon failure, returns nil
func (Argument) GetFloat ¶
GetFloat attempts to parse the argument as a float64. Upon failure, returns nil
func (Argument) GetInt ¶
GetInt attempts to parse the argument as a int64. Upon failure, returns nil
func (Argument) GetUint ¶
GetUint attempts to parse the argument as a uint64. Upon failure, returns nil
func (Argument) SurroundQuotes ¶
type Command ¶
type Command struct { Description string SubCommands map[string]*Command Aliases []string Name string Router *Router Session *discordgo.Session CommandExecutor CommandExecutor Middlwares []CommandMiddleware RequiredPermissions int64 // Use CombinePermissions to use multiple }
Command represents a discord command.
func NewCommand ¶
func (*Command) AddAliases ¶
func (*Command) AddMiddlewares ¶ added in v0.0.4
func (c *Command) AddMiddlewares(middlewares ...CommandMiddleware) *Command
func (*Command) AddSubCommand ¶
func (*Command) SetDescription ¶
func (*Command) SetExecutor ¶
func (c *Command) SetExecutor(executor CommandExecutor) *Command
type CommandExecutor ¶
type CommandExecutor func(ctx Context)
func DefaultCommandFound ¶ added in v0.0.9
func DefaultCommandFound(command *Command) CommandExecutor
func DefaultCommandNotFound ¶ added in v0.0.9
func DefaultCommandNotFound(parentCommand *Command, commandName string) CommandExecutor
type CommandFoundExecutor ¶ added in v0.0.9
type CommandFoundExecutor func(command *Command) CommandExecutor
type CommandMiddleware ¶ added in v0.0.4
type CommandMiddleware func(exe CommandExecutor) CommandExecutor
type CommandNotFoundExecutor ¶ added in v0.0.9
type CommandNotFoundExecutor func(parentCommand *Command, commandName string) CommandExecutor
type Context ¶
type Context struct { MessageCreate *discordgo.MessageCreate Command *Command Alias string Arguments []Argument }
func (*Context) ArgumentsString ¶
func (*Context) GetSession ¶
type HelpSettings ¶ added in v0.0.9
type HelpSettings struct { Enabled bool NotFoundExecutor CommandNotFoundExecutor FoundExecutor CommandFoundExecutor Aliases []string }
HelpSettings defines the settings for the router's built-in help command.
type Mention ¶
type Mention struct { MentionType MentionType ID string EmojiName string // The name of the emoji, if the mention is an emoji }
Mention represents a mention
func GetMention ¶
GetMention tries to make a Mention out of a string. Upon failure, return nil.
type MentionType ¶
type MentionType int
MentionType describes mention types
const ( MentionUser MentionType = 0 MentionUserNickname MentionType = 1 MentionChannel MentionType = 2 MentionRole MentionType = 3 MentionCustomEmoji MentionType = 4 MentionCustomEmojiAnimated MentionType = 5 )
func GetMentionType ¶
func GetMentionType(content string) MentionType
GetMentionType attempts to get the MentionType of a string, upon failure returns -1 as a MentionType
type Pagination ¶ added in v0.0.8
type Pagination struct { Embeds []PaginationPage RepliesTo *discordgo.MessageReference Router *Router Done bool Current uint ChannelID string MessageID string AuthorID string }
func (*Pagination) AddEmbeds ¶ added in v0.0.8
func (p *Pagination) AddEmbeds(embeds ...PaginationPage) *Pagination
func (*Pagination) SetRepliesTo ¶ added in v0.0.8
func (p *Pagination) SetRepliesTo(repliesTo *discordgo.MessageReference) *Pagination
func (*Pagination) Spawn ¶ added in v0.0.8
func (p *Pagination) Spawn() error
func (*Pagination) Update ¶ added in v0.0.8
func (p *Pagination) Update(index uint) error
type PaginationPage ¶ added in v0.0.8
type PaginationPage func() *discordgo.MessageEmbed
func EmbedToPage ¶ added in v0.0.8
func EmbedToPage(embed *discordgo.MessageEmbed) PaginationPage
type PrefixSettings ¶
type PrefixSettings struct { Prefixes []string IgnoreCase bool HandlePing bool // whether or not to treat a ping as a command prefix. Example: "@BotName help" does the same thing as "!help" if "!" is a prefix. }
PrefixSettings defines the settings for a router's prefixes
type Router ¶
type Router struct { Session *discordgo.Session Commands map[string]*Command PrefixSettings PrefixSettings BotsAllowed bool GlobalMiddlwares []CommandMiddleware RemoveHandlers []func() HelpSettings HelpSettings Paginations struct { Values map[string]*Pagination sync.RWMutex } }
Router is a command router
func NewRouter ¶
NewRouter creates a *Router and configures a *discordgo.Session to work with the command system
func (*Router) AddCommand ¶
func (*Router) CreatePagination ¶ added in v0.0.8
func (r *Router) CreatePagination(channelID, authorID string) *Pagination