util

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: GPL-3.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ColorBlack   = 0x000000
	ColorSilver  = 0xc0c0c0
	ColorGray    = 0x808080
	ColorWhite   = 0xffffff
	ColorMaroon  = 0x800000
	ColorRed     = 0xff0000
	ColorPurple  = 0x800080
	ColorFuchsia = 0xff00ff
	ColorGreen   = 0x008000
	ColorLime    = 0x00ff00
	ColorOlive   = 0x808000
	ColorYellow  = 0xffff00
	ColorNavy    = 0x000080
	ColorBlue    = 0x0000ff
	ColorTeal    = 0x008080
	ColorAqua    = 0x00ffff
)

----------------------------------- --- CSS LEVEL 1 --- --- https://www.w3.org/TR/CSS1/ --- -----------------------------------

View Source
const (
	ColorOrange = 0xffa500
)

----------------------------------- --- CSS Level 2 (Revision 1) --- --- https://www.w3.org/TR/CSS2/ --- -----------------------------------

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
)

Error constants

Functions

func CategoryFromName

func CategoryFromName(s *discordgo.Session, name, gID string) (string, error)

CategoryFromName gets a category from it's name

func ChannelArgument

func ChannelArgument(s *discordgo.Session, name, gID string) (string, discordgo.ChannelType, error)

ChannelArgument extracts the channel from a string argument It returns the channel id, the channel type. The error is ErrNotFound when the channel wasn't found s is the discord Session, name the requested channel and gID the guild id where to search When multiple channels with the same name are present, the first one found will be returned

func ChannelFromString

func ChannelFromString(s string) (string, bool)

ChannelFromString extracts a discord channelid from a string when no channel was found it returns false

func ConcatStrings

func ConcatStrings(args ...string) string

ConcatStrings concates multiple strings

func ExtractChannelID

func ExtractChannelID(mention string) string

ExtractChannelID extracts a discord channel id from a mention

func ExtractRoleID

func ExtractRoleID(mention string) string

ExtractRoleID extracts a discord role id from a mention

func ExtractUserID

func ExtractUserID(mention string) string

ExtractUserID extracts a discord user id from a mention

func MentionChannel

func MentionChannel(id string) string

MentionChannel returns a mentino to a channel

func MentionFromString

func MentionFromString(s string) (string, bool)

MentionFromString extracts a discord userid from a string when no user was found it returns false

func MentionRole

func MentionRole(id string) string

MentionRole returns a mention to a role

func MentionUser

func MentionUser(id string) string

MentionUser returns a mention to a user

func NewEmbed

func NewEmbed() *discordgo.MessageEmbed

NewEmbed returns a new Embed with the default color (red)

func ResponseData

func ResponseData(userid, msg string) *discordgo.MessageSend

ResponseData returns the data to send a @User, [msg] message

func RoleFromString

func RoleFromString(s string) (string, bool)

RoleFromString extracs a discord role mention from a strings when no mention was found it returns false

Types

type BigEmbed

type BigEmbed struct {
	// contains filtered or unexported fields
}

BigEmbed contains multiple embeds with descriptions longer than the maximum length of 2048

func NewBigEmbed

func NewBigEmbed(name string, color int, ln int, getFn func(int) string, maxLen int) *BigEmbed

NewBigEmbed creates a new big embed name is the embed title color is the embed color ln is the length of the slice of items that should be displayed getFn should return the string to append at a specific index maxLen is the maximun possible length of an entry. It is used to define when to create a new embed

func (*BigEmbed) Send

func (e *BigEmbed) Send(s *discordgo.Session, chID string) ([]*discordgo.Message, error)

Send sends all embeds to the given channel

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache is a memory cache that holds any type for the given duration

func NewCache

func NewCache(lifetime time.Duration) *Cache

NewCache returns a new cache

func (*Cache) Delete

func (c *Cache) Delete(key string)

Delete removes an item from the cache

func (*Cache) Get

func (c *Cache) Get(key string) (interface{}, bool)

Get returns the item with the key from the cache

func (*Cache) Insert

func (c *Cache) Insert(key string, val interface{})

Insert inserts a new item into the cache

Jump to

Keyboard shortcuts

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