Documentation
¶
Index ¶
- Variables
- type Category
- type CategoryConfig
- type Command
- type CommandConfig
- type CommandContext
- type Config
- type EightBallCommand
- type GiveCommand
- type HelpCommand
- type LanguageConfig
- type Middleware
- type PingPongCommand
- type Router
- func (router *Router) AddCommand(command *Command)
- func (router *Router) AddMiddleware(middleware Middleware)
- func (router *Router) AddRouterMiddleware(event string, middleware Middleware)
- func (router *Router) Init(session *discordgo.Session)
- func (router *Router) RefreshCategories()
- func (router *Router) RefreshCommand(command *Command)
- func (router *Router) RefreshCommands()
- func (router *Router) RemoveCommand(command *Command)
- type StatsCommand
Constants ¶
This section is empty.
Variables ¶
var ( //CATEGORY_MISC Miscellaneous commands CATEGORY_MISC = &Category{ Name: "Miscellaneous", Aliases: []string{"misc", "miscellaneous"}, Description: "Other stuff", ReactionEmoji: "✨", } //CATEGORY_CONFIG Bot config commands CATEGORY_CONFIG = &Category{ Name: "Bot config", Aliases: []string{"config", "botconfig", "bot_config"}, Description: "Bot config related commands", ReactionEmoji: "⚙️", } //CATEGORY_FUN Fun commands CATEGORY_FUN = &Category{ Name: "Fun", Aliases: []string{"fun"}, Description: "Haha funni", ReactionEmoji: "😀", } //CATEGORY_MOD Moderation commands CATEGORY_MOD = &Category{ Name: "Moderation", Aliases: []string{"moderation", "mod"}, Description: "Gang gang", ReactionEmoji: "🛡️", } //CATEGORY_GAMES Game commands CATEGORY_GAMES = &Category{ Name: "Games", Aliases: []string{"games"}, Description: "Simple games vs bot", ReactionEmoji: "🎮", } )
Functions ¶
This section is empty.
Types ¶
type CategoryConfig ¶
type CategoryConfig struct {
Description string `json:"description"`
}
CategoryConfig contains structure that categories used for their translation
type Command ¶
type Command struct { ID string Name string Category *Category Aliases []string CaseSensitive bool NeededPermissions int64 NSFWOnly bool Description string Usage string UsageOnError bool RateLimit struct { Limit int Duration time.Duration } LanguageSettings CommandConfig Handler func(*CommandContext) }
Command basic structure of a command
type CommandConfig ¶
type CommandConfig struct { Description string `json:"description,omitempty"` HelpCommand GiveCommand EightBallCommand PingPongCommand StatsCommand }
CommandConfig contains structure that commands used for their translation
type CommandContext ¶
type CommandContext struct { Session *discordgo.Session Router *Router Command *Command Arguments []string Event *discordgo.MessageCreate }
CommandContext contains necessary information about command and from where it comes from
type Config ¶
type Config struct { Prefix struct { Value []string `json:"prefixes"` CaseSensitive bool `json:"caseSensitive"` } `json:"prefix"` Language LanguageConfig `json:"language,omitempty"` }
Config main router config structure
func LoadConfig ¶
LoadConfig loads config from file
func (*Config) LoadLanguage ¶
LoadLanguage loads language from file to Config object
type EightBallCommand ¶
type EightBallCommand struct { NoArgumentsMessage string `json:"noArgumensMessage,omitempty"` Answers []string `json:"answers,omitempty"` }
EightBallCommand structure for 8ball command
type GiveCommand ¶
type GiveCommand struct { Response struct { Mention string `json:"mention"` NonMention string `json:"nonMention"` } `json:"response,omitempty"` }
GiveCommand structure for kitty,doggy etc commands
type HelpCommand ¶
type HelpCommand struct { Embed struct { Main struct { Title string `json:"title"` Description string `json:"description"` } `json:"main"` CategoryTitle string `json:"categoryTitle"` Name string `json:"name"` NoName string `json:"noName"` Description string `json:"description"` NoDescription string `json:"noDescription"` Usage string `json:"usage"` Aliases string `json:"aliases"` NoAliases string `json:"noAliases"` } `json:"embed,omitempty"` Page string `json:"page,omitempty"` CommandNotFound struct { Title string `json:"title"` Message string `json:"message"` } `json:"commandNotFound,omitempty"` }
HelpCommand structure for help command
type LanguageConfig ¶
type LanguageConfig struct { Errors struct { MessageSend string `json:"messageSend"` TooFewPermissions string `json:"tooFewPermissions"` NSFWOnly string `json:"nsfwOnly"` RateLimit string `json:"rateLimit"` } `json:"errors"` FunFacts []string `json:"funFacts"` Commands map[string]CommandConfig `json:"commands"` Categories map[string]CategoryConfig `json:"categories"` }
LanguageConfig contains config information that is mainly about translation
type Middleware ¶
type Middleware func(*CommandContext) (bool, func(*CommandContext))
Middleware handler used before running command
type PingPongCommand ¶
type PingPongCommand struct { TooManyMatchesMessage string `json:"tooManyMatches,omitempty"` Win struct { BotTrophyMessage string `json:"botTrophyMessage"` UserTrophyMessage string `json:"userTrophyMessage"` Message string `json:"message"` } `json:"win,omitempty"` ScoreboardMessage string `json:"scoreboardMessage,omitempty"` }
PingPongCommand structure for game pingpong command
type Router ¶
type Router struct { Prefixes []string CaseSensitive bool Middleware []Middleware Config *Config Commands []*Command Categories []*Category }
Router allows easier command handling by routing them from one place, it's even possible to use multiple routers e.g. for different prefixes/languages
func (*Router) AddCommand ¶
AddCommand Adds command to router
func (*Router) AddMiddleware ¶
func (router *Router) AddMiddleware(middleware Middleware)
AddMiddleware Adds middleware when executing command to router
func (*Router) AddRouterMiddleware ¶
func (router *Router) AddRouterMiddleware(event string, middleware Middleware)
AddRouterMiddleware Adds middleware to router on specified event
func (*Router) RefreshCategories ¶
func (router *Router) RefreshCategories()
RefreshCategories refreshes all categories
func (*Router) RefreshCommand ¶
RefreshCommand refreshes given command
func (*Router) RefreshCommands ¶
func (router *Router) RefreshCommands()
RefreshCommands does RefreshCommand to all commands in router
func (*Router) RemoveCommand ¶
RemoveCommand returns function that removes command from maps