commands

package
v0.0.0-...-f3179c4 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatReactionRankings

func FormatReactionRankings(r []storage.TopReactionEntry, reaction string, s *discord.Session) (embed *discordgo.MessageEmbed, err error)

func FormatUserReactions

func FormatUserReactions(reactions *[]storage.ReactionCounter, author *discordgo.User, session *discord.Session) (embed *discordgo.MessageEmbed, err error)

Types

type Command

type Command struct {
	Function         func(interaction *discordgo.InteractionCreate, args map[string]*discordgo.ApplicationCommandInteractionDataOption, settings types.CommandSettings) (context bool, err error)
	Name             string
	Description      string
	Settings         types.CommandSettings
	Options          []*discordgo.ApplicationCommandOption
	IsAdministrative bool
}

Command represents a public, private or administrative command

type CommandManager

type CommandManager struct {
	Config    *types.Config
	Discord   *discord.Session
	Storage   storage.Storer
	Forum     *forum.ForumClient
	Commands  []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,
	fc *forum.ForumClient,
) (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

func (*CommandManager) TryFindAndFireCommand

func (cm *CommandManager) TryFindAndFireCommand(interaction *discordgo.InteractionCreate)

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 {
	Url                  string  `json:"url"`
	Title                string  `json:"title"`
	Description          string  `json:"desc"`
	TitleFragments       string  `json:"title_fragment"`
	DescriptionFragments string  `json:"desc_fragment"`
	Score                float64 `json:"score"`
}

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"`
	Took      int64 `json:"took"`
}

Jump to

Keyboard shortcuts

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