utils

package
v0.0.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ColorPrimary = 0xB4DDB4
	ColorSuccess = 0x00FF00
	ColorError   = 0xFF0000
	ColorWarning = 0xFFFF00
	ColorInfo    = 0x0000FF
	ColorNeutral = 0x808080
)

Variables

This section is empty.

Functions

func Contains

func Contains[T comparable](array []T, value T) bool

Contains returns true if `array` contains `value`

func ErrorAsEmbed

func ErrorAsEmbed(message string) *discordgo.MessageEmbed

func Filter

func Filter[T any](array []T, predicate func(T) bool) []T

Filter returns a new array containing only the elements of `array` for which `predicate` returns true

func GetLatestMessageFromUser

func GetLatestMessageFromUser(s *discordgo.Session, u *discordgo.User, c *discordgo.Channel) (*discordgo.Message, error)

func GetMemberRoles

func GetMemberRoles(s *discordgo.Session, guildId string, member *discordgo.Member) ([]*discordgo.Role, error)

GetMemberRoles returns the roles of the member in the given guild

func GetMessagesFromUser

func GetMessagesFromUser(s *discordgo.Session, u *discordgo.User, c *discordgo.Channel, limit uint) ([]*discordgo.Message, error)

func GetRoleById

func GetRoleById(s *discordgo.Session, guildId string, id string) (*discordgo.Role, error)

GetRoleById returns the role with the given id or an error if it doesn't exist

func GetRoleByName

func GetRoleByName(s *discordgo.Session, guildId string, name string) (*discordgo.Role, error)

GetRoleById returns the role with the given name or an error if it doesn't exist

func HasRole

func HasRole(s *discordgo.Session, member *discordgo.Member, role *discordgo.Role) bool

HasRole iterates over the member's roles and checks if the role is present

func IfElse

func IfElse[T any](condition bool, a, b T) T

IfElse is a function that returns `a` if `condition` is true, otherwise it returns `b`

func InArray

func InArray[T comparable](array []T, value T) bool

func InfoAsEmbed

func InfoAsEmbed(description string) *discordgo.MessageEmbed

func IntPtr

func IntPtr[T int64](i T) *T

func Map

func Map[T any, U any](array []T, mapper func(T) U) []U

Map returns a new array containing the results of applying `mapper` to each element of `array`

func MessagesMatch

func MessagesMatch(current *discordgo.MessageSend, sent *discordgo.Message) bool

func NewDiscordLogHandler

func NewDiscordLogHandler(s *discordgo.Session, guildId, channelId string) log.Handler

func Pluralize

func Pluralize(count int, singular, plural string) string

func Remove

func Remove[T comparable](array []T, value T) ([]T, error)

Remove removes the first instance of `value` from `array`

func RemoveFromArray

func RemoveFromArray[T comparable](array []T, value T) ([]T, error)

func SuccessAsEmbed

func SuccessAsEmbed(description string) *discordgo.MessageEmbed

func UpdateMessage

func UpdateMessage(session *discordgo.Session, current *discordgo.MessageSend, sent *discordgo.Message) error

UpdateMessages compares the current version of a message to the version that was sent and updates it if they are different

Types

This section is empty.

Jump to

Keyboard shortcuts

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