command

package
v0.0.0-...-77095fa Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorColor   = 0xcc0000
	InfoColor    = 0x0099ff
	SuccessColor = 0x4CAF50
	WarnColor    = 0xff9800
)

Color code for embed colors.

Variables

This section is empty.

Functions

func CreateEmbed

func CreateEmbed(color discord.Color, title string, bodyText string, footerText string) discord.Embed

CreateEmbed makes a new Discord embed with the given parameters.

func ListPlayers

func ListPlayers(state *state.State, cmd DiscordCommand) error

ListPlayers sends an RCON command to the Minecraft server to list all online players.

func ParseConfigCommand

func ParseConfigCommand(state *state.State, cmd DiscordCommand) error

ParseConfigCommand checks if the config option specified is valid, and updates the config accordingly.

func RemoveEmbed

func RemoveEmbed(state *state.State, channelID discord.ChannelID, commandID, embedID discord.MessageID) error

RemoveEmbed attempts to remove an embed after 30 seconds. If a message is unable to be deleted, an error is returned.

func SendCommandEmbed

func SendCommandEmbed(state *state.State, cmd DiscordCommand, embed discord.Embed) error

SendCommandEmbed sends the given embed to the specified Discord channel, and removes it after 30 seconds. If there was an error sending or removing the embed, an error is returned.

func SendMissingPermsEmbed

func SendMissingPermsEmbed(state *state.State, channelID discord.ChannelID, messageID discord.MessageID) error

SendMissingPermsEmbed creates a new embed for a player missing a permission. This embed is then sent to the channel, and the command and embed are removed after 30 seconds.

func ShowHelp

func ShowHelp(state *state.State, cmd DiscordCommand) error

ShowHelp creates and sends an embed listing all of the commands that can be used on Discord.

Types

type Cmd

type Cmd struct {
	Name string
}

Cmd is the type that all command handlers are.

type DiscordCommand

type DiscordCommand struct {
	Sender    discord.User
	Command   string
	Args      []string
	GuildID   discord.GuildID
	ChannelID discord.ChannelID
	MessageID discord.MessageID
}

DiscordCommand is a command sent by a user in Discord to be parsed and handled.

type Handler

type Handler struct {
	Name string
	Desc string
	Run  func(state *state.State, cmd DiscordCommand) error
}

Handler is the interface the each Discord command handler implements.

type Parser

type Parser struct{}

Parser is a command parser that handles sending commands to the appropriate handler.

func NewParser

func NewParser(configuration *config.RootConfig, logger *waterlog.WaterLog) *Parser

NewParser creates a new command parser with our commands registered.

func (*Parser) Parse

func (p *Parser) Parse(message discord.Message, state *state.State, resp chan bool)

Parse will turn a Discord message into a DiscordCommand to be passed on to a command handler.

Jump to

Keyboard shortcuts

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