Documentation
¶
Index ¶
- Variables
- type Arg
- type ArgumentType
- type BalanceArg
- type BetArg
- type CoinArg
- type CommandCategory
- type CommandHandler
- type Data
- type DurationArg
- type IntArg
- type MemberArg
- type ParsedArg
- func (p *ParsedArg) BalanceType() string
- func (p *ParsedArg) BetAmount() string
- func (p *ParsedArg) Coin() string
- func (p *ParsedArg) Duration() *time.Duration
- func (p *ParsedArg) Int64() int64
- func (p *ParsedArg) Member(guildID string) *discordgo.Member
- func (p *ParsedArg) String() string
- func (p *ParsedArg) User() *discordgo.User
- type RegisteredCommand
- type Run
- type StringArg
- type SummitCommand
- type UserArg
Constants ¶
This section is empty.
Variables ¶
var ( String = &StringArg{} Int = &IntArg{} User = &UserArg{} Member = &MemberArg{} Bet = &BetArg{} Duration = &DurationArg{} Coin = &CoinArg{} UserBalance = &BalanceArg{} )
var ( CategoryGeneral = CommandCategory{ Name: "General", Description: "General bot commands", } CategoryOwner = CommandCategory{ Name: "Owner", Description: "Mainanance and other bot-owner commands", } CategoryEconomy = CommandCategory{ Name: "Economy", Description: "Gambling and other economy based commands", } CategoryModeration = CommandCategory{ Name: "Moderation", Description: "Moderation and guild safety", } )
Functions ¶
This section is empty.
Types ¶
type Arg ¶
type Arg struct {
Name string
Type ArgumentType
Optional bool
}
Arg defines the structure to pass argument data with
type ArgumentType ¶
type BalanceArg ¶
type BalanceArg struct{}
func (*BalanceArg) Help ¶
func (b *BalanceArg) Help() string
func (*BalanceArg) ValidateArg ¶
func (b *BalanceArg) ValidateArg(arg *ParsedArg, data *Data) bool
type CommandCategory ¶
CommandCategory defines the available category types for commands
type CommandHandler ¶
type CommandHandler struct {
// contains filtered or unexported fields
}
CommandHandler defines the general command handler, the full instances of a command and a string map to retireve them
var CmdHndlr *CommandHandler
func NewCommandHandler ¶
func NewCommandHandler() *CommandHandler
NewCommandHandler creates a new command handler
func (*CommandHandler) HandleMessageCreate ¶
func (c *CommandHandler) HandleMessageCreate(s *discordgo.Session, event *discordgo.MessageCreate)
Handles all message create events to the bot, to pass them to child functions
func (*CommandHandler) RegisterCommands ¶
func (c *CommandHandler) RegisterCommands(cmds ...*SummitCommand)
RegisterCommands adds each command to the command handler
func (*CommandHandler) RegisteredCommands ¶
func (c *CommandHandler) RegisteredCommands() map[string]RegisteredCommand
RegisteredCommands returns an array of each RegisteredCommand
type Data ¶
type Data struct {
Session *discordgo.Session
GuildID string
ChannelID string
Author *discordgo.User
Message *discordgo.Message
ParsedArgs []*ParsedArg
Handler *CommandHandler
}
Data defines the required data passed to each command
type DurationArg ¶
type DurationArg struct{}
func (*DurationArg) Help ¶
func (d *DurationArg) Help() string
func (*DurationArg) ValidateArg ¶
func (d *DurationArg) ValidateArg(arg *ParsedArg, data *Data) bool
type ParsedArg ¶
type ParsedArg struct {
Name string
Type ArgumentType
Value interface{} // raw value provided by the user
}
ParsedArg represents a single argument parsed from a command invocation. Each argument contains its name, expected type, and the supplied value.
func (*ParsedArg) BalanceType ¶
BalanceType returns the argument's lowercase string value, trimmed of whitespace. Used for commands that expect a balance source argument such as "bank" or "cash".
func (*ParsedArg) BetAmount ¶
BetAmount returns the argument's lowercase string value, trimmed of any surrounding whitespace. Typically used for betting-related arguments (e.g., "all", "half", or a specific amount).
func (*ParsedArg) Coin ¶
Coin returns the argument's lowercase string value, trimmed of whitespace. Used for commands that require a coin flip guess, e.g., "heads" or "tails".
func (*ParsedArg) Duration ¶
Duration attempts to parse the argument into a time.Duration pointer. Returns nil if parsing fails or if the argument has no value.
func (*ParsedArg) Int64 ¶
Int64 converts and returns the argument's value as an int64. If the value is nil or non-numeric, it safely returns 0.
func (*ParsedArg) Member ¶
Member attempts to resolve the argument into a Discord guild member. If the value is nil or resolution fails, it returns nil.
type RegisteredCommand ¶
type RegisteredCommand struct {
Trigger string
Category CommandCategory
Aliases []string
Description string
Args []*Arg
}
RegisteredCommand defines the context required to access data surrounding a command
type SummitCommand ¶
type SummitCommand struct {
Command string
Category CommandCategory
Aliases []string
Description string
ArgsRequired int
Args []*Arg
Run Run
Data *Data
}
SummitCommand defines the general data that must be set during the addition of a new command