Documentation ¶
Index ¶
- Constants
- func RunBot(settings *BotSettings) error
- type Bot
- func (bot *Bot) GetServiceData(srvName string, key string) string
- func (bot *Bot) RegisterCommand(cmd *Command) error
- func (bot *Bot) RegisterCommandPrefix(prefix string) error
- func (bot *Bot) RegisterEventHook(hook *EventHook) error
- func (bot *Bot) RegisterService(srv *Service) error
- func (bot *Bot) Run() error
- func (bot *Bot) SetServiceData(srvName string, key string, val string) string
- type BotSettings
- type Command
- type CommandActionFunc
- type CommandPermission
- type Context
- type DuplicateCommandError
- type DuplicateCommandPrefixError
- type DuplicateEventHookError
- type DuplicateServiceError
- type EventHandlerFunc
- type EventHook
- type Service
- type ServiceActionFunc
- type TooShortCommandPrefixError
Constants ¶
const DefaultCommandPrefix = "!"
Variables ¶
This section is empty.
Functions ¶
func RunBot ¶
func RunBot(settings *BotSettings) error
Types ¶
type Bot ¶
type Bot struct { *BotSettings Discord *discordgo.Session User *discordgo.User // contains filtered or unexported fields }
Bot is an active bot session.
func (*Bot) GetServiceData ¶
Get a data value from existing services
func (*Bot) RegisterCommand ¶
func (*Bot) RegisterCommandPrefix ¶
func (*Bot) RegisterEventHook ¶
func (*Bot) RegisterService ¶
type BotSettings ¶
type BotSettings struct { Token string Commands []*Command EventHooks []*EventHook Services []*Service // Every option here is added to an array of accepted prefixes later // So you can set values in CommandPrefix and/or CommandPrefixes at the same time // This also regards the option CommandInvokedByMention CommandPrefix string CommandPrefixes []string CommandInvokedByMention bool }
BotSettings contains the definition of bot behavior. It is used for creating the actual bot.
type Command ¶
type Command struct { // Name of the command Name string // Aliases for the command Aliases []string // Description of what the command does Description string // Check if this command is deactivated Deactivated bool // Command behavior Action CommandActionFunc // Command permissions Permission CommandPermission }
Command is the interface that every bot command must implement.
type CommandActionFunc ¶
CommandActionFunc is the action to execute when a command is called.
type CommandPermission ¶
type CommandPermission struct { // Used for specific User banning on a per command basis BannedUserIDs []string // *discordgo.User.ID // Users that has been given access to a command even though they do not have the required role. AllowedUserIDs []string // *discordgo.User.ID // What roles can run this command AllowedRoles []string // *discordgo.GuildRole.Role.ID }
Designed to handle X guilds per bot instance
func NewCommandPermission ¶
func NewCommandPermission() CommandPermission
type Context ¶
Context is a type that is passed to every handler in a bot application. It can be used to refer back to main components.
type DuplicateCommandError ¶
Duplicate command error
func (DuplicateCommandError) Error ¶
func (e DuplicateCommandError) Error() string
type DuplicateCommandPrefixError ¶
type DuplicateCommandPrefixError struct {
Prefix string
}
Duplicate command prefix error
func (DuplicateCommandPrefixError) Error ¶
func (e DuplicateCommandPrefixError) Error() string
type DuplicateEventHookError ¶
Duplicate event hook error
func (DuplicateEventHookError) Error ¶
func (e DuplicateEventHookError) Error() string
type DuplicateServiceError ¶
Duplicate event hook error
func (DuplicateServiceError) Error ¶
func (e DuplicateServiceError) Error() string
type EventHandlerFunc ¶
type EventHandlerFunc func(ctx *Context, ev *events.DiscordEvent) (handled bool, err error)
EventHandlerFunc handles a discord event and returns whether it handles the event type and if an error occured.
type EventHook ¶
type EventHook struct { // Name of the hook Name string // Description of what the hook does Description string // Events that the hook should react to Events []events.EventType // Check if this hook is deactivated Deactivated bool // Command behavior OnEvent EventHandlerFunc }
Hook interface for anything that is supposed to react on a event, besides commands.
type ServiceActionFunc ¶
CommandActionFunc is the action to execute when a command is called.
type TooShortCommandPrefixError ¶
type TooShortCommandPrefixError struct {
Prefix string
}
Too short command prefix error
func (TooShortCommandPrefixError) Error ¶
func (e TooShortCommandPrefixError) Error() string