commands

package
v0.0.0-...-1bcce77 Latest Latest
Warning

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

Go to latest
Published: May 3, 2021 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Function    func(args string, message discordgo.Message, contextual bool, settings types.CommandSettings) (context bool, err error)
	Description string
	Settings    types.CommandSettings

	Cooldown time.Duration // DEPRECATED
}

Command represents a public, private or administrative command

type CommandManager

type CommandManager struct {
	Config    *types.Config
	Discord   *discord.Session
	Storage   storage.Storer
	Commands  map[string]Command
	Contexts  *cache.Cache
	Cooldowns map[string]time.Time
	Cache     *cache.Cache
}

CommandManager stores command state

func (*CommandManager) Init

func (cm *CommandManager) Init(
	config *types.Config,
	discord *discord.Session,
	api storage.Storer,
) (err error)

Init creates a command manager for the app

func (*CommandManager) LoadCommands

func (cm *CommandManager) LoadCommands()

LoadCommands is called on initialisation and is responsible for registering all commands and binding them to functions.

func (*CommandManager) OnMessage

func (cm *CommandManager) OnMessage(message discordgo.Message) (err error)

OnMessage is called on a command string to check whether it's a valid command and, if so, call the associated function. nolint:gocyclo

type CommandParametersRange

type CommandParametersRange struct {
	Minimum int
	Maximum int
}

CommandParametersRange represents minimum value and maximum value number of parameters for a command

type Hit

type Hit struct {
	Index     string  `json:"index"`
	ID        string  `json:"id"`
	Score     float64 `json:"score"`
	Locations struct {
		Description struct {
			Position []struct {
				Pos            int         `json:"pos"`
				Start          int         `json:"start"`
				End            int         `json:"end"`
				ArrayPositions interface{} `json:"array_positions"`
			} `json:"position"`
		} `json:"Description"`
	} `json:"locations"`
	Fragments struct {
		Description []string `json:"Description"`
	} `json:"fragments"`
	Sort []string `json:"sort"`
}

type Results

type Results struct {
	Status struct {
		Total      int `json:"total"`
		Failed     int `json:"failed"`
		Successful int `json:"successful"`
	} `json:"status"`
	Request struct {
		Query struct {
			Query string `json:"query"`
		} `json:"query"`
		Size      int `json:"size"`
		From      int `json:"from"`
		Highlight struct {
			Style  interface{} `json:"style"`
			Fields interface{} `json:"fields"`
		} `json:"highlight"`
		Fields           interface{} `json:"fields"`
		Facets           interface{} `json:"facets"`
		Explain          bool        `json:"explain"`
		Sort             []string    `json:"sort"`
		IncludeLocations bool        `json:"includeLocations"`
		SearchAfter      interface{} `json:"search_after"`
		SearchBefore     interface{} `json:"search_before"`
	} `json:"request"`
	Hits      []Hit       `json:"hits"`
	TotalHits int         `json:"total_hits"`
	MaxScore  float64     `json:"max_score"`
	Took      int64       `json:"took"`
	Facets    interface{} `json:"facets"`
}

Jump to

Keyboard shortcuts

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