utils

package
v0.0.0-...-59c359b Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: GPL-3.0 Imports: 7 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommandDataInterface

func CommandDataInterface(command discordgo.ApplicationCommandInteractionData) any

CommandDataInterface returns a trimmed version of discordgo.ApplicationCommandInteractionData.

func CommandDataString

func CommandDataString(command discordgo.ApplicationCommandInteractionData) string

CommandDataString recursively traverses a discordgo.ApplicationCommandInteractionData and returns a formatted string representing the command.

func CompareApplicationCommand

func CompareApplicationCommand(first, second discordgo.ApplicationCommand) bool

CompareApplicationCommand compares two discordgo.ApplicationCommand(s) and returns first == second.

func CompareApplicationCommandOption

func CompareApplicationCommandOption(first, second discordgo.ApplicationCommandOption) bool

CompareApplicationCommandOption recursively traverses two discordgo.ApplicationCommandOption(s) to test for value equivalence. This can be called directly or through CompareApplicationCommand to compare higher level commands.

func GetCommandOption

func GetCommandOption(command any, name string, optionName string) *discordgo.ApplicationCommandInteractionDataOption

GetCommandOption takes either a discordgo.ApplicationCommandInteractionData or a discordgo.ApplicationCommandInteractionDataOption, and checks that:

  1. the `.Name` property matches `name`
  2. there exists and option in `.Options` with the name optionName

If those conditions are met then the *discordgo.ApplicationCommandInteractionDataOption that matches is returned. If the conditions aren't met, then nil is returned.

func GetInteractionUser

func GetInteractionUser(interaction *discordgo.Interaction) map[string]string

func GetInteractionUserId

func GetInteractionUserId(interaction *discordgo.Interaction) string

func GetInteractionUserName

func GetInteractionUserName(interaction *discordgo.Interaction) string

func GetInteractionUserVoiceStateId

func GetInteractionUserVoiceStateId(session *discordgo.Session, interaction *discordgo.Interaction) string

func IsInteractionMessageComponent

func IsInteractionMessageComponent(i *discordgo.InteractionCreate, compareType string, name string) bool

IsInteractionMessageComponent checks an interaction to see if it's of type discordgo.InteractionMessageComponent. It also compares the CustomID of it to name using the compareType supplied. compareType can be any of the following: "is", or "startsWith".

func MessageComponentInterface

func MessageComponentInterface(message discordgo.MessageComponentInteractionData) any

MessageComponentInterface returns a trimmed version of discordgo.MessageComponentInteractionData.

func NotNil

func NotNil(v any) bool

func PointerTo

func PointerTo[V any](v V) *V

func ShaSum

func ShaSum(s string) string

Types

type ActionsRowBuilder

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

func ActionsRow

func ActionsRow() *ActionsRowBuilder

func (*ActionsRowBuilder) Build

func (*ActionsRowBuilder) Button

func (*ActionsRowBuilder) SelectMenu

func (a *ActionsRowBuilder) SelectMenu() *ActionsRowBuilder

type ButtonBuilder

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

func Button

func Button() *ButtonBuilder

func (*ButtonBuilder) Build

func (b *ButtonBuilder) Build() discordgo.Button

func (*ButtonBuilder) Enabled

func (b *ButtonBuilder) Enabled(enabled bool) *ButtonBuilder

func (*ButtonBuilder) Id

func (b *ButtonBuilder) Id(id string) *ButtonBuilder

func (*ButtonBuilder) Label

func (b *ButtonBuilder) Label(label string) *ButtonBuilder

func (*ButtonBuilder) Style

func (*ButtonBuilder) URL

func (b *ButtonBuilder) URL(url string) *ButtonBuilder

type InteractionResponseBuilder

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

func InteractionResponse

func InteractionResponse(session *discordgo.Session, interaction *discordgo.Interaction) *InteractionResponseBuilder

func (*InteractionResponseBuilder) Components

func (*InteractionResponseBuilder) Deferred

Deferred marks the response as "will respond later"

func (*InteractionResponseBuilder) DeferredUpdate

DeferredUpdate marks the response as "will update response later"

func (*InteractionResponseBuilder) Delete

func (i *InteractionResponseBuilder) Delete() error

func (*InteractionResponseBuilder) DeleteWithLog

func (i *InteractionResponseBuilder) DeleteWithLog(logger *slog.Logger)

func (*InteractionResponseBuilder) Edit

func (*InteractionResponseBuilder) EditWithLog

func (i *InteractionResponseBuilder) EditWithLog(logger *slog.Logger)

func (*InteractionResponseBuilder) Embeds

func (*InteractionResponseBuilder) Ephemeral

Ephemeral is a convenience function that calls Flags(discordgo.MessageFlagsEphemeral).

func (*InteractionResponseBuilder) Flags

func (*InteractionResponseBuilder) FollowUpCreate

func (i *InteractionResponseBuilder) FollowUpCreate() (*discordgo.Message, error)

func (*InteractionResponseBuilder) FollowUpCreateWithLog

func (i *InteractionResponseBuilder) FollowUpCreateWithLog(logger *slog.Logger)

func (*InteractionResponseBuilder) FollowUpDelete

func (i *InteractionResponseBuilder) FollowUpDelete(id string) error

func (*InteractionResponseBuilder) FollowUpDeleteWithLog

func (i *InteractionResponseBuilder) FollowUpDeleteWithLog(id string, logger *slog.Logger)

func (*InteractionResponseBuilder) FollowUpEdit

func (i *InteractionResponseBuilder) FollowUpEdit(id string) (*discordgo.Message, error)

func (*InteractionResponseBuilder) FollowUpEditWithLog

func (i *InteractionResponseBuilder) FollowUpEditWithLog(id string, logger *slog.Logger)

func (*InteractionResponseBuilder) Message

func (*InteractionResponseBuilder) Response

func (*InteractionResponseBuilder) Send

func (*InteractionResponseBuilder) SendWithLog

func (i *InteractionResponseBuilder) SendWithLog(logger *slog.Logger)

func (*InteractionResponseBuilder) Type

type MessageEmbedBuilder

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

func MessageEmbed

func MessageEmbed() *MessageEmbedBuilder

func (*MessageEmbedBuilder) Build

func (*MessageEmbedBuilder) Description

func (m *MessageEmbedBuilder) Description(description string) *MessageEmbedBuilder

func (*MessageEmbedBuilder) Image

func (*MessageEmbedBuilder) Title

func (*MessageEmbedBuilder) URL

type NopLogHandler

type NopLogHandler struct{}

func (NopLogHandler) Enabled

func (n NopLogHandler) Enabled(_ context.Context, _ slog.Level) bool

func (NopLogHandler) Handle

func (n NopLogHandler) Handle(_ context.Context, _ slog.Record) error

func (NopLogHandler) WithAttrs

func (n NopLogHandler) WithAttrs(_ []slog.Attr) slog.Handler

func (NopLogHandler) WithGroup

func (n NopLogHandler) WithGroup(_ string) slog.Handler

Jump to

Keyboard shortcuts

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