Documentation ¶
Index ¶
- Constants
- Variables
- func CreateEmbed(values ...interface{}) (*discordgo.MessageEmbed, error)
- func CreateMessageEdit(values ...interface{}) (*discordgo.MessageEdit, error)
- func CreateMessageSend(values ...interface{}) (*discordgo.MessageSend, error)
- func KindOf(input interface{}, flag ...bool) (string, error)
- func LimitWriter(w io.Writer, n int64) io.Writer
- func MaybeScheduledDeleteMessage(guildID, channelID, messageID int64, delaySeconds int)
- func RegisterSetupFunc(f ContextSetupFunc)
- func TODO()
- func ToByte(from interface{}) []byte
- func ToDuration(from interface{}) time.Duration
- func ToFloat64(from interface{}) float64
- func ToInt64(from interface{}) int64
- func ToRune(from interface{}) []rune
- func ToString(from interface{}) string
- type Context
- func (c *Context) ChannelArg(v interface{}) int64
- func (c *Context) ChannelArgNoDM(v interface{}) int64
- func (c *Context) Execute(source string) (string, error)
- func (c *Context) ExecuteAndSendWithErrors(source string, channelID int64) error
- func (c *Context) IncreaseCheckCallCounter(key string, limit int) bool
- func (c *Context) IncreaseCheckCallCounterPremium(key string, normalLimit, premiumLimit int) bool
- func (c *Context) IncreaseCheckGenericAPICall() bool
- func (c *Context) IncreaseCheckStateLock() bool
- func (c *Context) LogEntry() *logrus.Entry
- func (c *Context) MessageSend(content string) *discordgo.MessageSend
- func (c *Context) Parse(source string) (*template.Template, error)
- func (c *Context) SendResponse(content string) (*discordgo.Message, error)
- type ContextSetupFunc
- type CtxChannel
- type CtxExecReturn
- type CtxMember
- type Dict
- type SDict
- type Slice
Constants ¶
const ( MaxOpsNormal = 1000000 MaxOpsPremium = 2500000 )
const MaxStringLength = 1000000
Variables ¶
var ErrStringTooLong = errors.NewPlain("String is too long (max 1MB)")
var ErrTooManyAPICalls = errors.New("Too many potential discord api calls function")
var ErrTooManyCalls = errors.New("Too many calls to this function")
var GuildPremiumFunc func(guildID int64) (bool, error)
set by the premium package to return wether this guild is premium or not
var ( StandardFuncMap = map[string]interface{}{ "str": ToString, "toString": ToString, "toInt": tmplToInt, "toInt64": ToInt64, "toFloat": ToFloat64, "toDuration": ToDuration, "toRune": ToRune, "toByte": ToByte, "joinStr": joinStrings, "lower": strings.ToLower, "upper": strings.ToUpper, "slice": slice, "urlescape": url.PathEscape, "split": strings.Split, "title": strings.Title, "add": add, "sub": tmplSub, "mult": tmplMult, "div": tmplDiv, "mod": tmplMod, "fdiv": tmplFDiv, "sqrt": tmplSqrt, "pow": tmplPow, "log": tmplLog, "round": tmplRound, "roundCeil": tmplRoundCeil, "roundFloor": tmplRoundFloor, "roundEven": tmplRoundEven, "humanizeThousands": tmplHumanizeThousands, "dict": Dictionary, "sdict": StringKeyDictionary, "structToSdict": StructToSdict, "cembed": CreateEmbed, "cslice": CreateSlice, "complexMessage": CreateMessageSend, "complexMessageEdit": CreateMessageEdit, "kindOf": KindOf, "formatTime": tmplFormatTime, "json": tmplJson, "in": in, "inFold": inFold, "roleAbove": roleIsAbove, "adjective": common.RandomAdjective, "noun": common.RandomNoun, "randInt": randInt, "shuffle": shuffle, "seq": sequence, "currentTime": tmplCurrentTime, "parseTime": tmplParseTime, "newDate": tmplNewDate, "escapeHere": func(s string) (string, error) { return "", errors.New("function is removed in favor of better direct control over mentions, join support server and read the announcements for more info.") }, "escapeEveryone": func(s string) (string, error) { return "", errors.New("function is removed in favor of better direct control over mentions, join support server and read the announcements for more info.") }, "escapeEveryoneHere": func(s string) (string, error) { return "", errors.New("function is removed in favor of better direct control over mentions, join support server and read the announcements for more info.") }, "humanizeDurationHours": tmplHumanizeDurationHours, "humanizeDurationMinutes": tmplHumanizeDurationMinutes, "humanizeDurationSeconds": tmplHumanizeDurationSeconds, "humanizeTimeSinceDays": tmplHumanizeTimeSinceDays, } )
Functions ¶
func CreateEmbed ¶ added in v1.4.1
func CreateEmbed(values ...interface{}) (*discordgo.MessageEmbed, error)
func CreateMessageEdit ¶ added in v1.24.6
func CreateMessageEdit(values ...interface{}) (*discordgo.MessageEdit, error)
func CreateMessageSend ¶ added in v1.24.6
func CreateMessageSend(values ...interface{}) (*discordgo.MessageSend, error)
func LimitWriter ¶ added in v1.10.1
LimitWriter works like io.LimitReader. It writes at most n bytes to the underlying Writer. It returns io.ErrShortWrite if more than n bytes are attempted to be written.
func MaybeScheduledDeleteMessage ¶ added in v1.13.0
func RegisterSetupFunc ¶
func RegisterSetupFunc(f ContextSetupFunc)
func ToDuration ¶ added in v1.17.0
Types ¶
type Context ¶
type Context struct { Name string GS *dstate.GuildState MS *dstate.MemberState Msg *discordgo.Message BotUser *discordgo.User ContextFuncs map[string]interface{} Data map[string]interface{} Counters map[string]int FixedOutput string IsPremium bool RegexCache map[string]*regexp.Regexp CurrentFrame *contextFrame // contains filtered or unexported fields }
func NewContext ¶
func NewContext(gs *dstate.GuildState, cs *dstate.ChannelState, ms *dstate.MemberState) *Context
func (*Context) ChannelArg ¶ added in v1.16.0
ChannelArg converts a variety of types of argument into a channel, verifying that it exists
func (*Context) ChannelArgNoDM ¶ added in v1.24.12
ChannelArgNoDM is the same as ChannelArg but will not accept DM channels
func (*Context) ExecuteAndSendWithErrors ¶ added in v1.17.3
func (*Context) IncreaseCheckCallCounter ¶ added in v0.29.1
IncreaseCheckCallCounter Returns true if key is above the limit
func (*Context) IncreaseCheckCallCounterPremium ¶ added in v1.17.2
IncreaseCheckCallCounter Returns true if key is above the limit
func (*Context) IncreaseCheckGenericAPICall ¶ added in v1.16.0
func (*Context) IncreaseCheckStateLock ¶ added in v1.16.0
func (*Context) MessageSend ¶ added in v1.24.6
func (c *Context) MessageSend(content string) *discordgo.MessageSend
type ContextSetupFunc ¶
type ContextSetupFunc func(ctx *Context)
type CtxChannel ¶ added in v1.24.11
type CtxChannel struct { // These fields never change ID int64 GuildID int64 IsPrivate bool Name string `json:"name"` Type discordgo.ChannelType `json:"type"` Topic string `json:"topic"` LastMessageID int64 `json:"last_message_id"` NSFW bool `json:"nsfw"` Position int `json:"position"` Bitrate int `json:"bitrate"` PermissionOverwrites []*discordgo.PermissionOverwrite `json:"permission_overwrites"` ParentID int64 `json:"parent_id"` }
CtxChannel is almost a 1:1 copy of dstate.ChannelState, its needed because we cant axpose all those state methods we also cant use discordgo.Channel because that would likely break a lot of custom commands at this point.
func CtxChannelFromCS ¶ added in v1.24.11
func CtxChannelFromCS(cs *dstate.ChannelState) *CtxChannel
func CtxChannelFromCSLocked ¶ added in v1.24.11
func CtxChannelFromCSLocked(cs *dstate.ChannelState) *CtxChannel
type CtxExecReturn ¶ added in v1.24.12
type CtxExecReturn struct { Return []interface{} Response *discordgo.MessageSend }
func (CtxExecReturn) String ¶ added in v1.24.12
func (c CtxExecReturn) String() string
type CtxMember ¶ added in v1.24.12
type CtxMember struct { *discordgo.Member //extra fields from Member State Status dstate.PresenceStatus `json:"status"` Activity *dstate.LightGame `json:"activity"` }
func CtxMemberFromMS ¶ added in v1.24.12
func CtxMemberFromMS(ms *dstate.MemberState) *CtxMember
type Dict ¶ added in v1.24.12
type Dict map[interface{}]interface{}
func Dictionary ¶
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.
type SDict ¶ added in v1.15.1
type SDict map[string]interface{}
func StringKeyDictionary ¶ added in v1.4.1
func StructToSdict ¶ added in v1.24.12
type Slice ¶ added in v1.24.6
type Slice []interface{}