commands

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BalanceCommand

func BalanceCommand(commandMessage CommandMessage)

BalanceCommand shows you your balance.

func HelpCommand

func HelpCommand(commandMessage CommandMessage)

HelpCommand displays information about all commands.

func LordCommand

func LordCommand(commandMessage CommandMessage)

LordCommand replies with the username of the player with the most tacos in the guild.

func PayCommand

func PayCommand(commandMessage CommandMessage)

PayCommand allows you to transfer funds to another user.

func PingCommand

func PingCommand(commandMessage CommandMessage)

PingCommand sends a "Pong!" message back.

Types

type Command

type Command func(CommandMessage)

Command is a function that requires CommandMessage as its argument.

type CommandHandler

type CommandHandler struct {
	Database *storage.Database
	// contains filtered or unexported fields
}

CommandHandler stores command information/state.

func New

func New(database *storage.Database, config Config) (ch *CommandHandler)

New creates a new command handler.

func (CommandHandler) Get

func (ch CommandHandler) Get(name string) (*CommandInfo, bool)

Get retrieves the Command (Data type) from the CommandMap map.

func (CommandHandler) Process

func (ch CommandHandler) Process(session *discordgo.Session, message *discordgo.MessageCreate)

Process processes incoming messages and calls the command's function.

func (CommandHandler) Register

func (ch CommandHandler) Register(name string, commandInfo CommandInfo)

Register registers a command to be handled by the command handler.

type CommandInfo

type CommandInfo struct {
	Function    Command
	Description string
	Hidden      bool
	Cooldown    map[*discordgo.Guild]time.Time
}

CommandInfo stores information about a command.

type CommandMap

type CommandMap map[string]CommandInfo

CommandMap stores all command functions by their name.

type CommandMessage

type CommandMessage struct {
	CommandHandler *CommandHandler
	Session        *discordgo.Session
	Guild          *discordgo.Guild
	Message        *discordgo.MessageCreate
	Args           []string
}

CommandMessage stores information about the message sent by the player.

type Config

type Config struct {
	Prefix   string
	Cooldown time.Duration
}

Config stores command handler configurations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL