util

package
v0.0.0-...-eb18d79 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StatsStartupTime             = time.Now()
	StatsCommandsExecuted uint64 = 0
	StatsMessagesAnalysed uint64 = 0
)
View Source
var (
	ConnectedState int32
)
View Source
var (
	DevModeEnabled = false
)

Functions

func AttachRoleSelectButtons

func AttachRoleSelectButtons(
	b *ken.ComponentBuilder,
	roles []*discordgo.Role,
) ([]string, error)

func CheckForUpdate

func CheckForUpdate() (isOld bool, current, latest versioncheck.Semver)

func FlushAllGuildData

func FlushAllGuildData(
	s *discordgo.Session,
	db database.Database,
	st storage.Storage,
	state *dgrs.State,
	guildID string,
) (err error)

func FlushAllUserData

func FlushAllUserData(
	db database.Database,
	state *dgrs.State,
	userID string,
) (res map[string]int, err error)

func GetAllPermissions

func GetAllPermissions(cmdHandler *ken.Ken) sop.Enumerable[string]

func GetEnv

func GetEnv(key, def string) string

GetEnv returns a value from environment variables or the given default value, if not existent.

func GetInviteLink(selfID string) string

GetInviteLink returns the invite link for the bot's account with the specified permissions.

func OnRoleSelect

func OnRoleSelect(roleID string) func(ctx ken.ComponentContext) bool

func Pluralize

func Pluralize(n int, s string) string

func UpdateGuildMemberStats

func UpdateGuildMemberStats(st dgrs.IState, s discordutil.ISession) error

Types

type EmbedMessage

type EmbedMessage struct {
	*discordgo.Message
	// contains filtered or unexported fields
}

EmbedMessage extends a discordgo.MessageEmbedMessage with extra utilities.

func SendEmbed

func SendEmbed(s discordutil.ISession, chanID, content string, title string, color int) *EmbedMessage

SendEmbed creates an discordgo.MessageEmbed from the passed content, title and color and sends it to the specified channel.

If color == 0, static.ColorEmbedDefault will be set as color.

Occured errors are set to the internal error.

func SendEmbedError

func SendEmbedError(s discordutil.ISession, chanID, content string, title ...string) *EmbedMessage

SendEmbedError is shorthand for SendEmbed with static.ColorEmbedError as color and title "Error" if no title was passed.

func SendEmbedRaw

func SendEmbedRaw(s discordutil.ISession, chanID string, emb *discordgo.MessageEmbed) *EmbedMessage

SendEmbedRaw sends the passed emb to the passed channel and sets occured errors to the internal error.

func (*EmbedMessage) DeleteAfter

func (emb *EmbedMessage) DeleteAfter(d time.Duration) *EmbedMessage

DeleteAfter deletes the message after the specified duration when the message still exists and sets occured error to the EmbedMessage.

func (*EmbedMessage) Edit

func (emb *EmbedMessage) Edit(content string, title string, color int) *EmbedMessage

Edit updates the current embed message with the given content replacing the internal message and error of this embed instance.

func (*EmbedMessage) EditRaw

func (emb *EmbedMessage) EditRaw(newEmb *discordgo.MessageEmbed) *EmbedMessage

EditRaw updates the current embed message with the given raw embed replacing the internal message and error of this embed instance.

func (*EmbedMessage) Error

func (emb *EmbedMessage) Error() error

Error returns the embedded error.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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