Documentation ¶
Index ¶
- func CanBan(s *discordgo.Session, guildID string, m *discordgo.Member) bool
- func HasPerm(userPerms, hasPerm int64) bool
- func IsChannelAdmin(s *discordgo.Session, channelID, userID string) bool
- func WaitForMessage(s *discordgo.Session) chan *discordgo.MessageCreate
- func WaitForUserMessage(s *discordgo.Session, userID string) chan *discordgo.MessageCreate
- func WaitForUserReact(s *discordgo.Session, userID string) chan *discordgo.MessageReactionAdd
- type Command
- type CommandHandler
- type Context
- type Middleware
- type Router
- func (r *Router) AddGlobalCommands(commands ...Command)
- func (r *Router) AddGuildCommands(commands ...Command)
- func (r *Router) CreateGlobalCommands(s *discordgo.Session)
- func (r *Router) CreateGuildCommands(s *discordgo.Session, guildID string)
- func (r *Router) DefaultCommandExecutor(session *discordgo.Session, vars interface{})
- func (r *Router) StartWithDefault(session *discordgo.Session, vars interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WaitForMessage ¶
func WaitForMessage(s *discordgo.Session) chan *discordgo.MessageCreate
func WaitForUserMessage ¶
func WaitForUserMessage(s *discordgo.Session, userID string) chan *discordgo.MessageCreate
func WaitForUserReact ¶
func WaitForUserReact(s *discordgo.Session, userID string) chan *discordgo.MessageReactionAdd
Types ¶
type Command ¶
type Command struct { // Discordgo slash command *discordgo.ApplicationCommand // The command's middlewares Middlewares []Middleware // The command's handler function Handler CommandHandler }
A Command has an underlying discordgo.ApplicationCommand pointer, middlewares, and a handler.
func (*Command) ApplyMiddlewares ¶
func (c *Command) ApplyMiddlewares() CommandHandler
ApplyMiddlewares applies all of the commands middlewares to it's handler
type CommandHandler ¶
A CommandHandler is just a function that handles command invokes
func IsAdmin ¶
func IsAdmin(h CommandHandler) CommandHandler
IsAdmin is a builtin middleware that checks if the caller of the command is an admin. It will only run the root handler if they are. If not, it will inform them they lack permissions.
type Context ¶
type Context struct { // Discordgo session *discordgo.Session // Interaction of command *discordgo.Interaction // An interface for any data you want to pass to your commands Vars interface{} }
Context is a command context passed into all command handlers.
type Middleware ¶
type Middleware func(CommandHandler) CommandHandler
Middlewares wrap your command handlers to perform checks before the root handler is called.
type Router ¶
type Router struct { // The commands you want to add globally GlobalCommands []Command // The commands you want to add to guilds GuildCommands []Command }
A router stores your commands and handles InteractionCreate events
func (*Router) AddGlobalCommands ¶
AddGlobalCommands appends your commands to router.GlobalCommands. commands: The commands you want to add.
func (*Router) AddGuildCommands ¶
AddGuildCommands appends your commands to router.GuildCommands. commands: The commands you want to add.
func (*Router) CreateGlobalCommands ¶
CreateGlobalCommands deletes old global commands and adds all new ones. If you don't want to delete you can add commands manually. s: the session you want to create the commands on.
func (*Router) CreateGuildCommands ¶
CreateGuildCommands deletes old guild commands and adds all new ones. If you don't want to delete you can add commands manually. s: the session you want to create the commands on. guildID: the snowflake of the guild you want to add the commands to.
func (*Router) DefaultCommandExecutor ¶
DefaultCommandExecutor adds the router's default command executor to the session. This will check InteractionCreate events for your commands being called, apply middlewares, and run the called command's handler. session: The session you want to add the executor to. vars: Can be anything you want (like a database you want your commands to have access to).
func (*Router) StartWithDefault ¶
StartWithDefault adds handlers to session. Call this before openning session. session: The session you want to run the router on. vars: Can be anything you want (like a database you want your commands to have access to).