discordutil

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const InteractionTokenLifetime = 15 * time.Minute
View Source
const ResponseDeadline = 3 * time.Second

Variables

View Source
var (
	ColorPrimary   = color.RGBA{R: 0xF3, G: 0xB6, B: 0xAF, A: 0xFF}
	ColorSecondary = color.RGBA{R: 0xEC, G: 0xD1, B: 0xA0, A: 0xFF}
	ColorSuccess   = color.RGBA{R: 0x36, G: 0x9E, B: 0x42, A: 0xFF}
	ColorWarning   = color.RGBA{R: 0xED, G: 0xB6, B: 0x3E, A: 0xFF}
	ColorDanger    = color.RGBA{R: 0xE0, G: 0x38, B: 0x38, A: 0xFF}
	ColorInfo      = color.RGBA{R: 0x57, G: 0x8B, B: 0xF2, A: 0xFF}
)
View Source
var ErrMessageHasHandler = errors.New("the selected message already has an associated message component interaction handler")

TODO: handle this case

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

Functions

func AcceptAllInteractionFilter

func AcceptAllInteractionFilter(i *discordgo.InteractionCreate) bool

func CollectComponentInteractions

func CollectComponentInteractions(ctx context.Context, s *discordgo.Session, f InteractionFilter) <-chan *discordgo.InteractionCreate

func GetBoolOption

func GetBoolOption(options []*discordgo.ApplicationCommandInteractionDataOption, key string) *bool

func GetBoolOptionOrDefault

func GetBoolOptionOrDefault(options []*discordgo.ApplicationCommandInteractionDataOption, key string, defaultValue bool) bool

func GetFloatOptionOrDefault

func GetFloatOptionOrDefault(options []*discordgo.ApplicationCommandInteractionDataOption, key string, defaultValue float64) float64

func GetIntOptionOrDefault

func GetIntOptionOrDefault(options []*discordgo.ApplicationCommandInteractionDataOption, key string, defaultValue int64) int64

func GetInteractionFollowupDeadline

func GetInteractionFollowupDeadline(i *discordgo.Interaction) time.Time

func GetInteractionResponseDeadline

func GetInteractionResponseDeadline(i *discordgo.Interaction) time.Time

func GetInteractionUser

func GetInteractionUser(i *discordgo.InteractionCreate) *discordgo.User

Because member is nil when not in a guild and I am going to cry if I get one more nil pointer error

func GetRequiredBoolOption

func GetRequiredBoolOption(options []*discordgo.ApplicationCommandInteractionDataOption, key string) (bool, error)

func GetRequiredFloatOption

func GetRequiredFloatOption(options []*discordgo.ApplicationCommandInteractionDataOption, key string) (float64, error)

func GetRequiredIntOption

func GetRequiredIntOption(options []*discordgo.ApplicationCommandInteractionDataOption, key string) (int64, error)

func GetRequiredStringOption

func GetRequiredStringOption(options []*discordgo.ApplicationCommandInteractionDataOption, key string) (string, error)

func GetRequiredUintOption

func GetRequiredUintOption(options []*discordgo.ApplicationCommandInteractionDataOption, key string) (uint64, error)

func GetRoleOptionOrDefault

func GetRoleOptionOrDefault(options []*discordgo.ApplicationCommandInteractionDataOption, key string, defaultValue *discordgo.Role, s *discordgo.Session, gid string) *discordgo.Role

func GetStringOptionOrDefault

func GetStringOptionOrDefault(options []*discordgo.ApplicationCommandInteractionDataOption, key, defaultValue string) string

func GetUintOptionOrDefault

func GetUintOptionOrDefault(options []*discordgo.ApplicationCommandInteractionDataOption, key string, defaultValue uint64) uint64

func GetUserOptionOrDefault

func GetUserOptionOrDefault(options []*discordgo.ApplicationCommandInteractionDataOption, key string, defaultValue *discordgo.User, s *discordgo.Session) *discordgo.User

func IsSameInteractionUser

func IsSameInteractionUser(i1, i2 *discordgo.InteractionCreate) bool

func NewIncNonce

func NewIncNonce() (nonce string)

func NewNonce

func NewNonce() (nonce string, err error)

Returns 32 byte string

Types

type EmbedBuilder

type EmbedBuilder struct {
	*discordgo.MessageEmbed
}

func NewEmbedBuilder

func NewEmbedBuilder() *EmbedBuilder

func (*EmbedBuilder) AddField

func (b *EmbedBuilder) AddField(name, value string, inline bool) *EmbedBuilder

func (*EmbedBuilder) ClearFields

func (b *EmbedBuilder) ClearFields() *EmbedBuilder

func (*EmbedBuilder) SetAuthor

func (b *EmbedBuilder) SetAuthor(name, iconUrl, url string) *EmbedBuilder

func (*EmbedBuilder) SetColor

func (b *EmbedBuilder) SetColor(c color.Color) *EmbedBuilder

func (*EmbedBuilder) SetColorFromInt

func (b *EmbedBuilder) SetColorFromInt(c int) *EmbedBuilder

func (*EmbedBuilder) SetDescription

func (b *EmbedBuilder) SetDescription(description string) *EmbedBuilder

func (*EmbedBuilder) SetFooter

func (b *EmbedBuilder) SetFooter(text, iconUrl string) *EmbedBuilder

func (*EmbedBuilder) SetImage

func (b *EmbedBuilder) SetImage(url string) *EmbedBuilder

func (*EmbedBuilder) SetThumbnail

func (b *EmbedBuilder) SetThumbnail(url string) *EmbedBuilder

func (*EmbedBuilder) SetTimestamp

func (b *EmbedBuilder) SetTimestamp(t time.Time) *EmbedBuilder

func (*EmbedBuilder) SetTitle

func (b *EmbedBuilder) SetTitle(title string) *EmbedBuilder

func (*EmbedBuilder) SplitOnFields added in v0.3.1

func (b *EmbedBuilder) SplitOnFields(maxFields int) []*EmbedBuilder

SplitOnFields returns multiple embed builders with identical content as the current builder except the fields, which is split amongst the new builders. Note: splits into shallow copies.

type InteractionFilter

type InteractionFilter func(i *discordgo.InteractionCreate) bool

func NewCustomIDFilter added in v0.2.4

func NewCustomIDFilter(customID string) InteractionFilter

func NewInteractionUserFilter added in v0.2.4

func NewInteractionUserFilter(interaction *discordgo.InteractionCreate) InteractionFilter

func NewMessageFilter

func NewMessageFilter(messageID string) InteractionFilter

func NewMultiFilter

func NewMultiFilter(filters ...InteractionFilter) InteractionFilter

func NewUserFilter

func NewUserFilter(userID string) InteractionFilter

type MessageComponentCollector added in v0.2.4

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

func NewMessageComponentCollector added in v0.2.4

func NewMessageComponentCollector(s *discordgo.Session) *MessageComponentCollector

func (*MessageComponentCollector) Close added in v0.2.4

func (cc *MessageComponentCollector) Close()

func (*MessageComponentCollector) Collect added in v0.2.4

func (*MessageComponentCollector) CollectOnce added in v0.2.4

func (cc *MessageComponentCollector) CollectOnce(
	ctx context.Context,
	messageID string,
	f InteractionFilter,
) (i *discordgo.InteractionCreate, err error)

Jump to

Keyboard shortcuts

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