templates

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2018 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTooManyCalls = errors.New("Too many calls to this function")
View Source
var (
	StandardFuncMap = map[string]interface{}{
		"dict":       Dictionary,
		"sdict":      StringKeyDictionary,
		"cembed":     CreateEmbed,
		"json":       tmplJson,
		"in":         in,
		"title":      strings.Title,
		"add":        add,
		"roleAbove":  roleIsAbove,
		"adjective":  common.RandomAdjective,
		"randInt":    randInt,
		"shuffle":    shuffle,
		"seq":        sequence,
		"joinStr":    joinStrings,
		"str":        str,
		"lower":      strings.ToLower,
		"toString":   ToString,
		"toInt":      tmplToInt,
		"toInt64":    ToInt64,
		"formatTime": tmplFormatTime,
		"slice":      slice,
		"cslice":     CreateSlice,
	}
)

Functions

func CreateEmbed added in v1.4.1

func CreateEmbed(values ...interface{}) (*discordgo.MessageEmbed, error)

func CreateSlice added in v1.4.1

func CreateSlice(values ...interface{}) ([]interface{}, error)

func Dictionary

func Dictionary(values ...interface{}) (map[interface{}]interface{}, error)

dictionary creates a map[string]interface{} from the given parameters by walking the parameters and treating them as key-value pairs. The number of parameters must be even.

func RegisterSetupFunc

func RegisterSetupFunc(f ContextSetupFunc)

func StringKeyDictionary added in v1.4.1

func StringKeyDictionary(values ...interface{}) (map[string]interface{}, error)

func TODO

func TODO()

func ToInt64

func ToInt64(from interface{}) int64

func ToString

func ToString(from interface{}) string

Types

type Context

type Context struct {
	GS *dstate.GuildState
	CS *dstate.ChannelState

	MS  *dstate.MemberState
	Msg *discordgo.Message

	BotUser *discordgo.User

	ContextFuncs map[string]interface{}
	Data         map[string]interface{}

	MentionEveryone  bool
	MentionHere      bool
	MentionRoles     []int64
	MentionRoleNames []string

	DelResponse bool
	DelTrigger  bool

	DelTriggerDelay  int
	DelResponseDelay int

	Counters map[string]int

	EmebdsToSend []*discordgo.MessageEmbed
}

func NewContext

func NewContext(gs *dstate.GuildState, cs *dstate.ChannelState, ms *dstate.MemberState) *Context

func (*Context) Execute

func (c *Context) Execute(source string) (string, error)

func (*Context) IncreaseCheckCallCounter added in v0.29.1

func (c *Context) IncreaseCheckCallCounter(key string, limit int) bool

IncreaseCheckCallCounter Returns true if key is above the limit

type ContextSetupFunc

type ContextSetupFunc func(ctx *Context)

Jump to

Keyboard shortcuts

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