utils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Console = &ConsoleUtils{}
View Source
var Discord = &DiscordUtils{}
View Source
var File = &FileUtils{}
View Source
var Input = &InputUtils{}
View Source
var Logging = &LoggingUtils{}
View Source
var Misc = &MiscUtils{}
View Source
var String = &StringUtils{}

Functions

func RandomChoice

func RandomChoice[T comparable](choices []T) T

func RandomNumber

func RandomNumber(min, max int) int

func RandomPercentage

func RandomPercentage() string

func RandomShuffle

func RandomShuffle[T comparable](slice []T) []T

Types

type ConsoleMessage

type ConsoleMessage struct {
	Title string
	Color string
	Info  *list.List
}

func (*ConsoleMessage) AddInfo

func (c *ConsoleMessage) AddInfo(key, value string) *ConsoleMessage

func (*ConsoleMessage) AddInfoConditional

func (c *ConsoleMessage) AddInfoConditional(key, value string, condition bool) *ConsoleMessage

func (*ConsoleMessage) SetColor

func (c *ConsoleMessage) SetColor(color string) *ConsoleMessage

func (*ConsoleMessage) SetTitle

func (c *ConsoleMessage) SetTitle(title string) *ConsoleMessage

func (*ConsoleMessage) Show

func (c *ConsoleMessage) Show()

type ConsoleUtils

type ConsoleUtils struct{}

func (ConsoleUtils) Clear

func (ConsoleUtils) Clear()

func (ConsoleUtils) Colored

func (ConsoleUtils) Colored(text string, r, g, b int, bold bool) string

func (ConsoleUtils) NewConsoleMessage

func (ConsoleUtils) NewConsoleMessage() *ConsoleMessage

func (ConsoleUtils) PrintBanner

func (ConsoleUtils) PrintBanner()

type DiscordUtils

type DiscordUtils struct{}

func (DiscordUtils) GetChannel

func (DiscordUtils) GetChannel(session *discordgo.Session, channelID string) (*discordgo.Channel, error)

func (DiscordUtils) GetChannelFromMention

func (DiscordUtils) GetChannelFromMention(ctx *dgc.Ctx, mention *dgc.Argument) (*discordgo.Channel, bool)

func (DiscordUtils) GetUserFromMention

func (DiscordUtils) GetUserFromMention(session *discordgo.Session, mention *dgc.Argument) (*discordgo.User, bool)

func (DiscordUtils) SendFileFromURL

func (DiscordUtils) SendFileFromURL(ctx *dgc.Ctx, url string, fileName string, headers ...map[string]string) error

func (DiscordUtils) SleepWithTyping

func (DiscordUtils) SleepWithTyping(session *discordgo.Session, channelID string, duration time.Duration)

type FileUtils

type FileUtils struct{}

func (FileUtils) CreateDirectories

func (FileUtils) CreateDirectories() error

func (FileUtils) GetMainFolder

func (FileUtils) GetMainFolder() string

type InputUtils

type InputUtils struct{}

func (InputUtils) GetString

func (InputUtils) GetString(prompt string) string

func (InputUtils) PrintPrompt

func (InputUtils) PrintPrompt(prompt string)

type LoggingUtils

type LoggingUtils struct{}

func (LoggingUtils) Debug

func (LoggingUtils) Debug(v ...any)

func (LoggingUtils) Error

func (LoggingUtils) Error(v ...any)

func (LoggingUtils) Info

func (LoggingUtils) Info(v ...any)

func (LoggingUtils) Warn

func (LoggingUtils) Warn(v ...any)

type MiscUtils

type MiscUtils struct{}

func (MiscUtils) GetDistance

func (MiscUtils) GetDistance(str1, str2 string) int

GetDistance returns the Levenshtein distance between two strings.

func (MiscUtils) HexToRGB

func (MiscUtils) HexToRGB(hex string) (int, int, int)

func (MiscUtils) Minimum

func (MiscUtils) Minimum(a, b, c int) int

Returns lowest of three integers

func (MiscUtils) OpenURL

func (MiscUtils) OpenURL(url string) error

func (MiscUtils) Or

func (MiscUtils) Or(a string, b string) string

Returns a if a is not empty, otherwise returns b

type StringUtils

type StringUtils struct{}

func (StringUtils) Capitalize

func (StringUtils) Capitalize(s string) string

func (StringUtils) CenterSlices

func (StringUtils) CenterSlices(rows []string) string

func (StringUtils) RemoveWords

func (StringUtils) RemoveWords(text string, amount int) string

func (StringUtils) Reverse

func (StringUtils) Reverse(s string) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳