Documentation
¶
Index ¶
- Variables
- func All(vs ...bool) bool
- func Any(vs ...bool) bool
- func CalcHalfLife(timeSince time.Duration, halfLifeTimeDays, weight float64) float64
- func FormatFloatUpToPrec(num float64, prec int) string
- func GetMembersIter(r rest.Rest, guildID snowflake.ID) iter.Seq[IterResult[discord.Member]]
- func HasRole(member discord.Member, roleID snowflake.ID) bool
- func HasRolesAll(member discord.Member, roleIDs ...snowflake.ID) bool
- func HasRolesAny(member discord.Member, roleIDs ...snowflake.ID) bool
- func Iif[T any](cond bool, t, f T) T
- func LogInteraction(interactionName string, interaction discord.Interaction)
- func LogInteractionContext(interactionName string, interaction discord.Interaction, ctx context.Context)
- func Max[T cmp.Ordered](a, b T) T
- func Min[T cmp.Ordered](a, b T) T
- func ParseLongDuration(s string) (time.Duration, error)
- func Ref[T any](v T) *T
- func RefDefault[T any](v *T, def T) T
- func WrapRef[T any](v *T) (T, bool)
- type DiscordTime
- type IterResult
- type MessageTemplateData
- type TemplateGuildData
- type TemplateUserData
Constants ¶
This section is empty.
Variables ¶
View Source
var LongDurationRegex = regexp.MustCompile(`^(?:(?P<years>\d+)y)? *(?:(?P<months>\d+)mo)? *(?:(?P<weeks>\d+)w)? *(?:(?P<days>\d+)d)? *(?:(?P<hours>\d+)h)? *(?:(?P<minutes>\d+)m)? *(?:(?P<seconds>\d+)s)?$`)
View Source
var MessageTemplateInfo = "The following placeholders can be used in join/leave/approval messages " +
"and will be replaced with the appropriate values." +
"\n" +
"\n" +
"**Username:** `{{User.Username}}` will show as \"Username#1234\" or \"username\"\n" +
"**Global name:** `{{User.GlobalName}}` will show the user's global display name\n" +
"**Server name:** `{{User.ServerName}}` will show the user's server nickname, if any\n" +
"**Resolved name:** `{{User.ResolvedName}}` will show the user's resolved name, which is" +
"the server nickname if set, otherwise the global name, or username if neither is set\n" +
"**Mention:** `{{User.Mention}}` will mention the user if it is used\n" +
"**User ID:** `{{User.ID}}` will show the user's ID\n" +
"**Server name:** `{{Server.Name}}` will show the server name\n" +
"**Server ID:** `{{Server.ID}}` will show the server ID\n"
Functions ¶
func CalcHalfLife ¶
func FormatFloatUpToPrec ¶
func GetMembersIter ¶
func HasRolesAll ¶
func HasRolesAny ¶
func LogInteraction ¶
func LogInteraction(interactionName string, interaction discord.Interaction)
func LogInteractionContext ¶
func LogInteractionContext(interactionName string, interaction discord.Interaction, ctx context.Context)
func ParseLongDuration ¶
ParseLongDuration parses a string into a time.Duration. It supports the following format:
- 1y2mo3w4d5h6m3s (year, month, week, day, hour, minute, second)
func RefDefault ¶
func RefDefault[T any](v *T, def T) T
Types ¶
type DiscordTime ¶
func (DiscordTime) ToLongDate ¶
func (t DiscordTime) ToLongDate() string
func (DiscordTime) ToLongDateTime ¶
func (t DiscordTime) ToLongDateTime() string
func (DiscordTime) ToLongTime ¶
func (t DiscordTime) ToLongTime() string
func (DiscordTime) ToRelative ¶
func (t DiscordTime) ToRelative() string
func (DiscordTime) ToShortDate ¶
func (t DiscordTime) ToShortDate() string
func (DiscordTime) ToShortDateTime ¶
func (t DiscordTime) ToShortDateTime() string
func (DiscordTime) ToShortTime ¶
func (t DiscordTime) ToShortTime() string
type IterResult ¶
type MessageTemplateData ¶
type MessageTemplateData struct { User TemplateUserData Server TemplateGuildData }
func NewMessageTemplateData ¶
func NewMessageTemplateData(user discord.Member, guild discord.Guild) MessageTemplateData
type TemplateGuildData ¶
type TemplateGuildData struct { Name string ID snowflake.ID }
Click to show internal directories.
Click to hide internal directories.