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 DecodeStringToHex(from interface{}) ([]byte, error)
- func HexToDecimal(from interface{}) (int, 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 ToInt64Base16(from interface{}) int64
- func ToRune(from interface{}) []rune
- func ToSHA256(from interface{}) string
- func ToString(from interface{}) string
- type Context
- func (c *Context) ChannelArg(v interface{}) int64
- func (c *Context) ChannelArgNoDM(v interface{}) int64
- func (c *Context) ChannelArgNoDMNoThread(v interface{}) int64
- func (c *Context) Execute(source string) (string, error)
- func (c *Context) ExecuteAndSendWithErrors(source string, channelID int64) error
- func (c *Context) FindRole(role interface{}) *discordgo.Role
- 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 Dict
- type SDict
- type Slice
Constants ¶
const ( MaxOpsNormal = 1000000 MaxOpsPremium = 2500000 )
const DiscordRoleLimit = 250
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{}{ "decodeStringToHex": DecodeStringToHex, "hexToDecimal": HexToDecimal, "str": ToString, "toString": ToString, "toInt": tmplToInt, "toInt64": ToInt64, "toInt64Base16": ToInt64Base16, "toFloat": ToFloat64, "toDuration": ToDuration, "toRune": ToRune, "toByte": ToByte, "toSHA256": ToSHA256, "hasPrefix": strings.HasPrefix, "hasSuffix": strings.HasSuffix, "joinStr": joinStrings, "lower": strings.ToLower, "print": withOutputLimit(fmt.Sprint, MaxStringLength), "printf": withOutputLimitf(fmt.Sprintf, MaxStringLength), "println": withOutputLimit(fmt.Sprintln, MaxStringLength), "slice": slice, "split": strings.Split, "upper": strings.ToUpper, "urlescape": url.PathEscape, "urlunescape": url.PathUnescape, "title": strings.Title, "abs": tmplAbs, "add": add, "cbrt": tmplCbrt, "cos": tmplCos, "div": tmplDiv, "divMod": tmplDivMod, "exp": tmplExp, "exp2": tmplExp2, "fdiv": tmplFDiv, "log": tmplLog, "mod": tmplMod, "max": tmplMax, "min": tmplMin, "mult": tmplMult, "ordinalize": tmplOrdinalize, "pow": tmplPow, "round": tmplRound, "roundCeil": tmplRoundCeil, "roundFloor": tmplRoundFloor, "roundEven": tmplRoundEven, "sin": tmplSin, "sqrt": tmplSqrt, "sub": tmplSub, "tan": tmplTan, "bitwiseAnd": tmplBitwiseAnd, "bitwiseOr": tmplBitwiseOr, "bitwiseNot": tmplBitwiseNot, "bitwiseXor": tmplBitwiseXor, "bitwiseClear": tmplBitwiseAndNot, "bitwiseAndNot": tmplBitwiseAndNot, "shiftLeft": tmplBitwiseShiftLeft, "shiftRight": tmplBitwiseShiftRight, "adjective": common.RandomAdjective, "cembed": CreateEmbed, "complexMessage": CreateMessageSend, "complexMessageEdit": CreateMessageEdit, "cslice": CreateSlice, "dict": Dictionary, "humanizeThousands": tmplHumanizeThousands, "in": in, "inFold": inFold, "json": tmplJson, "kindOf": KindOf, "noun": common.RandomNoun, "randInt": randInt, "roleAbove": roleIsAbove, "sdict": StringKeyDictionary, "seq": sequence, "structToSdict": StructToSdict, "shuffle": shuffle, "currentTime": tmplCurrentTime, "formatTime": tmplFormatTime, "loadLocation": time.LoadLocation, "parseTime": tmplParseTime, "snowflakeToTime": tmplSnowflakeToTime, "newDate": tmplNewDate, "weekNumber": tmplWeekNumber, "humanizeDurationHours": tmplHumanizeDurationHours, "humanizeDurationMinutes": tmplHumanizeDurationMinutes, "humanizeDurationSeconds": tmplHumanizeDurationSeconds, "humanizeTimeSinceDays": tmplHumanizeTimeSinceDays, } )
Functions ¶
func CreateEmbed ¶
func CreateEmbed(values ...interface{}) (*discordgo.MessageEmbed, error)
func CreateMessageEdit ¶
func CreateMessageEdit(values ...interface{}) (*discordgo.MessageEdit, error)
func CreateMessageSend ¶
func CreateMessageSend(values ...interface{}) (*discordgo.MessageSend, error)
func DecodeStringToHex ¶ added in v1.31.10
func HexToDecimal ¶ added in v1.31.9
func LimitWriter ¶
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 RegisterSetupFunc ¶
func RegisterSetupFunc(f ContextSetupFunc)
func ToDuration ¶
func ToInt64Base16 ¶ added in v1.29.0
func ToInt64Base16(from interface{}) int64
Types ¶
type Context ¶
type Context struct { Name string GS *dstate.GuildSet MS *dstate.MemberState Msg *discordgo.Message BotUser *discordgo.User DisabledContextFuncs []string ContextFuncs map[string]interface{} Data map[string]interface{} Counters map[string]int FixedOutput string IsPremium bool RegexCache map[string]*regexp.Regexp CurrentFrame *contextFrame IsExecedByLeaveMessage bool // contains filtered or unexported fields }
func NewContext ¶
func NewContext(gs *dstate.GuildSet, cs *dstate.ChannelState, ms *dstate.MemberState) *Context
func (*Context) ChannelArg ¶
ChannelArg converts a variety of types of argument into a channel, verifying that it exists
func (*Context) ChannelArgNoDM ¶
ChannelArgNoDM is the same as ChannelArg but will not accept DM channels
func (*Context) ChannelArgNoDMNoThread ¶ added in v1.31.9
func (*Context) ExecuteAndSendWithErrors ¶
func (*Context) FindRole ¶ added in v1.31.14
func (c *Context) FindRole(role interface{}) *discordgo.Role
c.FindRole accepts all possible role inputs (names, IDs and mentions) and tries to find them on the current context
func (*Context) IncreaseCheckCallCounter ¶
IncreaseCheckCallCounter Returns true if key is above the limit
func (*Context) IncreaseCheckCallCounterPremium ¶
IncreaseCheckCallCounter Returns true if key is above the limit
func (*Context) IncreaseCheckGenericAPICall ¶
func (*Context) IncreaseCheckStateLock ¶
func (*Context) MessageSend ¶
func (*Context) SendResponse ¶
SendResponse sends the response and handles reactions and the like
type ContextSetupFunc ¶
type ContextSetupFunc func(ctx *Context)
type CtxChannel ¶
type CtxChannel struct { // These fields never change ID int64 GuildID int64 IsPrivate bool IsThread bool Name string `json:"name"` Type discordgo.ChannelType `json:"type"` Topic string `json:"topic"` 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 ¶
func CtxChannelFromCS(cs *dstate.ChannelState) *CtxChannel
func (*CtxChannel) Mention ¶ added in v1.28.0
func (c *CtxChannel) Mention() (string, error)
PAGST previous vers
func (c *CtxChannel) Mention() string { if c == nil { return "No such channel to mention" } return "<#" + discordgo.StrID(c.ID) + ">"
type CtxExecReturn ¶
type CtxExecReturn struct { //Return Slice Return []interface{} Response *discordgo.MessageSend }
func (CtxExecReturn) String ¶
func (c CtxExecReturn) String() string
type Dict ¶
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.
func (Dict) MarshalJSON ¶ added in v1.31.12
type Slice ¶
type Slice []interface{}