Documentation ¶
Index ¶
- Variables
- func FormatBotToken(t string) string
- type Argument
- func (arg *Argument) Channel(session *dgo.Session) (*dgo.Channel, error)
- func (arg *Argument) ChannelID() (string, error)
- func (arg *Argument) Float() (float64, error)
- func (arg *Argument) Int() (int, error)
- func (arg *Argument) Member(session *dgo.Session, guildID string) (*dgo.Member, error)
- func (arg *Argument) Role(session *dgo.Session, guildID string) (*dgo.Role, error)
- func (arg *Argument) RoleID() (string, error)
- func (arg *Argument) String() string
- func (arg *Argument) Type() ArgumentType
- func (arg *Argument) User(session *dgo.Session) (*dgo.User, error)
- func (arg *Argument) UserID() (string, error)
- type ArgumentType
- type Arguments
- type Bot
- func (bot *Bot) AddCommands(commands ...*Command) error
- func (bot *Bot) DefaultGuildConfig(guildID string) *GuildConfig
- func (bot *Bot) DefaultUserConfig(userID string) *UserConfig
- func (bot *Bot) GetGuildConfig(guildID string) *GuildConfig
- func (bot *Bot) GetUserConfig(userID string) *UserConfig
- func (bot *Bot) MessageCreateHandler() func(*dgo.Session, *dgo.MessageCreate)
- func (bot *Bot) Run() error
- type BotConfig
- type Command
- type Config
- type GuildConfig
- type MessageEventContext
- type Options
- type Router
- type Storage
- type UserConfig
- type Var
- type VarFolder
Constants ¶
This section is empty.
Variables ¶
var ( // RegexChannelMention matches strings that are channel mentions RegexChannelMention = regexp.MustCompile("<#(\\d+)>") // RegexUserMention matches strings that are user mentions RegexUserMention = regexp.MustCompile("<@!?(\\d+)>") // RegexRoleMention matches strings that are role mentions RegexRoleMention = regexp.MustCompile("<@&(\\d+)>") )
Functions ¶
func FormatBotToken ¶
FormatBotToken ensures that a bot token begins with "Bot", as required by the Discord API
Types ¶
type Argument ¶
type Argument struct {
// contains filtered or unexported fields
}
func (*Argument) Channel ¶
Channel parses the argument and returns a pointer to a channel struct, if the argument is of the correct type
func (*Argument) ChannelID ¶
ChannelID returns the argument as a channel ID, if the argument is of the correct type
func (*Argument) Float ¶
Float returns the argument as a float64, if the argument is of the correct type
func (*Argument) Member ¶
Member parses the argument and returns a pointer to a Member struct, if the argument is of the correct type
func (*Argument) Role ¶
Role parses the argument and returns a pointer to a Role struct, if the argument is of the correct type
func (*Argument) RoleID ¶
RoleID returns the argument as a role ID, if the argument is of the correct type
func (*Argument) Type ¶
func (arg *Argument) Type() ArgumentType
Type returns the type of the argument
type ArgumentType ¶
type ArgumentType string
const ( ArgumentTypeString ArgumentType = "string" ArgumentTypeInt ArgumentType = "int" ArgumentTypeFloat ArgumentType = "float" ArgumentTypeURL ArgumentType = "url" ArgumentTypeChannelMention ArgumentType = "channelMention" ArgumentTypeEveryoneMention ArgumentType = "everyoneMention" ArgumentTypeUserMention ArgumentType = "userMention" ArgumentTypeRoleMention ArgumentType = "roleMention" )
type Arguments ¶
type Arguments struct { Arguments []*Argument // contains filtered or unexported fields }
func ParseArguments ¶
ParseArguments parses a prefix-less string into a set of arguments
type Bot ¶
type Bot struct { Name string `json:"name"` Version string `json:"version"` Description string `json:"description"` Config *BotConfig `json:"config"` // contains filtered or unexported fields }
Bot represents a collection of commands
func (*Bot) AddCommands ¶
func (*Bot) DefaultGuildConfig ¶
func (bot *Bot) DefaultGuildConfig(guildID string) *GuildConfig
func (*Bot) DefaultUserConfig ¶
func (bot *Bot) DefaultUserConfig(userID string) *UserConfig
func (*Bot) GetGuildConfig ¶
func (bot *Bot) GetGuildConfig(guildID string) *GuildConfig
func (*Bot) GetUserConfig ¶
func (bot *Bot) GetUserConfig(userID string) *UserConfig
func (*Bot) MessageCreateHandler ¶
func (bot *Bot) MessageCreateHandler() func(*dgo.Session, *dgo.MessageCreate)
type BotConfig ¶
type BotConfig struct { DefaultPrefix string `json:"default_prefix"` Guilds map[string]*GuildConfig `json:"guilds"` Users map[string]*UserConfig `json:"users"` IgnoreDMs bool `json:"ignore_dms"` IgnoreMentions bool `json:"ignore_mentions"` IgnoreCase bool `json:"ignore_prefix_case"` }
type Config ¶
type Config struct {
*VarFolder
}
Config is a generic config struct which contains vars
type GuildConfig ¶
type MessageEventContext ¶
type MessageEventContext struct { Arguments *Arguments Command *Command GuildConfig *GuildConfig UserConfig *UserConfig Message *dgo.Message Session *dgo.Session Router *Router }
func (*MessageEventContext) RespondEmbed ¶
func (ctx *MessageEventContext) RespondEmbed(args ...interface{}) (*dgo.Message, error)
type Options ¶
type Options struct { Name string `json:"name"` Description string `json:"description"` Version string `json:"version"` Token string `json:"token"` DefaultPrefix string `json:"default_prefix"` Guilds map[string]*GuildConfig `json:"guilds"` Users map[string]*UserConfig `json:"users"` IgnoreDMs bool `json:"ignore_dms"` IgnoreMentions bool `json:"ignore_mentions"` IgnoreCase bool `json:"ignore_prefix_case"` }
Options provides a set of options for initialising Discord bots
type Router ¶
func (*Router) AddCommand ¶
type UserConfig ¶
type Var ¶
type Var struct { *VarFolder Key string `json:"key"` Value interface{} `json:"value"` // contains filtered or unexported fields }
Var implements a basic key-value structure that can also contain other Vars