utils

package
v0.0.0-...-886a64d Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: MPL-2.0 Imports: 8 Imported by: 3

Documentation

Index

Constants

View Source
const (
	StrongGreen = 0x09D67C
	Green       = 0x10E6AD
	LightGreen  = 0x9DDDCD
	DarkRed     = 0x831010
	Red         = 0xF74D53
	LightBlue   = 0x34A6F4
	Blue        = 0x10889E
	Rose        = 0xF8C7DA
	Camel       = 0xF4D694
	Violet      = 0xC5A2FF

	Error        = DarkRed
	Alert        = Red
	Success      = Green
	GreatSuccess = StrongGreen
	Neutral      = Camel
	Nice         = Rose
)
View Source
const (
	AnsiReset       = "\033[0m"
	AnsiRed         = "\033[31m"
	AnsiGreen       = "\033[32m"
	AnsiYellow      = "\033[33m"
	AnsiBlue        = "\033[34m"
	AnsiMagenta     = "\033[35m"
	AnsiCyan        = "\033[36m"
	AnsiWhite       = "\033[37m"
	AnsiBlueBold    = "\033[34;1m"
	AnsiMagentaBold = "\033[35;1m"
	AnsiRedBold     = "\033[31;1m"
	AnsiYellowBold  = "\033[33;1m"
)

Variables

View Source
var DebugEnabled bool

Functions

func AStringContains

func AStringContains(a []string, b string) bool

AStringContains checks if a slice "a" contains a "b" string

func ComesFromDM

func ComesFromDM(s *discordgo.Session, id string) (bool, error)

ComesFromDM returns true if a message comes from a DM channel

func FetchGuildUser

func FetchGuildUser(s *discordgo.Session, guildID string) []*discordgo.Member

FetchGuildUser returns the list of member in a guild

func GetTimestampFromId

func GetTimestampFromId(id string) (time.Time, error)

func HoursOfUnix

func HoursOfUnix(unix int64) uint

HoursOfUnix returns the hours of a unix timestamp

func NewTimers

func NewTimers(d time.Duration, fn func(chan struct{}))

NewTimers produce a new async ticker.

d is for the duration between two ticks and fn is the functions called at each tick: it takes a chan in parameter, and you can put anything here to disable the ticker

func SendAlert

func SendAlert(pos string, message string)

SendAlert sends an alert

func SendDebug

func SendDebug(message ...any)

SendDebug sends a debug message

func SendError

func SendError(err error)

SendError sends an error (like a panic(any...))

func SendSuccess

func SendSuccess(message string)

SendSuccess sends a success message

func SendWarn

func SendWarn(message string)

SendWarn sends a warning message

func TrimMessage

func TrimMessage(s string) string

TrimMessage trims a "s" string and remove bad chars, links and pings

Types

type ResponseBuilder

type ResponseBuilder struct {
	I *discordgo.InteractionCreate
	C *discordgo.Session
	// contains filtered or unexported fields
}

ResponseBuilder helps to response to slash commands

func (*ResponseBuilder) Client

func (*ResponseBuilder) Embeds

func (*ResponseBuilder) Interaction

func (*ResponseBuilder) IsDeferred

func (res *ResponseBuilder) IsDeferred() *ResponseBuilder

func (*ResponseBuilder) IsEdit

func (res *ResponseBuilder) IsEdit() *ResponseBuilder

func (*ResponseBuilder) IsEphemeral

func (res *ResponseBuilder) IsEphemeral() *ResponseBuilder

func (*ResponseBuilder) Message

func (res *ResponseBuilder) Message(s string) *ResponseBuilder

func (*ResponseBuilder) NotDeferred

func (res *ResponseBuilder) NotDeferred() *ResponseBuilder

func (*ResponseBuilder) NotEdit

func (res *ResponseBuilder) NotEdit() *ResponseBuilder

func (*ResponseBuilder) NotEphemeral

func (res *ResponseBuilder) NotEphemeral() *ResponseBuilder

func (*ResponseBuilder) Send

func (res *ResponseBuilder) Send() error

Send the response

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL