Documentation
¶
Index ¶
- func AlignString(str string, width int, alignment StringAlign) string
- func CalculateFutureTokenLogs(maxEntries int, startTime time.Time, minutesPerToken int, ...) ([]FutureToken, []FutureToken)
- func CalculateTcountTtime(tokenValue float64, tval float64, valueLog []FutureToken) (string, string, int)
- func CellANSI(s, color string, width int, right bool) string
- func DownloadLatestEggImages(localDownloadDir string) error
- func FindCategoryID(s *discordgo.Session, channelID string) (string, error)
- func FitString(str string, width int, alignment StringAlign) string
- func FmtDuration(d time.Duration) string
- func FmtDurationSingleUnit(d time.Duration) (string, int)
- func FormatIntWithCommas[T ~int | ~int64 | ~uint | ~uint32 | ~uint64](v T) string
- func GenerateBanner(ID string, eggName string, text string)
- func GenerateSnapshots(outputPath, packageName string) error
- func GetCommandOptionsMap(i *discordgo.InteractionCreate) map[string]*discordgo.ApplicationCommandInteractionDataOption
- func GetFormattedCommand(command string) string
- func GetGistData(filename string) (string, error)
- func GetInteractionUserID(i *discordgo.InteractionCreate) string
- func GetSlashRemoveMessage(cmd string) *discordgo.ApplicationCommand
- func GetStaabmiaLink(darkMode bool, modifierType ei.GameModifier_GameDimension, ...) string
- func GetTokenValue(seconds float64, durationSeconds float64) float64
- func HandleRemoveMessageCommand(s *discordgo.Session, i *discordgo.InteractionCreate)
- func ImportEggImage(s *discordgo.Session, eggID, IconURL string) (string, error)
- func ImportNewEmojis(s *discordgo.Session)
- func LoadEmotes(s *discordgo.Session, force bool)
- func NewSmallSeparatorComponent(visible bool) *discordgo.Separator
- func PutGistData(filename string, data string) error
- func RefreshMap[K comparable, V any](m map[K]V) map[K]V
- func SanitizeStringDuration(s string) string
- func UpdateCommandMap(commands []*discordgo.ApplicationCommand)
- func VisibleLenANSI(s string) int
- func WrapANSI(s, color string) string
- func WrapTimestamp[N TimestampNumber](ts N, format DiscordTimestampFormat) string
- type DiscordTimestampFormat
- type FutureToken
- type StringAlign
- type TimestampNumber
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AlignString ¶
func AlignString(str string, width int, alignment StringAlign) string
AlignString aligns a string to the left, center, or right within a given width
func CalculateFutureTokenLogs ¶
func CalculateFutureTokenLogs(maxEntries int, startTime time.Time, minutesPerToken int, duration time.Duration, rateSecondPerTokens float64) ([]FutureToken, []FutureToken)
CalculateFutureTokenLogs calculates the future token logs based on the given parameters
func CalculateTcountTtime ¶
func CalculateTcountTtime(tokenValue float64, tval float64, valueLog []FutureToken) (string, string, int)
CalculateTcountTtime calculates the token count and time based on the given parameters
func CellANSI ¶
CellANSI pads s to width with spaces and applies color to the content only. If right: the content is right-aligned.
func DownloadLatestEggImages ¶
DownloadLatestEggImages downloads the latest image files from a specific GitHub repository directory.
func FindCategoryID ¶
FindCategoryID walks up the parent chain until it finds the category. Returns the category ID, or "" if err.
func FitString ¶
func FitString(str string, width int, alignment StringAlign) string
FitString truncates and pads left or right
func FmtDuration ¶
FmtDuration formats a time.Duration into a human-readable string with seconds precision.
func FmtDurationSingleUnit ¶
FmtDurationSingleUnit formats a time.Duration into a single unit string and its corresponding unit integer Parameters:
- d (time.Duration)
Returns:
- (string): the duration value as a string.
- (int): the duration unit as an integer (0: days, 1: hours, 2: minutes, 3: seconds).
func FormatIntWithCommas ¶
FormatIntWithCommas formats any integer value with commas as thousands separators
func GenerateBanner ¶
GenerateBanner creates a banner image with a background, overlay image, and text
func GenerateSnapshots ¶
GenerateSnapshots writes snapshot structs to outputPath for the listed protobuf types. Run this manually with:
go run ./src/bottools/cmd/run_snapshots.go
func GetCommandOptionsMap ¶
func GetCommandOptionsMap(i *discordgo.InteractionCreate) map[string]*discordgo.ApplicationCommandInteractionDataOption
GetCommandOptionsMap returns a map of command options subcommand options are stored as "subcommand-option"
func GetFormattedCommand ¶
GetFormattedCommand returns the formatted command string
func GetGistData ¶
GetGistData retrieves data from a Gist and unmarshals it into the target interface.
func GetInteractionUserID ¶
func GetInteractionUserID(i *discordgo.InteractionCreate) string
GetInteractionUserID returns the user ID from an interaction, whether in a guild or DM
func GetSlashRemoveMessage ¶
func GetSlashRemoveMessage(cmd string) *discordgo.ApplicationCommand
GetSlashRemoveMessage returns the slash command for removing a bot message from a DM channel.
func GetStaabmiaLink ¶
func GetStaabmiaLink(darkMode bool, modifierType ei.GameModifier_GameDimension, modifierMult float64, coopDeflectorBonus int, artifacts []string, shippingRate, elrRate, habCap float64) string
GetStaabmiaLink returns a link to the Staabia calculator.
func GetTokenValue ¶
GetTokenValue calculates the token value based on the given parameters
func HandleRemoveMessageCommand ¶
func HandleRemoveMessageCommand(s *discordgo.Session, i *discordgo.InteractionCreate)
HandleRemoveMessageCommand handles the remove message command.
func ImportEggImage ¶
ImportEggImage will import an egg image into the discord app
func ImportNewEmojis ¶
ImportNewEmojis will import new emojis from the emoji directory into the discord app
func LoadEmotes ¶
LoadEmotes will load all the emojis from the app
func NewSmallSeparatorComponent ¶
NewSmallSeparatorComponent returns a Discord separator component configured with small spacing and optional visibility.
func PutGistData ¶
PutGistData uploads data to a Gist.
func RefreshMap ¶
func RefreshMap[K comparable, V any](m map[K]V) map[K]V
RefreshMap creates and returns a shallow copy of the given map
func SanitizeStringDuration ¶
SanitizeStringDuration takes an hms string and returns a sanitized version of it
func UpdateCommandMap ¶
func UpdateCommandMap(commands []*discordgo.ApplicationCommand)
UpdateCommandMap updates the command map
func VisibleLenANSI ¶
VisibleLenANSI returns the rune length of s excluding ANSI escape codes.
func WrapANSI ¶
WrapANSI wraps s with an ANSI color by name ("red", "green", "blue"). Unknown color returns s unchanged.
func WrapTimestamp ¶
func WrapTimestamp[N TimestampNumber](ts N, format DiscordTimestampFormat) string
WrapTimestamp returns ts formatted as a Discord timestamp string.
ts can be any integer type assumed to be a Unix timestamp in seconds. format is one of the DiscordTimestampFormat constants. If format is TimestampDefault, it returns "<t:ts>". Otherwise it returns "<t:ts:format>".
Types ¶
type DiscordTimestampFormat ¶
type DiscordTimestampFormat string
DiscordTimestampFormat holds the style postfixes for Discord timestamp formatting.
const ( // Default <t:1543392060> November 28, 2018 9:01 AM || 28 November 2018 09:01 TimestampDefault DiscordTimestampFormat = "" // Short Time <t:1543392060:t> 9:01 AM || 09:01 TimestampShortTime DiscordTimestampFormat = "t" // Long Time <t:1543392060:T> 9:01:00 AM || 09:01:00 TimestampLongTime DiscordTimestampFormat = "T" // Short Date <t:1543392060:d> 11/28/2018 || 28/11/2018 TimestampShortDate DiscordTimestampFormat = "d" // Long Date <t:1543392060:D> November 28, 2018 || 28 November 2018 TimestampLongDate DiscordTimestampFormat = "D" // Short Date/Time<t:1543392060:f> November 28, 2018 9:01 AM || 28 November 2018 09:01 TimestampShortDateTime DiscordTimestampFormat = "f" // Long Date/Time <t:1543392060:F> Wednesday, November 28, 2018 9:01 AM || Wednesday, 28 November 2018 09:01 TimestampLongDateTime DiscordTimestampFormat = "F" // Relative Time <t:1543392060:R> 3 years ago || 3 years ago TimestampRelativeTime DiscordTimestampFormat = "R" )
type FutureToken ¶
FutureToken represents a token with its value and time
type StringAlign ¶
type StringAlign int
StringAlign is an enum for string alignment
const ( // StringAlignLeft aligns the string to the left StringAlignLeft StringAlign = iota // StringAlignCenter aligns the string to the center (left biased) StringAlignCenter // StringAlignRight aligns the string to the right StringAlignRight // StringAlignCenterRight aligns the string to the center (right biased) StringAlignCenterRight )