Documentation
¶
Index ¶
- func CreatePagedEmbed(out *CommandOutput, s *discordgo.Session, m *discordgo.MessageCreate, ...)
- func GenerateOutputEmbed(out *CommandOutput, page *Page) (*discordgo.MessageEmbed, bool, bool)
- func HasNumArgs(a BotArgs, min, max int) bool
- func InitializeCommandRegistry(r *CommandRegistrar)
- type BotArgs
- type BotCommand
- type CommandArgument
- type CommandOutput
- func (o *CommandOutput) AddLine(line string)
- func (o *CommandOutput) Construct()
- func (o *CommandOutput) Index() (int, int)
- func (o *CommandOutput) Loglevel() int
- func (o *CommandOutput) NextPage() *Page
- func (o *CommandOutput) PreviousPage() *Page
- func (o *CommandOutput) RemoveLine()
- func (o *CommandOutput) SetLoglevel(l int)
- func (o *CommandOutput) ThisPage() *Page
- func (o *CommandOutput) UUID() string
- type CommandRegistrant
- func (c *CommandRegistrant) Help() *CommandOutput
- func (c *CommandRegistrant) Loglevel() int
- func (c *CommandRegistrant) Name() string
- func (c *CommandRegistrant) Registrar() *CommandRegistrar
- func (c *CommandRegistrant) SetLoglevel(l int)
- func (c *CommandRegistrant) Subcommands() (int, []*CommandRegistrant)
- func (c *CommandRegistrant) UUID() string
- type CommandRegistrar
- func (reg *CommandRegistrar) AllCommands() (int, []string)
- func (reg *CommandRegistrar) Command(n string) (*CommandRegistrant, error)
- func (reg *CommandRegistrar) IsRegistered(n string) bool
- func (reg *CommandRegistrar) Loglevel() int
- func (reg *CommandRegistrar) ProcessCommand(s *discordgo.Session, m *discordgo.MessageCreate, c ifaces.IConfigurator, ...) (string, ICommandError)
- func (reg *CommandRegistrar) Register(n, d, u string, a []CommandArgument, f BotCommand, owners ...string) error
- func (reg *CommandRegistrar) SetLoglevel(l int)
- func (reg *CommandRegistrar) UUID() string
- type ErrCommandDisabled
- type ErrCommandError
- type ErrInvalidAlias
- type ErrInvalidArgument
- type ErrInvalidCommand
- type ErrInvalidSubcommand
- type ErrInvalidTimezone
- type ErrUnauthorizedUsage
- type ICommandError
- type ICommandOutput
- type Page
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreatePagedEmbed ¶
func CreatePagedEmbed(out *CommandOutput, s *discordgo.Session, m *discordgo.MessageCreate, expirech chan struct{}, exitch chan struct{})
CreatePagedEmbed is used to create paginated embeds under a goroutine that will eventually expire and return. The operates by paging the provided *CommandOutput linked list, so long as the correct react is added to the initial embed message. To detect which reacts need to be added, the function generateOutputEmbed returns two boolean values.
The first boolean denotes previous, the second denotes next. These variables are doP and doN respectively.
func GenerateOutputEmbed ¶
func GenerateOutputEmbed(out *CommandOutput, page *Page) (*discordgo.MessageEmbed, bool, bool)
GenerateOutputEmbed creates a Discord embed from a CommandOutput, and outputs booleans depicting whether or not the Next or Previous page of output is available
func HasNumArgs ¶
HasNumArgs - Determine if a set of command arguments is between min and max
@a BotArgs Argument set to process @min int Minimum number of positional arguments @max int Maximum number of positional arguments You can use -1 in place of either min or max (or both) to disable the check for that range.
func InitializeCommandRegistry ¶
func InitializeCommandRegistry(r *CommandRegistrar)
InitializeCommandRegistry Register the commands for commands/everyonecmds
@r *CommandRegistrar The command resistrar that we are initializing
Types ¶
type BotCommand ¶
type BotCommand = func(*discordgo.Session, *discordgo.MessageCreate, BotArgs, ifaces.IConfigurator, *CommandRegistrant) (*CommandOutput, ICommandError)
BotCommand - Function signature for a bots primary function
type CommandArgument ¶
type CommandArgument [2]string
CommandArgument - Define an argument for a command
@0 Argument's invokation @1 A description of it's effect on the command
type CommandOutput ¶
type CommandOutput struct { Title string Description string Header string Quoted bool Monospace bool Status int Color int // contains filtered or unexported fields }
CommandOutput is an object describing a commands output
func (*CommandOutput) AddLine ¶
func (o *CommandOutput) AddLine(line string)
AddLine adds a line of output to the CommandOutput
func (*CommandOutput) Construct ¶
func (o *CommandOutput) Construct()
Construct processes the lines in a CommandOutput object and forms a linked list of Pages to paginate through on embeds
func (*CommandOutput) Index ¶
func (o *CommandOutput) Index() (int, int)
Index returns the current index, and the max page index
func (*CommandOutput) Loglevel ¶
func (o *CommandOutput) Loglevel() int
Loglevel - Return the current loglevel for the CommandRegistrant
func (*CommandOutput) NextPage ¶
func (o *CommandOutput) NextPage() *Page
NextPage returns a string of the next page, or an empty string if either the doesn't exist or is empty
func (*CommandOutput) PreviousPage ¶
func (o *CommandOutput) PreviousPage() *Page
PreviousPage returns a string of the previuos page, or an empty string if there is no previous page, or its empty
func (*CommandOutput) RemoveLine ¶
func (o *CommandOutput) RemoveLine()
RemoveLine removes the last line of output from the CommandOutput object
func (*CommandOutput) SetLoglevel ¶
func (o *CommandOutput) SetLoglevel(l int)
SetLoglevel - Set the current loglevel
func (*CommandOutput) ThisPage ¶
func (o *CommandOutput) ThisPage() *Page
ThisPage returns the current page
type CommandRegistrant ¶
type CommandRegistrant struct {
// contains filtered or unexported fields
}
CommandRegistrant - Command definition
func (*CommandRegistrant) Help ¶
func (c *CommandRegistrant) Help() *CommandOutput
Help - Return a commands help text with following markdown formatting preapplied
func (*CommandRegistrant) Loglevel ¶
func (c *CommandRegistrant) Loglevel() int
Loglevel - Return the current loglevel for the CommandRegistrant
func (*CommandRegistrant) Name ¶
func (c *CommandRegistrant) Name() string
Name - Return a commands name.
func (*CommandRegistrant) Registrar ¶
func (c *CommandRegistrant) Registrar() *CommandRegistrar
Registrar - Return a commands master CommandRegistrar
func (*CommandRegistrant) SetLoglevel ¶
func (c *CommandRegistrant) SetLoglevel(l int)
SetLoglevel - Set the current loglevel
func (*CommandRegistrant) Subcommands ¶
func (c *CommandRegistrant) Subcommands() (int, []*CommandRegistrant)
Subcommands - Return all the count of the subcommands added to a command, and their slice.
func (*CommandRegistrant) UUID ¶
func (c *CommandRegistrant) UUID() string
UUID - Return a commands name and guild information
type CommandRegistrar ¶
type CommandRegistrar struct { GuildID string // contains filtered or unexported fields }
CommandRegistrar - Guild specific container for commands and authorization level settings
func NewRegistrar ¶
func NewRegistrar(gid string, gs ifaces.IGameServer) *CommandRegistrar
NewRegistrar - Create and return a new instance of CommandRegistrar
@gid string ID string of the guild the CommandRegistrar belongs to
func Registrar ¶
func Registrar(gid string) (r *CommandRegistrar, err error)
Registrar - Return the Registrar that is associated with a specific guild
func (*CommandRegistrar) AllCommands ¶
func (reg *CommandRegistrar) AllCommands() (int, []string)
AllCommands - Return an int and a string slice. The int is how many commands are currently registered, and the slice is list of their names
func (*CommandRegistrar) Command ¶
func (reg *CommandRegistrar) Command(n string) (*CommandRegistrant, error)
Command - Return a pointer to a given registered CommandRegistrant
@n string Name of a command TODO: Consider refactoring this to make use of BotConfig.GetAliasesCommand
func (*CommandRegistrar) IsRegistered ¶
func (reg *CommandRegistrar) IsRegistered(n string) bool
IsRegistered - Return true if the command is registered, false if its not
@n string Name of a command
func (*CommandRegistrar) Loglevel ¶
func (reg *CommandRegistrar) Loglevel() int
Loglevel - Return the current loglevel for the CommandRegistrant
func (*CommandRegistrar) ProcessCommand ¶
func (reg *CommandRegistrar) ProcessCommand(s *discordgo.Session, m *discordgo.MessageCreate, c ifaces.IConfigurator, exitch chan struct{}) (string, ICommandError)
ProcessCommand - Processes a Discord message that has the configured prefix, and runs the correct command given its contents
@s *discordgo.Session Discordgo Session @m *discordgo.MessageCreate Discordgo message event @c IConfigurator Bot configuration pointer
func (*CommandRegistrar) Register ¶
func (reg *CommandRegistrar) Register(n, d, u string, a []CommandArgument, f BotCommand, owners ...string) error
Register - Register a command with the given options
@n string Name @d string Description text @u string Usage text @a []CommandArgument Valid arguments @f BotCommand Function to execute @owner ...string Registered command to add this subcommand to
func (*CommandRegistrar) SetLoglevel ¶
func (reg *CommandRegistrar) SetLoglevel(l int)
SetLoglevel - Set the current loglevel
func (*CommandRegistrar) UUID ¶
func (reg *CommandRegistrar) UUID() string
UUID - Return a commands name.
type ErrCommandDisabled ¶
type ErrCommandDisabled struct {
// contains filtered or unexported fields
}
ErrCommandDisabled describes an attempt to use a command that has been disabled
func (*ErrCommandDisabled) Command ¶
func (e *ErrCommandDisabled) Command() *CommandRegistrant
Command returns the command object that encountered an error
func (*ErrCommandDisabled) Emit ¶
func (e *ErrCommandDisabled) Emit(s *discordgo.Session, channel string)
Emit creates and outputs a CommandOutput with error formatting for the given error object.
func (*ErrCommandDisabled) Error ¶
func (e *ErrCommandDisabled) Error() string
func (*ErrCommandDisabled) Subcommand ¶
func (e *ErrCommandDisabled) Subcommand() *CommandRegistrant
Subcommand returns the subcommand object that encountered an error
type ErrCommandError ¶
type ErrCommandError struct {
// contains filtered or unexported fields
}
ErrCommandError describes a generic non-fatal error that occurred during command processing.
func (*ErrCommandError) Command ¶
func (e *ErrCommandError) Command() *CommandRegistrant
Command returns the command object that encountered an error
func (*ErrCommandError) Emit ¶
func (e *ErrCommandError) Emit(s *discordgo.Session, channel string)
Emit creates and outputs a CommandOutput with error formatting for the given error object.
func (*ErrCommandError) Error ¶
func (e *ErrCommandError) Error() string
func (*ErrCommandError) Subcommand ¶
func (e *ErrCommandError) Subcommand() *CommandRegistrant
Subcommand returns the subcommand object that encountered an error
type ErrInvalidAlias ¶
type ErrInvalidAlias struct {
// contains filtered or unexported fields
}
ErrInvalidAlias describes an attempt to use an alias that doesn't exist
func (*ErrInvalidAlias) Command ¶
func (e *ErrInvalidAlias) Command() *CommandRegistrant
Command returns the command object that encountered an error
func (*ErrInvalidAlias) Emit ¶
func (e *ErrInvalidAlias) Emit(s *discordgo.Session, channel string)
Emit creates and outputs a CommandOutput with error formatting for the given error object.
func (*ErrInvalidAlias) Error ¶
func (e *ErrInvalidAlias) Error() string
func (*ErrInvalidAlias) Subcommand ¶
func (e *ErrInvalidAlias) Subcommand() *CommandRegistrant
Subcommand returns the subcommand object that encountered an error
type ErrInvalidArgument ¶
type ErrInvalidArgument struct {
// contains filtered or unexported fields
}
ErrInvalidArgument describes an invalid attempt to use a command due to incorrect arguments
func (*ErrInvalidArgument) Command ¶
func (e *ErrInvalidArgument) Command() *CommandRegistrant
Command returns the command object that encountered an error
func (*ErrInvalidArgument) Emit ¶
func (e *ErrInvalidArgument) Emit(s *discordgo.Session, channel string)
Emit creates and outputs a CommandOutput with error formatting for the given error object.
func (*ErrInvalidArgument) Error ¶
func (e *ErrInvalidArgument) Error() string
func (*ErrInvalidArgument) Subcommand ¶
func (e *ErrInvalidArgument) Subcommand() *CommandRegistrant
Subcommand returns the subcommand object that encountered an error
type ErrInvalidCommand ¶
type ErrInvalidCommand struct {
// contains filtered or unexported fields
}
ErrInvalidCommand describes an attempt to run a command that doesn't exist
func (*ErrInvalidCommand) Command ¶
func (e *ErrInvalidCommand) Command() *CommandRegistrant
Command returns the command object that encountered an error
func (*ErrInvalidCommand) Emit ¶
func (e *ErrInvalidCommand) Emit(s *discordgo.Session, channel string)
Emit creates and outputs a CommandOutput with error formatting for the given error object.
func (*ErrInvalidCommand) Error ¶
func (e *ErrInvalidCommand) Error() string
func (*ErrInvalidCommand) Subcommand ¶
func (e *ErrInvalidCommand) Subcommand() *CommandRegistrant
Subcommand returns the subcommand object that encountered an error
type ErrInvalidSubcommand ¶
type ErrInvalidSubcommand struct {
// contains filtered or unexported fields
}
ErrInvalidSubcommand describes an error in which a provided subcommand does not exist
func (*ErrInvalidSubcommand) Command ¶
func (e *ErrInvalidSubcommand) Command() *CommandRegistrant
Command returns the command object that encountered an error
func (*ErrInvalidSubcommand) Emit ¶
func (e *ErrInvalidSubcommand) Emit(s *discordgo.Session, channel string)
Emit creates and outputs a CommandOutput with error formatting for the given error object.
func (*ErrInvalidSubcommand) Error ¶
func (e *ErrInvalidSubcommand) Error() string
func (*ErrInvalidSubcommand) Subcommand ¶
func (e *ErrInvalidSubcommand) Subcommand() *CommandRegistrant
Subcommand returns the subcommand object that encountered an error
type ErrInvalidTimezone ¶
type ErrInvalidTimezone struct {
// contains filtered or unexported fields
}
ErrInvalidTimezone describes an attempt to use an invalid timezone that was configured
func (*ErrInvalidTimezone) Command ¶
func (e *ErrInvalidTimezone) Command() *CommandRegistrant
Command returns the command object that encountered an error
func (*ErrInvalidTimezone) Emit ¶
func (e *ErrInvalidTimezone) Emit(s *discordgo.Session, channel string)
Emit creates and outputs a CommandOutput with error formatting for the given error object.
func (*ErrInvalidTimezone) Error ¶
func (e *ErrInvalidTimezone) Error() string
func (*ErrInvalidTimezone) Subcommand ¶
func (e *ErrInvalidTimezone) Subcommand() *CommandRegistrant
Subcommand returns the subcommand object that encountered an error
type ErrUnauthorizedUsage ¶
type ErrUnauthorizedUsage struct {
// contains filtered or unexported fields
}
ErrUnauthorizedUsage describes an attempt to run a command by someone unauthorized to do so
func (*ErrUnauthorizedUsage) Command ¶
func (e *ErrUnauthorizedUsage) Command() *CommandRegistrant
Command returns the command object that encountered an error
func (*ErrUnauthorizedUsage) Emit ¶
func (e *ErrUnauthorizedUsage) Emit(s *discordgo.Session, channel string)
Emit creates and outputs a CommandOutput with error formatting for the given error object.
func (*ErrUnauthorizedUsage) Error ¶
func (e *ErrUnauthorizedUsage) Error() string
func (*ErrUnauthorizedUsage) Subcommand ¶
func (e *ErrUnauthorizedUsage) Subcommand() *CommandRegistrant
Subcommand returns the subcommand object that encountered an error
type ICommandError ¶
type ICommandError interface { Command() *CommandRegistrant Subcommand() *CommandRegistrant Emit(*discordgo.Session, string) error }
ICommandError describes an error producable by a bot command
type ICommandOutput ¶
ICommandOutput descibes an interface to a commands output
Source Files
¶
- 000-init.go
- adminConfigCmnd.go
- checkHangCmnd.go
- commandOutput.go
- errors.go
- functions.go
- getAlliancesCmnd.go
- getCoordHistoryCmnd.go
- getIntegratedCmnd.go
- getJumpsCmnd.go
- getPlayersCmnd.go
- helpCmnd.go
- helperCmnds.go
- listCmnd.go
- logLevelCmnd.go
- modConfigCmnd.go
- outputEmbed.go
- pingCmnd.go
- playerCmnds.go
- pongCmnd.go
- rconCmnd.go
- registrant.go
- registrar.go
- reloadConfigCmnd.go
- sendBroadcastCmnd.go
- serverCmnd.go
- setAliasCmnd.go
- setChatChannelCmnd.go
- setLogChannelCmnd.go
- setPrefixCmnd.go
- setStatusChannel.go
- setTimezoneCmnd.go
- statusCmnd.go
- types.go