flo

package module
v0.0.0-...-be3cb3b Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 23 Imported by: 0

README

[!IMPORTANT]
The API coverage is currently quite low, and reliability is not guaranteed. The library is also subject to making breaking changes since a release has not yet been made!

Flo

A cute Go library for making Fluxer bots/self-bots aiming to be simple in implementation and usage! More user-API specific things may be considered in the future, but that is likely more useful for custom clients which is not the current focus.

Join our Fluxer Community to get help or just hang out!

Features

  • Rate limiting
  • Caching
  • API designed with sharding in mind (minimal changes should be needed to properly support sharding when it is available)
  • Cache and REST methods on objects for slightly more type safety
    • Another approach is typed IDs, but this has its downsides - at least taking the approach of arikawa which duplicates code and uses codegen.

See also

  • FluxerGo - Port of DisGo to Fluxer
    • Split up into several packages which may be more your style
    • Still has a lot of Discord stuff that needs to removed/changed :(

Example

package main

import (
	"context"
	"fmt"
	"log/slog"
	"os"

	"github.com/fluxer-flo/flo"
)

func main() {
	token := os.Getenv("FLUXER_TOKEN")
	if token == "" {
		slog.Error("please provide the token as FLUXER_TOKEN")
		os.Exit(1)
	}
	// you need this prefix for bot tokens!
	token = "Bot " + token

	cache := flo.NewCacheDefault()
	// if you want to change the limit or avoid caching something entirely:
	// cache.Guilds = flo.NewCollection[Guild](0)

	// REST is used to perform actions through Fluxer's REST HTTP API
	rest := flo.REST{
        // Auth can be omitted, for example if you're just using webhooks
        // Note that this will cause ratelimits to be done based on IP instead
        // Cache is also optional, omitting it will simply stop requests populating the cache
		Auth:  token, 
		Cache: &cache,
        // Recommended - disable all mentions unless AllowedMentions is explicitly specified for a message
        DefaultAllowedMentions: &flo.AllowedMentionsNone,
	}

	// Gateway is used to receive events through a persistent websocket connection to Fluxer's gateway
	gateway := flo.Gateway{
        // Auth is required, but cache can be omitted to stop events from populating the cache (not recommended)
		Auth:  token,
		Cache: &cache,
	}
    gateway.SetPresence(flo.PresenceOpts{
        Status: flo.UserStatusIdle,
        CustomStatus: flo.CustomStatusOpts{
            EmojiName: "💤",
            Text: "chillin'",
        },
    })

	gateway.ShardReady.OnceSync(func(r flo.ShardReadyEvent) {
		fmt.Println("ready as " + r.User.Tag())
	})

	gateway.MessageCreate.On(func(m flo.MessageCreateEvent) {
		var resp string
		switch m.Content {
		case "!ping":
			resp = "Pong!"
		case "!pong":
			resp = "Ping!"
		default:
			return
		}

		_, err := rest.CreateMessage(context.TODO(), m.ChannelID, flo.CreateMessageOpts{
			Content: resp,
			// reply to the original message
			MessageReference: flo.MessageReferenceOpts{
				MessageID: m.ID,
			},
		})
		if err != nil {
			slog.Warn("couldn't reply to command :/", slog.Any("err", err))
		}
	})

	gateway.Start()

	stopped, _ := gateway.ShardStopped.OnceChan()
	event := <-stopped
	if event.Err != nil {
		slog.Error("stopped with error", slog.Any("err", event.Err))
	}
}

Documentation

Overview

Package flo provides a high-level way to use the Fluxer API.

Index

Constants

View Source
const (
	EmbedMediaFlagNSFW     = 1 << 4
	EmbedMediaFlagAnimated = 1 << 5
)
View Source
const (
	AttachmentFlagSpoiler  = 1 << 3
	AttachmentFlagNSFW     = 1 << 4
	AttachmentFlagAnimated = 1 << 5
)
View Source
const DefaultGatewayVersion = 1

DefaultGatewayVersion is the default gateway version if not specified in Gateway.ConnURL.

Variables

View Source
var (
	ErrShardAlreadyRunning       = errors.New("shard already running")
	ErrShardNotRunning           = errors.New("shard not running")
	ErrShardAlreadyStopping      = errors.New("shard already stopping")
	ErrShardAlreadyDisconnecting = errors.New("shard already disconnecting")
)
View Source
var (
	PermCreateInstantInvite = NewPermsBit(0)
	PermKickMembers         = NewPermsBit(1)
	PermBanMembers          = NewPermsBit(2)
	PermAdministrator       = NewPermsBit(3)
	PermManageChannels      = NewPermsBit(4)
	PermManageGuild         = NewPermsBit(5)
	PermAddReactions        = NewPermsBit(6)
	PermViewAuditLog        = NewPermsBit(7)
	PermPrioritySpeaker     = NewPermsBit(8)
	PermStream              = NewPermsBit(9)
	PermViewChannel         = NewPermsBit(10)
	PermSendMessages        = NewPermsBit(11)
	PermSendTTSMessages     = NewPermsBit(12)
	PermManageMessages      = NewPermsBit(13)
	PermEmbedLinks          = NewPermsBit(14)
	PermAttachFiles         = NewPermsBit(15)
	PermReadMessageHistory  = NewPermsBit(16)
	PermMentionEveryone     = NewPermsBit(17)
	PermUseExternalEmojis   = NewPermsBit(18)
	PermConnect             = NewPermsBit(20)
	PermSpeak               = NewPermsBit(21)
	PermMuteMembers         = NewPermsBit(22)
	PermDeafenMembers       = NewPermsBit(23)
	PermMoveMembers         = NewPermsBit(24)
	PermUseVAD              = NewPermsBit(25)
	PermChangeNickname      = NewPermsBit(26)
	PermManageNicknames     = NewPermsBit(27)
	PermManageRoles         = NewPermsBit(28)
	PermManageWebhooks      = NewPermsBit(29)
	PermManageExpressions   = NewPermsBit(30)
	PermUseExternalStickers = NewPermsBit(37)
	PermModerateMembers     = NewPermsBit(40)
	PermCreateExpressions   = NewPermsBit(43)
	PermPinMembers          = NewPermsBit(51)
	PermBypassSlowmode      = NewPermsBit(52)
	PermUpdateRTCRegion     = NewPermsBit(53)
	PermsAll                = NewPerms(
		PermCreateInstantInvite,
		PermKickMembers,
		PermBanMembers,
		PermAdministrator,
		PermManageChannels,
		PermManageGuild,
		PermAddReactions,
		PermViewAuditLog,
		PermPrioritySpeaker,
		PermStream,
		PermViewChannel,
		PermSendMessages,
		PermSendTTSMessages,
		PermManageMessages,
		PermEmbedLinks,
		PermAttachFiles,
		PermReadMessageHistory,
		PermMentionEveryone,
		PermUseExternalEmojis,
		PermConnect,
		PermSpeak,
		PermMuteMembers,
		PermDeafenMembers,
		PermMoveMembers,
		PermUseVAD,
		PermChangeNickname,
		PermManageNicknames,
		PermManageRoles,
		PermManageWebhooks,
		PermManageExpressions,
		PermUseExternalStickers,
		PermModerateMembers,
		PermCreateExpressions,
		PermPinMembers,
		PermBypassSlowmode,
		PermUpdateRTCRegion,
	)
)
View Source
var AllowedMentionsNone = func() AllowedMentions {
	f := false
	return AllowedMentions{
		Parse:       []AllowedMentionsParse{},
		RepliedUser: &f,
	}
}()

AllowedMentionsNone is an AllowedMentions value which disables all mentions.

View Source
var DefaultAPIURL = func() *url.URL {
	result, err := url.Parse("https://api.fluxer.app/")
	if err != nil {
		panic(err)
	}

	return result
}()

DefaultAPIURL is the default value for REST.BaseURL. It points to the current base URL for API requests to the main Fluxer instance.

View Source
var DefaultGatewayURL = func() *url.URL {
	result, err := url.Parse("wss://gateway.fluxer.app")
	if err != nil {
		panic(err)
	}

	return result
}()

DefaultGatewayURL is the default value for Gateway.ConnURL. It points to the current gateway URL of the main Fluxer instance.

View Source
var DefaultUserAgent = func() string {
	version := libVersion()
	if version == "" {
		version = "unknown"
	}

	return "flo/" + version
}()

DefaultUserAgent is the default user agent used for REST requests and the browser string when connecting to the gateway.

Functions

func IsRESTError

func IsRESTError(err error, codes ...RESTErrorCode) bool

IsRESTError is a convinience method to check for one of a list of REST error codes.

Types

type AllShardsStoppedEvent

type AllShardsStoppedEvent struct {
	Gateway *Gateway
}

type AllowedMentions

type AllowedMentions struct {
	Parse       []AllowedMentionsParse `json:"parse,omitzero"`
	Users       []ID                   `json:"users,omitzero"`
	Roles       []ID                   `json:"roles,omitzero"`
	RepliedUser *bool                  `json:"replied_user,omitempty"`
}

AllowedMentions specifies allowed mentions when creating or editing a message.

type AllowedMentionsParse

type AllowedMentionsParse string
const (
	AllowedMentionsParseUsers    AllowedMentionsParse = "users"
	AllowedMentionsParseRoles    AllowedMentionsParse = "roles"
	AllowedMentionsParseEveryone AllowedMentionsParse = "everyone"
)

type Attachment

type Attachment struct {
	ID           ID              `json:"id"`
	Filename     string          `json:"filename"`
	Title        *string         `json:"title"`
	Description  *string         `json:"description"`
	ContentType  *string         `json:"content_type"`
	ContentHash  *string         `json:"content_hash"`
	Size         int             `json:"size"`
	URL          *string         `json:"url"`
	ProxyURL     *string         `json:"proxy_url"`
	Width        *int            `json:"width"`
	Height       *int            `json:"height"`
	Placeholder  *string         `json:"placeholder"`
	Flags        AttachmentFlags `json:"flags"`
	DurationSecs *int            `json:"duration"`
	Waveform     *string         `json:"waveform"`
	ExpiresAt    *time.Time      `json:"expires_at"`
	Expired      bool            `json:"expired"`
}

type AttachmentFlags

type AttachmentFlags uint

type BulkDeletedMessage

type BulkDeletedMessage struct {
	ID ID
	// Cached is the message that was removed from cache by this event, if any.
	Cached *Message
}

type Cache

type Cache struct {
	// DMChannels is populated by channels of type [ChannelTypeDM].
	DMChannels Collection[Channel]
	// MakeDMChannel is used to create new DM channel entries if it is not nil.
	// This function should simply return a channel with the [Collection]s set for whatever limits are desired.
	MakeDMChannel func() Channel
	// DMChannels is populated by channels of type [ChannelTypeGroupDM].
	GroupDMChannels Collection[Channel]
	// MakeGroupDM is used to create new group DM channel entries if it is not nil.
	// This function should simply return a channel with the [Collection]s set for whatever limits are desired.
	MakeGroupDMChannel func() Channel
	// ChannelGuilds is populated with a mapping from guild channel ID -> guild ID.
	ChannelGuilds Collection[ID]
	// MakePrivateChannel is used to create new guild channel entries if it is not nil.
	// This function should simply return a channel with the [Collection]s set for whatever limits are desired.
	MakeGuildChannel func() Channel
	// Guilds by default is populated by guilds which are available on the gateway.
	// If requesting a Guild over the REST API, you will manually need to add it if you wish to be able to retrieve it later.
	Guilds Collection[Guild]
	// UnavailableGuilds is populated by guilds have become unavailable but not been fully removed.
	UnavailableGuilds Collection[struct{}]
	// MakeGuild is used to create new guild entries if it is not nil.
	// This function should simply return a guild with the [Collection]s set for whatever limits are desired.
	MakeGuild func() Guild
	// Users is populated by requested users or whatever is available from other gateway/REST paylods.
	Users Collection[User]
	// CacheCurrentUser is used to determine whether to cache the [UserPrivate] object for the authenticated user.
	CacheCurrentUser bool
	// contains filtered or unexported fields
}

Cache specifies caching targets and configuration. The zero value for Cache does not cache anything - use NewCacheDefault for generous defaults.

func NewCacheDefault

func NewCacheDefault() Cache

NewCacheDefault returns a Cache which prioritises out-of-the-box usability. The caching here is quite aggressive but tuning it by modifying the fields is encouraged.

func (*Cache) Channel

func (c *Cache) Channel(channelID ID) (Channel, bool)

Channel looks up a channel by its ID alone. Guild channels will not be found if ChannelGuilds does not contain them. This should be used with caution - if you, for example, provide a command that allows any channel ID and looks it up with this method it could easily lead to privilege escalation! If you only want channels from a specific guild, first look it up in Guilds then look it up on Guild.Channels if it is present.

func (*Cache) ClearCurrentUser

func (c *Cache) ClearCurrentUser()

func (*Cache) CurrentUser

func (c *Cache) CurrentUser() (UserPrivate, bool)

func (*Cache) ExpectCurrentUser

func (c *Cache) ExpectCurrentUser() UserPrivate

func (*Cache) UpdateChannel

func (c *Cache) UpdateChannel(channelID ID, update func(channel *Channel)) bool

func (*Cache) UpdateCurrentUser

func (c *Cache) UpdateCurrentUser(user UserPrivate)

type Channel

type Channel struct {
	// ID is the globally unique identifier for the channel.
	ID ID `json:"id"`
	// Type is the type of channel.
	// Properties of which the presence can currently be used to determine the channel type are subject to change, so it is best to check this property if you want to guarantee the channel type.
	Type ChannelType `json:"type"`
	// GuildID is the guild this channel belongs to if this is a guild channel.
	GuildID *ID `json:"guild_id"`
	// Name is the name of the channel if applicable.
	// Regular DMs do not have this, and group DMs only have this if the name is overriden.
	Name *string `json:"name"`
	// Topic is the topic description of the channel if this is a guild channel which has it set.
	Topic *string `json:"topic"`
	// URL is the link the channel opens upon clicking it if the type is [ChannelTypeGuildLink].
	URL *string `json:"url"`
	// Icon is the icon hash of the channel if the type is [ChannelTypeGroupDM].
	Icon *string `json:"icon"`
	// OwnerID is the ID of the user owning this channel if the type is [ChannelTypeGroupDM].
	OwnerID *string `json:"owner_id"`
	// Position is used to sort guild channels.
	Position *int `json:"position"`
	// ParentID is the ID of the category this channel is in if this is a guild channel.
	ParentID *ID `json:"parent_id"`
	// Bitrate is the bitrate in bits per second if the type is [ChannelTypeGuildVoice].
	Bitrate *int `json:"bitrate"`
	// UserLimit is the maximum number of users allowed to join if the type is [ChannelTypeGuildVoice].
	UserLimit *int `json:"user_limit"`
	// RTCRegion is the voice region ID if the type is [ChannelTypeGuildVoice].
	RTCRegion *string `json:"rtc_region"`
	// LastMessageID is the ID of the last sent message if this is a textable channel.
	LastMessageID *ID `json:"last_message_id"`
	// LastPinAt is the time of the last pin if this is a textable channel.
	LastPinAt *time.Time `json:"last_pin_timestamp"`
	// PermOverwrites contains the permission overrides if this is a guild channel.
	PermOverwrites []ChannelPermOverwrite `json:"permission_overwrites"`
	// Recipients contains the users with access to the channel if the type is [ChannelTypeDM] or [ChannelTypeGroupDM].
	Recipients []User `json:"recipients"`
	// NSFW is true if the channel is marked as age-restricted.
	NSFW bool `json:"nsfw"`
	// RateLimitSecs is the slowmode duration in seconds.
	RateLimitSecs int `json:"rate_limit_per_user"`
	// Nicks contains custom nicknames for users inside the channel if the type is [ChannelTypeGroupDM].
	Nicks map[ID]string `json:"nicks"`

	Messages *Collection[Message]
}

Channel represents any kind of channel on Fluxer, which may or may not be able to hold messages.

func (*Channel) BulkDeleteMessages

func (c *Channel) BulkDeleteMessages(ctx context.Context, rest *REST, messageIDs []ID) error

func (*Channel) CreateMessage

func (c *Channel) CreateMessage(ctx context.Context, rest *REST, opts CreateMessageOpts) (Message, error)

func (*Channel) CreateReaction

func (c *Channel) CreateReaction(ctx context.Context, rest *REST, msgID ID, emoji string) error

func (*Channel) CreateWebhook

func (c *Channel) CreateWebhook(ctx context.Context, rest *REST, opts CreateWebhookOpts) (Webhook, error)

func (*Channel) CreatedAt

func (c *Channel) CreatedAt() time.Time

func (*Channel) Delete

func (c *Channel) Delete(ctx context.Context, rest *REST) error

func (*Channel) DeleteMessage

func (c *Channel) DeleteMessage(ctx context.Context, rest *REST, msgID ID) error

func (*Channel) EditMessage

func (c *Channel) EditMessage(ctx context.Context, rest *REST, msgID ID, opts EditMessageOpts) (Message, error)

func (*Channel) GetMessage

func (c *Channel) GetMessage(ctx context.Context, rest *REST, msgID ID) (Message, error)

func (*Channel) GetMessages

func (c *Channel) GetMessages(ctx context.Context, rest *REST, opts GetMessagesOpts) ([]Message, error)

func (*Channel) GetWebhooks

func (c *Channel) GetWebhooks(ctx context.Context, rest *REST) ([]Webhook, error)

func (*Channel) IsTextable

func (c *Channel) IsTextable() bool

IsTextable returns true if the channel can contains messages.

func (*Channel) MemberOverwrite

func (c *Channel) MemberOverwrite(userID ID) (ChannelPermOverwrite, bool)

func (*Channel) Mention

func (c *Channel) Mention() string

Mention creates a string which can be used to display the channel in chat.

func (*Channel) RemoveAllReactions

func (c *Channel) RemoveAllReactions(ctx context.Context, rest *REST, msgID ID) error

func (*Channel) RemoveEmojiReactions

func (c *Channel) RemoveEmojiReactions(ctx context.Context, rest *REST, msgID ID, emoji string) error

func (*Channel) RemoveOwnReaction

func (c *Channel) RemoveOwnReaction(ctx context.Context, rest *REST, msgID ID, emoji string) error

func (*Channel) RemoveReaction

func (c *Channel) RemoveReaction(ctx context.Context, rest *REST, msgID ID, emoji string, userID ID) error

func (*Channel) RoleOverwrite

func (c *Channel) RoleOverwrite(roleID ID) (ChannelPermOverwrite, bool)

func (*Channel) StartTyping

func (c *Channel) StartTyping(ctx context.Context, rest *REST) error

func (*Channel) Update

func (c *Channel) Update(ctx context.Context, rest *REST, opts UpdateChannelOpts) error

type ChannelCreateEvent

type ChannelCreateEvent struct {
	Shard *Shard `json:"-"`
	Channel
}

type ChannelDeleteEvent

type ChannelDeleteEvent struct {
	Shard *Shard `json:"-"`
	Channel
}

type ChannelPermOverwrite

type ChannelPermOverwrite struct {
	ID    ID                       `json:"id"`
	Type  ChannelPermOverwriteType `json:"type"`
	Allow Perms                    `json:"allow"`
	Deny  Perms                    `json:"deny"`
}

type ChannelPermOverwriteType

type ChannelPermOverwriteType uint
const (
	ChannelPermOverwriteTypeRole   ChannelPermOverwriteType = 0
	ChannelPermOverwriteTypeMember ChannelPermOverwriteType = 1
)

func (ChannelPermOverwriteType) String

func (i ChannelPermOverwriteType) String() string

type ChannelType

type ChannelType uint
const (
	ChannelTypeGuildText     ChannelType = 0
	ChannelTypeDM            ChannelType = 1
	ChannelTypeGuildVoice    ChannelType = 2
	ChannelTypeGroupDM       ChannelType = 3
	ChannelTypeGuildCategory ChannelType = 4
	ChannelTypeGuildLink     ChannelType = 998
	ChannelTypePersonalNotes ChannelType = 999
)

func (ChannelType) IsGuild

func (c ChannelType) IsGuild() bool

func (ChannelType) IsPrivate

func (c ChannelType) IsPrivate() bool

func (ChannelType) IsTextable

func (c ChannelType) IsTextable() bool

func (ChannelType) String

func (i ChannelType) String() string

type ChannelUpdateBulkEvent

type ChannelUpdateBulkEvent struct {
	Shard    *Shard    `json:"-"`
	GuildID  ID        `json:"guild_id"`
	Channels []Channel `json:"channels"`
}

type ChannelUpdateEvent

type ChannelUpdateEvent struct {
	Shard *Shard `json:"-"`
	Channel
}

type Collection

type Collection[T any] struct {
	// contains filtered or unexported fields
}

A Collection is a possibly-limited thread-safe set of Fluxer entities looked up by ID. The zero value has a limit of 0, so writes will be ignored. A nil *Collection can be read, but writes will panic. Assigning a new collection to an existing one is not a thread-safe operation.

func NewCollection

func NewCollection[T any](limit int) Collection[T]

NewCollection creates a new collection with a limited amount of items. If the limit is reached, the least recently used item will be removed upon adding a new item. Passing a limit under 0 will result in a panic. Use NewCollectionUnlimited if you don't want to number of items to be limited.

func NewCollectionUnlimited

func NewCollectionUnlimited[T any]() Collection[T]

NewCollectionUnlimited creates a new collection which can hold an unlimited amount of items.

func (*Collection[T]) Clear

func (c *Collection[T]) Clear()

Clear removes all items from the collection.

func (*Collection[T]) Contains

func (c *Collection[T]) Contains(id ID) bool

Contains returns true if an item with the specified ID is included in the collection. It does not update the item's recency.

func (*Collection[T]) Delete

func (c *Collection[T]) Delete(id ID) (*T, bool)

Delete removes the item with the specified ID from the collection.

func (*Collection[T]) Get

func (c *Collection[T]) Get(id ID) (T, bool)

Get returns a value in the collection by ID. It marks the item as most recently used if a limit is set.

func (*Collection[T]) IDs

func (c *Collection[T]) IDs() iter.Seq[ID]

IDs returns a sequence of the item IDs in the collection. The order is effectively random. !! Important: While iterating, no writes may happen - you should therefore not have any blocking operations or call other [Collect] methods within the loop.

func (*Collection[T]) Items

func (c *Collection[T]) Items() iter.Seq2[ID, T]

Items returns a sequence of the items in the collection. The order is effectively random. !! Important: While iterating, no writes may happen - you should therefore not have any blocking operations or call other Collection methods within the loop.

func (*Collection[T]) Len

func (c *Collection[T]) Len() int

Len returns the number of items in the collection.

func (*Collection[T]) Limit

func (c *Collection[T]) Limit() (int, bool)

Limit returns the item limit if the collection is limited. Otherwise it returns -1, false.

func (*Collection[T]) Set

func (c *Collection[T]) Set(id ID, val T)

Set adds or updates the item with the specified ID in the collection. It marks the item as most recently used if a limit is set.

func (*Collection[T]) Update

func (c *Collection[T]) Update(id ID, update func(val *T)) bool

Update allows safely updating the item with the specified ID from the collection through a pointer if it is present. It marks the item as most recently used if a limit is set. Copying the value is fine, but the pointer should not be copied outside the closure.

func (*Collection[T]) Upsert

func (c *Collection[T]) Upsert(id ID, val T, update func(val *T)) bool

Upsert behaves like Update, but in the case where it returns false i.e. an item was not updated, it is added instead.

type ColorInt

type ColorInt uint32

ColorInt represents a Fluxer RGB color value. 0xRRGGBB can be used to create a color.

func (ColorInt) String

func (c ColorInt) String() string

String returns a hex color code string for the color.

type CreateAttachmentOpts

type CreateAttachmentOpts struct {
	// ID is the fake ID used for the attachment in the request.
	// If left as 0, ascending numbers will be used.
	// An actual [ID] will be generated in the response.
	ID          uint            `json:"id"`
	Filename    string          `json:"filename"`
	Title       string          `json:"title,omitempty"`
	Description string          `json:"description,omitempty"`
	Flags       AttachmentFlags `json:"flags,omitzero"`
	// Content is used to provide attachment data. It should not be nil.
	Content io.ReadCloser `json:"-"`
}

CreateAttachmentOpts specifies an attachment when creating a message.

type CreateGuildBanOpts

type CreateGuildBanOpts struct {
	// DeleteMessageDays is the days worth of messages to delete (0-7).
	DeleteMessageDays uint
	// Reason specifies the reason which appears in the ban list.
	Reason string
	// AuditLogReason specifies an audit-log specific reason which does not persist.
	AuditLogReason string
	// BanDuration specifies how long to ban the user for if not 0.
	// It is converted to seconds so anything more precise will be lost.
	BanDuration time.Duration
}

type CreateGuildChannelOpts

type CreateGuildChannelOpts struct {
	Type     ChannelType `json:"type"`
	Name     string      `json:"name,omitempty"`
	Topic    string      `json:"topic,omitempty"`
	URL      string      `json:"url,omitempty"`
	ParentID ID          `json:"parent_id,omitempty"`
	Bitrate  int         `json:"bitrate,omitzero"`
	NSFW     bool        `json:"nsfw,omitzero"`
}

type CreateGuildEmojiOpts

type CreateGuildEmojiOpts struct {
	Name string `json:"name"`
	// Image is the base64 encoded image of the emoji.
	Image string `json:"image"`
}

type CreateGuildStickerOpts

type CreateGuildStickerOpts struct {
	Name string `json:"name"`
	// Image is the base64 encoded image of the sticker.
	Image       string   `json:"image"`
	Description string   `json:"description,omitempty"`
	Tags        []string `json:"tags,omitempty"`
}

type CreateMessageOpts

type CreateMessageOpts struct {
	Content          string                 `json:"content,omitempty"`
	Embeds           []EmbedOpts            `json:"embeds,omitempty"`
	Attachments      []CreateAttachmentOpts `json:"attachments,omitempty"`
	MessageReference MessageReferenceOpts   `json:"message_reference,omitzero"`
	AllowedMentions  *AllowedMentions       `json:"allowed_mentions,omitempty"`
	Flags            MessageFlags           `json:"flags,omitzero"`
	Nonce            string                 `json:"nonce,omitempty"`
	StickerIDs       []ID                   `json:"sticker_ids,omitempty"`
	TTS              bool                   `json:"tts,omitzero"`
}

CreateMessageOpts specifies a message to send.

type CreateRoleOpts

type CreateRoleOpts struct {
	Name  string   `json:"name"`
	Color ColorInt `json:"color"`
	Perms *Perms   `json:"permissions,omitempty"`
}

type CreateWebhookOpts

type CreateWebhookOpts struct {
	Name string `json:"name"`
	// Avatar is the webhook avatar in base64.
	Avatar string `json:"avatar,omitempty"`
}

type CustomStatusOpts

type CustomStatusOpts struct {
	Text          string    `json:"text,omitempty"`
	ExpiresAt     time.Time `json:"expires_at,omitzero"`
	EmojiID       string    `json:"emoji_id,omitempty"`
	EmojiName     string    `json:"emoji_name,omitempty"`
	EmojiAnimated bool      `json:"emoji_animated"`
}

type EditAttachmentOpts

type EditAttachmentOpts struct {
	// ID is the ID of an existing attachment to keep or a fake ID for a new attachment.
	// If left as 0 ascending numbers will be be used in the request - you probably want to do this for new attachments.
	// An actual [ID] will be generated for new attachments in the response.
	ID       ID     `json:"id"`
	Filename string `json:"filename"`
	// Content is used to provide attachment data. It should be nil for existing attachments but not for new ones.
	Content io.ReadCloser `json:"-"`
}

EditAttachmentOpts specifies a possibly preexisting attachment when editing a message.

type EditMessageOpts

type EditMessageOpts struct {
	Content         *string              `json:"content,omitempty"`
	Embeds          []EmbedOpts          `json:"embeds,omitzero"`
	AllowedMentions *AllowedMentions     `json:"allowed_mentions,omitempty"`
	Attachments     []EditAttachmentOpts `json:"attachments,omitzero"`
	Flags           *MessageFlags        `json:"flags,omitempty"`
}

EditMessageOpts specifies message fields to edit. A field being left as nil indicates to keep it the same.

type EditWebhookMessageOpts

type EditWebhookMessageOpts struct {
	Content         *string          `json:"content,omitempty"`
	Embeds          []EmbedOpts      `json:"embeds,omitzero"`
	AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"`
	Flags           *MessageFlags    `json:"flags,omitempty"`
}

EditWebhookOpts specifies webhook message fields to edit. A field being left as nil indicates to keep it the same.

type Embed

type Embed struct {
	Type        EmbedType    `json:"type"`
	URL         *string      `json:"url"`
	Title       *string      `json:"title"`
	Color       *ColorInt    `json:"color"`
	Timestamp   *time.Time   `json:"timestamp"`
	Description *string      `json:"description"`
	Author      *EmbedAuthor `json:"author"`
	Image       *EmbedMedia  `json:"image"`
	Thumbnail   *EmbedMedia  `json:"thumbnail"`
	Footer      *EmbedFooter `json:"footer"`
	Fields      []EmbedField `json:"fields"`
	Provider    *EmbedAuthor `json:"provider"`
	Video       *EmbedMedia  `json:"video"`
	Audio       *EmbedMedia  `json:"audio"`
	// Children is a list of internal nested embeds generated by unfurlers.
	// Each child will not contain any further children.
	Children []Embed `json:"children"`
}

type EmbedAuthor

type EmbedAuthor struct {
	Name         string  `json:"name"`
	URL          *string `json:"url"`
	IconURL      *string `json:"icon_url"`
	ProxyIconURL *string `json:"proxy_icon_url"`
}

type EmbedAuthorOpts

type EmbedAuthorOpts struct {
	Name    string `json:"name"`
	URL     string `json:"url,omitempty"`
	IconURL string `json:"icon_url,omitempty"`
}

EmbedAuthorOpts specifies an embed author when creating or editing a message.

type EmbedField

type EmbedField struct {
	Name   string `json:"name"`
	Value  string `json:"value"`
	Inline bool   `json:"inline"`
}

type EmbedFooter

type EmbedFooter struct {
	Text         string  `json:"text"`
	IconURL      *string `json:"icon_url"`
	ProxyIconURL *string `json:"proxy_icon_url"`
}

type EmbedFooterOpts

type EmbedFooterOpts struct {
	Text    string `json:"text"`
	IconURL string `json:"icon_url,omitempty"`
}

EmbedAuthorOpts specifies an embed footer when creating or editing a message.

type EmbedMedia

type EmbedMedia struct {
	URL         string          `json:"url"`
	ProxyURL    *string         `json:"proxy_url"`
	ContentType *string         `json:"content_type"`
	ContentHash *string         `json:"content_hash"`
	Width       *int            `json:"width"`
	Height      *int            `json:"height"`
	Description *string         `json:"description"`
	Placeholder *string         `json:"placeholder"`
	Duration    *time.Duration  `json:"duration"`
	Flags       EmbedMediaFlags `json:"flags"`
}

type EmbedMediaFlags

type EmbedMediaFlags uint

type EmbedMediaOpts

type EmbedMediaOpts struct {
	URL         string `json:"url"`
	Description string `json:"description,omitempty"`
}

EmbedAuthorOpts specifies embed media when creating or editing a message.

type EmbedOpts

type EmbedOpts struct {
	URL         string          `json:"url,omitempty"`
	Title       string          `json:"title,omitempty"`
	Color       ColorInt        `json:"color,omitzero"`
	Timestamp   time.Time       `json:"timestamp,omitzero"`
	Description string          `json:"description,omitempty"`
	Author      EmbedAuthorOpts `json:"author,omitzero"`
	Image       EmbedMediaOpts  `json:"image,omitzero"`
	Thumbnail   EmbedMediaOpts  `json:"thumbnail,omitzero"`
	Footer      EmbedFooterOpts `json:"footer,omitzero"`
	Fields      []EmbedField    `json:"fields,omitempty"`
}

EmbedOpts specifies a rich embed when creating or editing a message.

type EmbedType

type EmbedType string

type ExecWebhookOpts

type ExecWebhookOpts struct {
	Content          string                 `json:"content,omitempty"`
	Embeds           []EmbedOpts            `json:"embeds,omitempty"`
	Attachments      []CreateAttachmentOpts `json:"attachments,omitempty"`
	MessageReference MessageReferenceOpts   `json:"message_reference,omitzero"`
	AllowedMentions  *AllowedMentions       `json:"allowed_mentions,omitempty"`
	Flags            MessageFlags           `json:"flags,omitzero"`
	Nonce            string                 `json:"nonce,omitempty"`
	StickerIDs       []ID                   `json:"sticker_ids,omitempty"`
	TTS              bool                   `json:"tts,omitzero"`
	Username         string                 `json:"username,omitempty"`
	AvatarURL        string                 `json:"avatar_url,omitempty"`
}

type Gateway

type Gateway struct {
	// Auth specifies the token to send when connecting.
	Auth string
	// Cache specifies the caching target. If nil is specified, nothing is cached.
	Cache *Cache
	// ConnURL specifies the initial URL for establishing a connection.
	// If not specified, [DefaultGatewayURL] is used.
	// If ?v=[num] is specified, it will be used as the gateway API version; otherwise [DefaultGatewayVersion] will be used.
	// Be careful when changing the version number - it will likely break the library and cause disconnects.
	ConnURL *url.URL
	// Dialer specifies options for connecting to the WebSocket server (from Gorilla WebSocket).
	// If nil, websocket.DefaultDialer is used.
	Dialer *websocket.Dialer
	// ReconnectDelay determines how long to wait before reconnecting on the nth dial attempt.
	ReconnectDelay func(n uint) time.Duration

	// FirstShard is the first and lowest shard ID to connect to.
	// If it is greater than LastShard trying to access any shard will panic.
	FirstShard uint
	// LastShard is the final and highest shard ID to connect to.
	// If it is less than FirstShard trying to access any shard will panic.
	LastShard uint
	// TotalShards is the total amount of shards that the bot will indicate it will use.
	// If left unset it will be determined from the highest shard ID + 1.
	TotalShards uint

	// Logger is the [slog.Logger] used by shards to log useful information.
	Logger *slog.Logger
	// contains filtered or unexported fields
}

Gateway manages one or more [Shard]s and provides a high-level interface for listening to events. Sharding is supported, but at the time of writing Fluxer does not support it yet - it has instead been tested with Discord.

func (*Gateway) ExpectShard

func (g *Gateway) ExpectShard(id uint) *Shard

Shard returns the shard by the specified ID, which may or may not be connected. If it does not exist on this gateway object, it will panic. The sharding parameters should not be changed after this is called.

func (*Gateway) Reconnect

func (g *Gateway) Reconnect() error

Reconnect attemps to reconnect all running shards. If some of the shards were not running or already disconnecting/stopping an error will be returned.

func (*Gateway) RunningShards

func (g *Gateway) RunningShards() uint

RunningShards returns the count of shards that are running.

func (*Gateway) SetPresence

func (g *Gateway) SetPresence(opts PresenceOpts)

SetPresence sets the presence to be used by all shards. If a shard is currently connected it will be sent immediately, otherwise it will be sent the next time the shard connects. This means you can call this before Start! To set a presence for a specific shard, see Shard.SetPresence.

func (*Gateway) Shard

func (g *Gateway) Shard(id uint) (*Shard, bool)

Shard returns the shard by the specified ID, which may or may not be connected. The sharding parameters should not be changed after this is called.

func (*Gateway) Shards

func (g *Gateway) Shards() []*Shard

Shards returns the list of shards which will be connected to. The sharding parameters should not be changed after this is called.

func (*Gateway) Start

func (g *Gateway) Start() error

Start attemps to starts all shards. The sharding parameters should not be changed after this is called. An error will be returned if any of the shards are already running - you may ignore this if it is not important.

func (*Gateway) Stop

func (g *Gateway) Stop() error

Stop attemps to stop all running shards. If some of the shards were not running or already stopping an error will be returned.

type GatewayOpcode

type GatewayOpcode uint
const (
	GatewayOpDispatch            GatewayOpcode = 0
	GatewayOpHeartbeat           GatewayOpcode = 1
	GatewayOpIdentify            GatewayOpcode = 2
	GatewayOpPresenceUpdate      GatewayOpcode = 3
	GatewayOpVoiceStateUpdate    GatewayOpcode = 4
	GatewayOpResume              GatewayOpcode = 6
	GatewayOpReconnect           GatewayOpcode = 7
	GatewayOpRequestGuildMembers GatewayOpcode = 8
	GatewayOpInvalidSession      GatewayOpcode = 9
	GatewayOpHello               GatewayOpcode = 10
	GatewayOpHeartbeatACK        GatewayOpcode = 11
)

func (GatewayOpcode) String

func (i GatewayOpcode) String() string

type GatewayPacket

type GatewayPacket struct {
	Opcode GatewayOpcode   `json:"op"`
	Data   json.RawMessage `json:"d"`
	Seq    *uint           `json:"s"`
	Event  *string         `json:"t"`
}

type GetMembersOpts

type GetMembersOpts struct {
	// Limit is specified as limit=... in the URL if not 0.
	Limit int
	// After is specified as after=... in the URL if not 0.
	After ID
}

type GetMessagesOpts

type GetMessagesOpts struct {
	// Around is specified as around=... in the URL if not 0.
	Around ID
	// Before is specified as before=... in the URL if not 0.
	Before ID
	// After is specified as after=... in the URL if not 0.
	After ID
	// Limit is specified as limit=... in the URL if not 0.
	Limit int
}

type Guild

type Guild struct {
	ID                    ID                         `json:"id"`
	Name                  string                     `json:"name"`
	Icon                  *string                    `json:"icon"`
	Banner                *string                    `json:"banner"`
	BannerWidth           *int                       `json:"banner_width"`
	BannerHeight          *int                       `json:"banner_height"`
	Splash                *string                    `json:"splash"`
	SplashWidth           *int                       `json:"splash_width"`
	SplashHeight          *int                       `json:"splash_height"`
	SplashCardAlignment   GuildSplashCardAlignment   `json:"splash_card_alignment"`
	EmbedSplash           *string                    `json:"embed_splash"`
	EmbedSplashWidth      *int                       `json:"embed_splash_width"`
	EmbedSplashHeight     *int                       `json:"embed_splash_height"`
	VanityURLCode         *string                    `json:"vanity_url_code"`
	OwnerID               ID                         `json:"owner_id"`
	SystemChannelID       *ID                        `json:"system_channel_id"`
	SystemChannelFlags    GuildSystemChannelFlags    `json:"system_channel_flags"`
	RulesChannelID        *ID                        `json:"rules_channel_id"`
	AFKChannelID          *ID                        `json:"afk_channel_id"`
	AFKTimeoutSecs        int                        `json:"afk_timeout"`
	Features              []GuildFeature             `json:"features"`
	VerifLevel            GuildVerifLevel            `json:"verification_level"`
	MFALevel              GuildMFALevel              `json:"mfa_level"`
	NSFWLevel             GuildNSFWLevel             `json:"nsfw_level"`
	ExplicitContentFilter GuildExplicitContentFilter `json:"explicit_content_filter"`
	DefaultMessageNotifs  UserNotifSettings          `json:"default_message_notifications"`
	DisabledOperations    GuildOperations            `json:"disabled_operations"`
	MessageHistoryCutoff  *time.Time                 `json:"message_history_cutoff"`

	// Channels is the known channels of the guild.
	// If the guild is cached, they will be automatically updated.
	Channels *Collection[Channel] `json:"-"`
	// Roles is the known roles of the guild.
	// If the guild is cached, they will be automatically updated.
	Roles *Collection[Role] `json:"-"`
	// Members is the known members of the guild.
	// If the guild is cached, they will be automatically updated.
	Members *Collection[Member] `json:"-"`
	// Emojis is the known emojis of the guild.
	// If the guild is cached, they will be automatically updated.
	Emojis *Collection[GuildEmoji] `json:"-"`
	// Stickers is the known stickers of the guild.
	// If the guild is cached, they will be automatically updated.
	Stickers *Collection[GuildSticker] `json:"-"`
}

func (*Guild) AddMemberRole

func (g *Guild) AddMemberRole(ctx context.Context, rest *REST, userID ID, roleID ID) error

func (*Guild) AddMemberRoleWithReason

func (g *Guild) AddMemberRoleWithReason(ctx context.Context, rest *REST, userID ID, roleID ID, reason string) error

func (*Guild) CreateBan

func (g *Guild) CreateBan(ctx context.Context, rest *REST, userID ID, opts CreateGuildBanOpts) error

func (*Guild) CreateChannel

func (g *Guild) CreateChannel(ctx context.Context, rest *REST, opts CreateGuildChannelOpts) (Channel, error)

func (*Guild) CreateEmoji

func (g *Guild) CreateEmoji(ctx context.Context, rest *REST, opts CreateGuildEmojiOpts) (GuildEmoji, error)

func (*Guild) CreateRole

func (g *Guild) CreateRole(ctx context.Context, rest *REST, opts CreateRoleOpts) (Role, error)

func (*Guild) CreateSticker

func (g *Guild) CreateSticker(ctx context.Context, rest *REST, opts CreateGuildStickerOpts) (GuildSticker, error)

func (*Guild) CreatedAt

func (g *Guild) CreatedAt() time.Time

func (*Guild) DeleteEmoji

func (g *Guild) DeleteEmoji(ctx context.Context, rest *REST, emojiID ID) error

func (*Guild) DeleteRole

func (g *Guild) DeleteRole(ctx context.Context, rest *REST, roleID ID) error

func (*Guild) DeleteSticker

func (g *Guild) DeleteSticker(ctx context.Context, rest *REST, stickerID ID) error

func (*Guild) GetBans

func (g *Guild) GetBans(ctx context.Context, rest *REST) ([]GuildBan, error)

func (*Guild) GetCurrentMember

func (g *Guild) GetCurrentMember(ctx context.Context, rest *REST) (Member, error)

func (*Guild) GetEmoji

func (g *Guild) GetEmoji(ctx context.Context, rest *REST, emojiID ID) (GuildEmoji, error)

func (*Guild) GetMember

func (g *Guild) GetMember(ctx context.Context, rest *REST, userID ID) (Member, error)

func (*Guild) GetMembers

func (g *Guild) GetMembers(ctx context.Context, rest *REST, opts GetMembersOpts) ([]Member, error)

func (*Guild) GetRole

func (g *Guild) GetRole(ctx context.Context, rest *REST, roleID ID) (Role, error)

func (*Guild) GetSticker

func (g *Guild) GetSticker(ctx context.Context, rest *REST, stickerID ID) (GuildSticker, error)

func (*Guild) GetWebhooks

func (g *Guild) GetWebhooks(ctx context.Context, rest *REST) ([]Webhook, error)

func (*Guild) Leave

func (g *Guild) Leave(ctx context.Context, rest *REST) error

func (*Guild) RemoveBan

func (g *Guild) RemoveBan(ctx context.Context, rest *REST, userID ID) error

func (*Guild) RemoveBanWithReason

func (g *Guild) RemoveBanWithReason(ctx context.Context, rest *REST, userID ID, reason string) error

func (*Guild) RemoveMember

func (g *Guild) RemoveMember(ctx context.Context, rest *REST, userID ID) error

func (*Guild) RemoveMemberRole

func (g *Guild) RemoveMemberRole(ctx context.Context, rest *REST, userID ID, roleID ID) error

func (*Guild) RemoveMemberRoleWithReason

func (g *Guild) RemoveMemberRoleWithReason(ctx context.Context, rest *REST, userID ID, roleID ID, reason string) error

func (*Guild) RemoveMemberWithReason

func (g *Guild) RemoveMemberWithReason(ctx context.Context, rest *REST, userID ID, reason string) error

func (*Guild) ResolvePerms

func (g *Guild) ResolvePerms(member Member) Perms

ResolvePerms resolves the permissions from the roles which are available in Guild.Roles. If a Role is not available, it will be ignored.

func (*Guild) ResolvePermsInChannel

func (g *Guild) ResolvePermsInChannel(member Member, channel Channel) (Perms, bool)

ResolvePermsInChannel resolves permissions of a member for a channel in this guild. Perms{}, false is returned if the channel is from outside this guild.

func (*Guild) UpdateCurrentMember

func (g *Guild) UpdateCurrentMember(ctx context.Context, rest *REST, opts UpdateCurrentMemberOpts) (Member, error)

func (*Guild) UpdateEmoji

func (g *Guild) UpdateEmoji(ctx context.Context, rest *REST, emojiID ID, opts UpdateGuildEmojiOpts) (GuildEmoji, error)

func (*Guild) UpdateMember

func (g *Guild) UpdateMember(ctx context.Context, rest *REST, userID ID, opts UpdateMemberOpts) (Member, error)

func (*Guild) UpdateRole

func (g *Guild) UpdateRole(ctx context.Context, rest *REST, roleID ID, opts UpdateRoleOpts) (Role, error)

func (*Guild) UpdateSticker

func (g *Guild) UpdateSticker(ctx context.Context, rest *REST, stickerID ID, opts UpdateGuildStickerOpts) (GuildSticker, error)

type GuildAddEvent

type GuildAddEvent struct {
	Shard *Shard `json:"-"`
	Guild
}

GuildAddEvent represents a guild becoming available or being joined.

type GuildBan

type GuildBan struct {
	User        User       `json:"user"`
	Reason      string     `json:"reason"`
	ModeratorID ID         `json:"moderator_id"`
	BannedAt    time.Time  `json:"banned_at"`
	ExpiresAt   *time.Time `json:"expires_at"`
}

GuildBan represents a member ban in a guild.

type GuildBanAddEvent

type GuildBanAddEvent struct {
	Shard   *Shard
	GuildID ID
	UserID  ID
}

func (*GuildBanAddEvent) Guild

func (e *GuildBanAddEvent) Guild(cache *Cache) (Guild, bool)

Guild returns the guild where the user was banned if it is cached.

func (*GuildBanAddEvent) User

func (e *GuildBanAddEvent) User(cache *Cache) (User, bool)

User returns the user that was banned if it is cached.

type GuildBanRemoveEvent

type GuildBanRemoveEvent struct {
	Shard   *Shard
	GuildID ID
	UserID  ID
}

func (*GuildBanRemoveEvent) Guild

func (e *GuildBanRemoveEvent) Guild(cache *Cache) (Guild, bool)

Guild returns the guild where the user was unbanned if it is cached.

func (*GuildBanRemoveEvent) User

func (e *GuildBanRemoveEvent) User(cache *Cache) (User, bool)

User returns the user that was unbanned if it is cached.

type GuildEmoji

type GuildEmoji struct {
	ID       ID     `json:"id"`
	Name     string `json:"name"`
	Animated bool   `json:"animated"`
	// User is the user who uploaded the emoji, which may not be available in all responses.
	User *User `json:"user"`
}

GuildEmoji represents a custom emoji in a guild.

func (*GuildEmoji) CreatedAt

func (e *GuildEmoji) CreatedAt() time.Time

func (*GuildEmoji) Render

func (e *GuildEmoji) Render() string

Render creates a string that can be used to display the emoji in chat.

type GuildEmojisUpdateEvent

type GuildEmojisUpdateEvent struct {
	Shard   *Shard       `json:"-"`
	GuildID ID           `json:"guild_id"`
	Emojis  []GuildEmoji `json:"emojis"`
}

func (*GuildEmojisUpdateEvent) Guild

func (e *GuildEmojisUpdateEvent) Guild(cache *Cache) (Guild, bool)

Guild returns the guild where the emojis are being updated if it is cached.

type GuildExplicitContentFilter

type GuildExplicitContentFilter uint
const (
	GuildExplicitContentFilterDisabled            GuildExplicitContentFilter = 0
	GuildExplicitContentFilterMembersWithoutRoles GuildExplicitContentFilter = 1
	GuildExplicitContentFilterAllMembers          GuildExplicitContentFilter = 2
)

func (GuildExplicitContentFilter) String

type GuildFeature

type GuildFeature string
const (
	GuildFeatureAnimatedIcon                   GuildFeature = "ANIMATED_ICON"
	GuildFeatureAnimatedBanner                 GuildFeature = "ANIMATED_BANNER"
	GuildFeatureBanner                         GuildFeature = "BANNER"
	GuildFeatureDetachedBanner                 GuildFeature = "DETACHED_BANNER"
	GuildFeatureInviteSplash                   GuildFeature = "INVITE_SPLASH"
	GuildFeatureInvitesDisabled                GuildFeature = "INVITES_DISABLED"
	GuildFeatureTextChannelFlexibleNames       GuildFeature = "TEXT_CHANNEL_FLEXIBLE_NAMES"
	GuildFeatureMoreEmoji                      GuildFeature = "MORE_EMOJI"
	GuildFeatureMoreStickers                   GuildFeature = "MORE_STICKERS"
	GuildFeatureUnlimitedEmoji                 GuildFeature = "UNLIMITED_EMOJI"
	GuildFeatureUnlimitedStickers              GuildFeature = "UNLIMITED_STICKERS"
	GuildFeatureExpressionPurgeAllowed         GuildFeature = "EXPRESSION_PURGE_ALLOWED"
	GuildFeatureVanityURL                      GuildFeature = "VANITY_URL"
	GuildFeatureDiscoverable                   GuildFeature = "DISCOVERABLE"
	GuildFeaturePartnered                      GuildFeature = "PARTNERED"
	GuildFeatureVerified                       GuildFeature = "VERIFIED"
	GuildFeatureVIPVoice                       GuildFeature = "VIP_VOICE"
	GuildFeatureUnavailableForEveryone         GuildFeature = "UNAVAILABLE_FOR_EVERYONE"
	GuildFeatureUnavailableForEveryoneButStaff GuildFeature = "UNAVAILABLE_FOR_EVERYONE_BUT_STAFF"
	GuildFeatureVisionary                      GuildFeature = "VISIONARY"
	GuildFeatureOperator                       GuildFeature = "OPERATOR"
	GuildFeatureLargeGuildOverride             GuildFeature = "LARGE_GUILD_OVERRIDE"
	GuildFeatureVeryLargeGuild                 GuildFeature = "VERY_LARGE_GUILD"
)

type GuildMFALevel

type GuildMFALevel uint
const (
	GuildMFALevelNone     GuildMFALevel = 0
	GuildMFALevelElevated GuildMFALevel = 1
)

func (GuildMFALevel) String

func (i GuildMFALevel) String() string

type GuildNSFWLevel

type GuildNSFWLevel uint
const (
	GuildNSFWLevelDefault       GuildNSFWLevel = 0
	GuildNSFWLevelExplicit      GuildNSFWLevel = 1
	GuildNSFWLevelSafe          GuildNSFWLevel = 2
	GuildNSFWLevelAgeRestricted GuildNSFWLevel = 3
)

func (GuildNSFWLevel) String

func (i GuildNSFWLevel) String() string

type GuildOperations

type GuildOperations uint
const (
	GuildOperationPushNotifications GuildOperations = 1 << 0
	GuildOperationEveryoneMentions  GuildOperations = 1 << 1
	GuildOperationTypingEvents      GuildOperations = 1 << 2
	GuildOperationInstantInvites    GuildOperations = 1 << 3
	GuildOperationSendMessage       GuildOperations = 1 << 4
	GuildOperationReactions         GuildOperations = 1 << 5
	GuildOperationMemberListUpdates GuildOperations = 1 << 6
)

type GuildRemoveEvent

type GuildRemoveEvent struct {
	Shard *Shard
	ID    ID
	// Cached is the guild that was removed from the cache by this event, if any.
	Cached *Guild
}

GuildRemoveEvent represents a guild becoming unavailable or being left/deleted.

type GuildSplashCardAlignment

type GuildSplashCardAlignment uint
const (
	GuildSplashCardAlignCenter GuildSplashCardAlignment = 0
	GuildSplashCardAlignLeft   GuildSplashCardAlignment = 1
	GuildSplashCardAlignRight  GuildSplashCardAlignment = 2
)

func (GuildSplashCardAlignment) String

func (i GuildSplashCardAlignment) String() string

type GuildSticker

type GuildSticker struct {
	ID          ID       `json:"id"`
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Tags        []string `json:"tags"`
	Animated    bool     `json:"animated"`
	// User is the user who uploaded the emoji, which may not be available in all responses.
	User *User `json:"user"`
}

GuildSticker reperesents a custom sticker in a guild.

type GuildStickersUpdateEvent

type GuildStickersUpdateEvent struct {
	Shard    *Shard         `json:"-"`
	GuildID  ID             `json:"guild_id"`
	Stickers []GuildSticker `json:"stickers"`
}

func (*GuildStickersUpdateEvent) Guild

func (e *GuildStickersUpdateEvent) Guild(cache *Cache) (Guild, bool)

Guild returns the guild where the stickers are being updated if it is cached.

type GuildSystemChannelFlags

type GuildSystemChannelFlags uint
const (
	SystemChannelFlagSupressJoinNotifications GuildSystemChannelFlags = 1 << 0
)

type GuildUpdateEvent

type GuildUpdateEvent struct {
	Shard *Shard `json:"-"`
	Guild
}

GuildUpdateEvent represents a guild being updated. The guild collections will only be present if the guild was already cached.

type GuildVerifLevel

type GuildVerifLevel uint
const (
	GuildVerifLevelNone      GuildVerifLevel = 0
	GuildVerifLevelLow       GuildVerifLevel = 1
	GuildVerifLevelMedium    GuildVerifLevel = 2
	GuildVerifLevelHigh      GuildVerifLevel = 3
	GuildVerifLevelVeryHeigh GuildVerifLevel = 4
)

func (GuildVerifLevel) String

func (i GuildVerifLevel) String() string

type ID

type ID uint64

ID represents an ID on Fluxer, which contains an embedded timestamp.

func NewID

func NewID(timestamp time.Time) ID

NewID creates a new dummy ID with the timestamp provided. Two IDs created with the same timestamp using this function will be identical.

func ParseID

func ParseID(s string) (ID, error)

func (ID) CreatedAt

func (id ID) CreatedAt() time.Time

func (ID) MarshalJSON

func (id ID) MarshalJSON() ([]byte, error)

func (*ID) UnmarshalJSON

func (id *ID) UnmarshalJSON(data []byte) error

type InstanceAppPublicConfig

type InstanceAppPublicConfig struct {
	SentryDSN *string `json:"sentry_dsn"`
}

type InstanceCaptchaConfig

type InstanceCaptchaConfig struct {
	Provider         string  `json:"provider"`
	HCaptchaSiteKey  *string `json:"hcaptcha_site_key"`
	TurnstileSiteKey *string `json:"turnstile_site_key"`
}

type InstanceEndpoints

type InstanceEndpoints struct {
	API       *url.URL
	APIClient *url.URL
	APIPublic *url.URL
	Gateway   *url.URL
	Media     *url.URL
	StaticCDN *url.URL
	Marketing *url.URL
	Admin     *url.URL
	Invite    *url.URL
	Gift      *url.URL
	WebApp    *url.URL
}

func (*InstanceEndpoints) UnmarshalJSON

func (e *InstanceEndpoints) UnmarshalJSON(data []byte) error

type InstanceFeatures

type InstanceFeatures struct {
	SMSMFAEnabled       bool `json:"sms_mfa_enabled"`
	VoiceEnabled        bool `json:"voice_enabled"`
	StripeEnabled       bool `json:"stripe_enabled"`
	SelfHosted          bool `json:"self_hosted"`
	ManualReviewEnabled bool `json:"manual_review_enabled"`
}

type InstanceGIFConfig

type InstanceGIFConfig struct {
	Provider string `json:"provider"`
}

type InstanceInfo

type InstanceInfo struct {
	APICodeVersion int                     `json:"api_code_version"`
	Endpoints      InstanceEndpoints       `json:"endpoints"`
	Captcha        InstanceCaptchaConfig   `json:"captcha"`
	Features       InstanceFeatures        `json:"features"`
	GIF            InstanceGIFConfig       `json:"gif"`
	SSO            InstanceSSOConfig       `json:"sso"`
	Limits         InstanceLimitConfig     `json:"limits"`
	Push           InstancePushNotifConfig `json:"push"`
	AppPublic      InstanceAppPublicConfig `json:"app_public"`
}

type InstanceLimitConfig

type InstanceLimitConfig struct {
	TraitDefinitions []string
	Rules            []InstanceLimitRule
	DefaultsHash     string
}

func (*InstanceLimitConfig) UnmarshalJSON

func (c *InstanceLimitConfig) UnmarshalJSON(data []byte) error

type InstanceLimitRule

type InstanceLimitRule struct {
	ID        string                   `json:"id"`
	Filters   InstanceLimitRuleFilters `json:"filters"`
	Overrides map[string]int           `json:"overrides"`
}

type InstanceLimitRuleFilters

type InstanceLimitRuleFilters struct {
	Traits        []string `json:"traits"`
	GuildFeatures []string `json:"guildFeatures"`
}

type InstancePushNotifConfig

type InstancePushNotifConfig struct {
	PublicVAPIDKey *string `json:"public_vapid_key"`
}

type InstanceSSOConfig

type InstanceSSOConfig struct {
	Enabled     bool    `json:"enabled"`
	Enforced    bool    `json:"enforced"`
	DisplayName *string `json:"display_name"`
	RedirectURI string  `json:"redirect_uri"`
}

type ListenerRemoveFunc

type ListenerRemoveFunc func()

ListenerRemoveFunc can be used to remove a listener by calling it.

type Member

type Member struct {
	User              User       `json:"user"`
	Nick              *string    `json:"nick"`
	Avatar            *string    `json:"avatar"`
	Banner            *string    `json:"banner"`
	AccentColor       *ColorInt  `json:"accent_color"`
	Roles             []ID       `json:"roles"`
	JoinedAt          time.Time  `json:"joined_at"`
	Mute              bool       `json:"mute"`
	Deaf              bool       `json:"deaf"`
	CommDisabledUntil *time.Time `json:"communication_disabled_until"`
}

func (*Member) CreatedAt

func (m *Member) CreatedAt() time.Time

func (*Member) DisplayName

func (m *Member) DisplayName() string

DisplayName returns the member's rendered name in chat.

func (*Member) ID

func (m *Member) ID() ID

func (*Member) Mention

func (m *Member) Mention() string

type MemberAddEvent

type MemberAddEvent struct {
	Shard   *Shard `json:"-"`
	GuildID ID     `json:"guild_id"`
	Member
}

func (*MemberAddEvent) Guild

func (e *MemberAddEvent) Guild(cache *Cache) (Guild, bool)

Guild returns the guild where the member is being added if it is cached.

type MemberRemoveEvent

type MemberRemoveEvent struct {
	Shard    *Shard
	GuildID  ID
	MemberID ID
	Cached   *Member
}

func (*MemberRemoveEvent) Guild

func (e *MemberRemoveEvent) Guild(cache *Cache) (Guild, bool)

Guild returns the guild where the member is being removed if it is cached.

type MemberUpdateEvent

type MemberUpdateEvent struct {
	Shard   *Shard `json:"-"`
	GuildID ID     `json:"guild_id"`
	Member
}

func (*MemberUpdateEvent) Guild

func (e *MemberUpdateEvent) Guild(cache *Cache) (Guild, bool)

Guild returns the guild where the member is being updated if it is cached.

type Message

type Message struct {
	// ID is the globally unique identifier for the message.
	ID ID `json:"id"`
	// ChannelID is the channel that the message belongs to.
	ChannelID ID `json:"channel_id"`
	// Type is the type of message.
	Type MessageType `json:"type"`
	// Author is the user which sent the message.
	// If WebhookID is not nil, this is a fake webhook user.
	// For non-default/reply messages this is the user performing the action.
	Author User `json:"author"`
	// WebhookID is the ID of the webhook which sent the message.
	WebhookID *ID `json:"webhook_id"`
	// Flags is a set of flags on the message.
	Flags MessageFlags `json:"flags"`
	// Content is the textual content of the message, if any.
	// The meaning varies widely depending on the message type.
	// You should probably check the message type before reading this.
	Content string `json:"content"`
	// EditedAt is the time when the message was last edited.
	EditedAt *time.Time `json:"edited_timestamp"`
	// Pinned is true if the message is pinned.
	Pinned bool `json:"pinned"`
	// MentionEveryone is true if the message mentions @everyone.
	MentionEveryone bool `json:"mention_everyone"`
	// TTS is true if the message is text-to-speech.
	TTS bool `json:"tts"`
	// Mentions contains the users mentioned by the message.
	Mentions []User `json:"mentions"`
	// MentionRoles contains the roles mentioned by the message.
	MentionRoles []ID `json:"mention_roles"`
	// Embeds contains the embeds attached to the message.
	Embeds []Embed `json:"embeds"`
	// Attachments contains the files attached to the attached
	Attachments []Attachment `json:"attachments"`
	// Stickers contains the stickers sent with the message.
	Stickers []MessageSticker `json:"stickers"`
	// Reactions contains the reactions on the message.
	Reactions []MessageReaction `json:"reactions"`
	// MessageReference identifies the forwarded or replied to message.
	MessageReference *MessageReference `json:"message_reference"`
	// ReferencedMessage is the message that is being replied to.
	ReferencedMessage *Message `json:"referenced_message"` // TODO: also add MessageSnaphots
	// Call specifies the call the message represents if the type is [MessageTypeCall].
	Call *MessageCall `json:"call"`
	// Nonce is a string that can be set when creating a message and checked to verify it has been sent.
	// This will only be present if the message was received over the gateway - so either in an event or the message cache.
	Nonce *string `json:"nonce"`
}

func (*Message) Channel

func (m *Message) Channel(cache *Cache) (Channel, bool)

Channel returns the channel the message was sent in which may or may not be cached.

func (*Message) CreateReaction

func (m *Message) CreateReaction(ctx context.Context, rest *REST, emoji string) error

CreateReaction adds a reaction to the specified message with a custom or unicode emoji. A custom emoji should be formatted as name:id.

func (*Message) CreatedAt

func (m *Message) CreatedAt() time.Time

func (*Message) Delete

func (m *Message) Delete(ctx context.Context, rest *REST) error

func (*Message) Edit

func (m *Message) Edit(ctx context.Context, rest *REST, opts EditMessageOpts) error

func (*Message) IsDeletable

func (m *Message) IsDeletable() bool

func (*Message) RemoveAllReactions

func (m *Message) RemoveAllReactions(ctx context.Context, rest *REST) error

func (*Message) RemoveEmojiReactions

func (m *Message) RemoveEmojiReactions(ctx context.Context, rest *REST, emoji string) error

func (*Message) RemoveOwnReaction

func (m *Message) RemoveOwnReaction(ctx context.Context, rest *REST, emoji string) error

func (*Message) RemoveReaction

func (m *Message) RemoveReaction(ctx context.Context, rest *REST, emoji string, userID ID) error

type MessageCall

type MessageCall struct {
	Participants []ID       `json:"participants"`
	EndedAt      *time.Time `json:"ended_timestamp"`
}

type MessageCreateEvent

type MessageCreateEvent struct {
	Shard   *Shard  `json:"-"`
	Member  *Member `json:"member"`
	GuildID *ID     `json:"guild_id"`
	Message
}

MessageCreateEvent represents a received message.

func (*MessageCreateEvent) Channel

func (e *MessageCreateEvent) Channel(cache *Cache) (Channel, bool)

Channel returns the channel the message was sent in if it is cached.

func (*MessageCreateEvent) Guild

func (e *MessageCreateEvent) Guild(cache *Cache) (Guild, bool)

Guild returns the guild the message was sent in if it is cached.

type MessageDeleteBulkEvent

type MessageDeleteBulkEvent struct {
	ChannelID ID
	GuildID   *ID
	Messages  []BulkDeletedMessage
}

type MessageDeleteEvent

type MessageDeleteEvent struct {
	Shard     *Shard   `json:"-"`
	GuildID   *ID      `json:"guild_id"`
	ChannelID ID       `json:"channel_id"`
	MessageID ID       `json:"id"`
	Content   *string  `json:"content"`
	AuthorID  *ID      `json:"author_id"`
	Member    *Member  `json:"member"`
	Cached    *Message `json:"-"`
}

func (*MessageDeleteEvent) Channel

func (e *MessageDeleteEvent) Channel(cache *Cache) (Channel, bool)

Channel returns the channel the message was sent in if it is cached.

func (*MessageDeleteEvent) Guild

func (e *MessageDeleteEvent) Guild(cache *Cache) (Guild, bool)

Guild returns the guild the message was sent in if it is cached.

type MessageFlags

type MessageFlags uint
const (
	MessageFlagSupressEmbeds       MessageFlags = 1 << 2
	MessageFlagSupressNotification MessageFlags = 1 << 12
	MessageFlagCompactAttachments  MessageFlags = 1 << 17
)

type MessageReaction

type MessageReaction struct {
	Emoji ReactionEmoji `json:"emoji"`
	Count int           `json:"count"`
	Me    bool          `json:"me"`
}

type MessageReference

type MessageReference struct {
	ChannelID ID                   `json:"channel_id"`
	MessageID ID                   `json:"message_id"`
	GuildID   *ID                  `json:"guild_id"`
	Type      MessageReferenceType `json:"type"`
}

type MessageReferenceOpts

type MessageReferenceOpts struct {
	MessageID ID                   `json:"message_id"`
	ChannelID ID                   `json:"channel_id,omitzero"`
	GuildID   ID                   `json:"guild_id,omitzero"`
	Type      MessageReferenceType `json:"type"`
}

MessageReferenceOpts specifies a message reference (reply or forward) when sending or editing a message.

type MessageReferenceType

type MessageReferenceType uint
const (
	MessageReferenceTypeDefault MessageReferenceType = 0
	MessageReferenceTypeForward MessageReferenceType = 1
)

func (MessageReferenceType) String

func (i MessageReferenceType) String() string

type MessageSticker

type MessageSticker struct {
	ID       ID     `json:"id"`
	Name     string `json:"name"`
	Animated bool   `json:"animated"`
}

type MessageType

type MessageType uint
const (
	MessageTypeDefault              MessageType = 0
	MessageTypeRecipientAdd         MessageType = 1
	MessageTypeRecipientRemove      MessageType = 2
	MessageTypeCall                 MessageType = 3
	MessageTypeChannelNameChange    MessageType = 4
	MessageTypeChannelIconChange    MessageType = 5
	MessageTypeChannelPinnedMessage MessageType = 6
	MessageTypeUserJoin             MessageType = 7
	MessageTypeReply                MessageType = 19
)

func (MessageType) IsDeletable

func (mt MessageType) IsDeletable() bool

func (MessageType) String

func (i MessageType) String() string

type MessageUpdateEvent

type MessageUpdateEvent struct {
	Shard   *Shard  `json:"-"`
	Member  *Member `json:"member"`
	GuildID *ID     `json:"guild_id"`
	Message
}

func (*MessageUpdateEvent) Channel

func (e *MessageUpdateEvent) Channel(cache *Cache) (Channel, bool)

Channel returns the channel the message was sent in if it was cached.

func (*MessageUpdateEvent) Guild

func (e *MessageUpdateEvent) Guild(cache *Cache) (Guild, bool)

Guild returns the guild the message was sent in if it was cached.

type Perms

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

Perms respresents a set of member permissions. The zero value can be used to represent no permissions. The underlying uint64 cannot be accessed directly since more than 64 permissions may be available at some point.

func NewPerms

func NewPerms(p ...Perms) Perms

NewPerms creates permissions as a combination of all provided permissions.

func NewPermsBit

func NewPermsBit(bit uint) Perms

func PermsFromUint64

func PermsFromUint64(i uint64) Perms

func (*Perms) Clear

func (p *Perms) Clear(p2 ...Perms)

Clear removes all of the permissions on p2 from p. If p2 is empty, p is fully cleared instead.

func (Perms) Difference

func (p Perms) Difference(p2 Perms) Perms

Difference returns the set of permissions which are in p but not in p2.

func (Perms) Equal

func (p Perms) Equal(p2 Perms) bool

Equal returns true if p and p2 represent the same set of permissions.

func (Perms) Has

func (p Perms) Has(p2 ...Perms) bool

Has returns true if p contains all the perms in p2.

func (Perms) Intersection

func (p Perms) Intersection(p2 Perms) Perms

Intersection returns the common permissions between p and p2.

func (Perms) MarshalJSON

func (p Perms) MarshalJSON() ([]byte, error)

func (*Perms) Set

func (p *Perms) Set(p2 ...Perms)

Set adds all of the permissions on p2 to p.

func (Perms) String

func (p Perms) String() string

func (Perms) ToUint64

func (p Perms) ToUint64() uint64

ToUint64 returns the lower 64 bits of the permissions.

func (Perms) Union

func (p Perms) Union(p2 Perms) Perms

Union returns a combination of permissions between p and p2.

func (*Perms) UnmarshalJSON

func (p *Perms) UnmarshalJSON(data []byte) error

type PresenceOpts

type PresenceOpts struct {
	// Status specifies the status icon to set.
	// By default, it will be [UserStatusOnline].
	Status       UserStatus       `json:"status,omitempty"`
	AFK          bool             `json:"afk"`
	Mobile       bool             `json:"mobile"`
	CustomStatus CustomStatusOpts `json:"custom_status,omitzero"`
}

type REST

type REST struct {
	// Auth specifies the Authorization header to use. For most endpoints, it is required.
	Auth string
	// Cache specifies the caching target. If nil is specified, nothing is cached.
	Cache *Cache
	// UserAgent overrides the used user agent. By default it is generated from the library version.
	UserAgent string
	// Client allows configuring the underlying HTTP client.
	Client http.Client
	// BaseURL specifies the base URL for requests.
	// If not specified, [DefaultAPIURL] is used.
	// This should never contain the API version - it is specified per-request in order to allow progressive adoption of new API features, as well as to avoid silently breaking old code.
	BaseURL *url.URL

	// DefaultAllowedMentions specifies the default allowed mentions if nothing is specified when creating or editing a message.
	DefaultAllowedMentions *AllowedMentions
	// contains filtered or unexported fields
}

REST is used to make REST requests to the Fluxer API, respecting rate limits and updating cache.

func (*REST) AddMemberRole

func (r *REST) AddMemberRole(ctx context.Context, guildID ID, userID ID, roleID ID) error

func (*REST) AddMemberRoleWithReason

func (r *REST) AddMemberRoleWithReason(ctx context.Context, guildID ID, userID ID, roleID ID, reason string) error

func (*REST) BulkDeleteMessages

func (r *REST) BulkDeleteMessages(ctx context.Context, channelID ID, messageIDs []ID) error

func (*REST) CreateDMChannel

func (r *REST) CreateDMChannel(ctx context.Context, userID ID) (Channel, error)

func (*REST) CreateGuildBan

func (r *REST) CreateGuildBan(ctx context.Context, guildID ID, userID ID, opts CreateGuildBanOpts) error

func (*REST) CreateGuildChannel

func (r *REST) CreateGuildChannel(ctx context.Context, guildID ID, opts CreateGuildChannelOpts) (Channel, error)

func (*REST) CreateGuildEmoji

func (r *REST) CreateGuildEmoji(ctx context.Context, guildID ID, opts CreateGuildEmojiOpts) (GuildEmoji, error)

func (*REST) CreateGuildSticker

func (r *REST) CreateGuildSticker(ctx context.Context, guildID ID, opts CreateGuildStickerOpts) (GuildSticker, error)

func (*REST) CreateMessage

func (r *REST) CreateMessage(ctx context.Context, channelID ID, opts CreateMessageOpts) (Message, error)

func (*REST) CreateReaction

func (r *REST) CreateReaction(ctx context.Context, channelID ID, messageID ID, emoji string) error

CreateReaction adds a reaction to the specified message with a custom or unicode emoji. A custom emoji should be formatted as name:id.

func (*REST) CreateRole

func (r *REST) CreateRole(ctx context.Context, guildID ID, opts CreateRoleOpts) (Role, error)

func (*REST) CreateWebhook

func (r *REST) CreateWebhook(ctx context.Context, channelID ID, opts CreateWebhookOpts) (Webhook, error)

func (*REST) DeleteChannel

func (r *REST) DeleteChannel(ctx context.Context, channelID ID) error

func (*REST) DeleteGuildEmoji

func (r *REST) DeleteGuildEmoji(ctx context.Context, guildID ID, emojiID ID) error

func (*REST) DeleteGuildSticker

func (r *REST) DeleteGuildSticker(ctx context.Context, guildID ID, emojiID ID) error

func (*REST) DeleteMessage

func (r *REST) DeleteMessage(ctx context.Context, channelID ID, msgID ID) error

func (*REST) DeleteRole

func (r *REST) DeleteRole(ctx context.Context, guildID ID, roleID ID) error

func (*REST) DeleteWebhook

func (r *REST) DeleteWebhook(ctx context.Context, webhookID ID) error

func (*REST) DeleteWebhookMessage

func (r *REST) DeleteWebhookMessage(ctx context.Context, auth WebhookAuth, messageID ID) error

DeleteWebhookMessage deletes a message sent by a webhook using its token.

func (*REST) DeleteWebhookWithAuth

func (r *REST) DeleteWebhookWithAuth(ctx context.Context, auth WebhookAuth) error

func (*REST) EditMessage

func (r *REST) EditMessage(ctx context.Context, channelID ID, msgID ID, opts EditMessageOpts) (Message, error)

func (*REST) EditWebhookMessage

func (r *REST) EditWebhookMessage(ctx context.Context, auth WebhookAuth, messageID ID, opts EditWebhookMessageOpts) (Message, error)

EditWebhookMessage edits a message sent by a webhook using its token.

func (*REST) ExecWebhook

func (r *REST) ExecWebhook(ctx context.Context, auth WebhookAuth, opts ExecWebhookOpts) error

ExecWebhook sends a message through a webhook without waiting. If you want a message repsonse use [ExecWebhookWait]

func (*REST) ExecWebhookWait

func (r *REST) ExecWebhookWait(ctx context.Context, auth WebhookAuth, opts ExecWebhookOpts) (Message, error)

ExecWebhookWait sends a message through a webhook and returns the sent message.

func (*REST) GetChannel

func (r *REST) GetChannel(ctx context.Context, channelID ID) (Channel, error)

func (*REST) GetChannelWebhooks

func (r *REST) GetChannelWebhooks(ctx context.Context, channelID ID) ([]Webhook, error)

GetGuildWebhooks gets a list of channel webhooks, so long as the authenticated user has PermManageWebhooks.

func (*REST) GetCurrentMember

func (r *REST) GetCurrentMember(ctx context.Context, guildID ID) (Member, error)

func (*REST) GetCurrentUser

func (r *REST) GetCurrentUser(ctx context.Context) (UserPrivate, error)

func (*REST) GetGuild

func (r *REST) GetGuild(ctx context.Context, guildID ID) (Guild, error)

func (*REST) GetGuildBans

func (r *REST) GetGuildBans(ctx context.Context, guildID ID) ([]GuildBan, error)

func (*REST) GetGuildEmoji

func (r *REST) GetGuildEmoji(ctx context.Context, guildID ID, emojiID ID) (GuildEmoji, error)

func (*REST) GetGuildSticker

func (r *REST) GetGuildSticker(ctx context.Context, guildID ID, stickerID ID) (GuildSticker, error)

func (*REST) GetGuildWebhooks

func (r *REST) GetGuildWebhooks(ctx context.Context, channelID ID) ([]Webhook, error)

GetGuildWebhooks gets a list of guild webhooks, so long as the authenticated user has PermManageWebhooks.

func (*REST) GetInstanceInfo

func (r *REST) GetInstanceInfo(ctx context.Context) (InstanceInfo, error)

func (*REST) GetMember

func (r *REST) GetMember(ctx context.Context, guildID ID, userID ID) (Member, error)

func (*REST) GetMembers

func (r *REST) GetMembers(ctx context.Context, guildID ID, opts GetMembersOpts) ([]Member, error)

func (*REST) GetMessage

func (r *REST) GetMessage(ctx context.Context, channelID ID, msgID ID) (Message, error)

func (*REST) GetMessages

func (r *REST) GetMessages(ctx context.Context, channelID ID, opts GetMessagesOpts) ([]Message, error)

func (*REST) GetRole

func (r *REST) GetRole(ctx context.Context, guildID ID, roleID ID) (Role, error)

func (*REST) GetUser

func (r *REST) GetUser(ctx context.Context, userID ID) (User, error)

func (*REST) GetWebhook

func (r *REST) GetWebhook(ctx context.Context, webhookID ID) (Webhook, error)

GetWebhook gets the webhook by the provided ID, so long as the authenticated user has PermManageWebhooks.

func (*REST) GetWebhookWithAuth

func (r *REST) GetWebhookWithAuth(ctx context.Context, auth WebhookAuth) (Webhook, error)

GetWebhookWithAuth gets the webhook by the provided ID using its token. Webhook.User is not returned in the response.

func (*REST) LeaveGuild

func (r *REST) LeaveGuild(ctx context.Context, guildID ID) error

func (*REST) RemoveAllReactions

func (r *REST) RemoveAllReactions(ctx context.Context, channelID ID, messageID ID) error

func (*REST) RemoveEmojiReactions

func (r *REST) RemoveEmojiReactions(ctx context.Context, channelID ID, messageID ID, emoji string) error

func (*REST) RemoveGuildBan

func (r *REST) RemoveGuildBan(ctx context.Context, guildID ID, userID ID) error

func (*REST) RemoveGuildBanWithReason

func (r *REST) RemoveGuildBanWithReason(ctx context.Context, guildID ID, userID ID, reason string) error

func (*REST) RemoveMember

func (r *REST) RemoveMember(ctx context.Context, guildID ID, userID ID) error

func (*REST) RemoveMemberRole

func (r *REST) RemoveMemberRole(ctx context.Context, guildID ID, userID ID, roleID ID) error

func (*REST) RemoveMemberRoleWithReason

func (r *REST) RemoveMemberRoleWithReason(ctx context.Context, guildID ID, userID ID, roleID ID, reason string) error

func (*REST) RemoveMemberWithReason

func (r *REST) RemoveMemberWithReason(ctx context.Context, guildID ID, userID ID, reason string) error

func (*REST) RemoveOwnReaction

func (r *REST) RemoveOwnReaction(ctx context.Context, channelID ID, messageID ID, emoji string) error

func (*REST) RemoveReaction

func (r *REST) RemoveReaction(ctx context.Context, channelID ID, messageID ID, emoji string, userID ID) error

func (*REST) Request

func (r *REST) Request(ctx context.Context, req RESTRequest) (*http.Response, error)

Request sends a Request to a Fluxer endpoint. If the returned error is nil, the response body should be closed.

func (*REST) RequestJSON

func (r *REST) RequestJSON(ctx context.Context, req RESTRequest, result any) error

func (*REST) RequestNoContent

func (r *REST) RequestNoContent(ctx context.Context, req RESTRequest) error

func (*REST) StartTyping

func (r *REST) StartTyping(ctx context.Context, channelID ID) error

func (*REST) UpdateChannel

func (r *REST) UpdateChannel(ctx context.Context, channelID ID, opts UpdateChannelOpts) (Channel, error)

func (*REST) UpdateCurrentMember

func (r *REST) UpdateCurrentMember(ctx context.Context, guildID ID, opts UpdateCurrentMemberOpts) (Member, error)

func (*REST) UpdateGuildEmoji

func (r *REST) UpdateGuildEmoji(ctx context.Context, guildID ID, emojiID ID, opts UpdateGuildEmojiOpts) (GuildEmoji, error)

func (*REST) UpdateGuildSticker

func (r *REST) UpdateGuildSticker(ctx context.Context, guildID ID, stickerID ID, opts UpdateGuildStickerOpts) (GuildSticker, error)

func (*REST) UpdateMember

func (r *REST) UpdateMember(ctx context.Context, guildID ID, userID ID, opts UpdateMemberOpts) (Member, error)

func (*REST) UpdateRole

func (r *REST) UpdateRole(ctx context.Context, guildID ID, roleID ID, opts UpdateRoleOpts) (Role, error)

func (*REST) UpdateWebhook

func (r *REST) UpdateWebhook(ctx context.Context, webhookID ID, opts UpdateWebhookOpts) (Webhook, error)

func (*REST) UpdateWebhookWithAuth

func (r *REST) UpdateWebhookWithAuth(ctx context.Context, auth WebhookAuth, opts UpdateWebhookOpts) (Webhook, error)

UpdateWebhookWithAuth updates the properties of the specified webhook using its token. Webhook.User is not returned in the response.

type RESTAPIError

type RESTAPIError struct {
	Method  string
	Path    string
	Status  int
	Code    RESTErrorCode
	Message string
}

RESTAPIError represents an API error from Fluxer in the expected format.

func (*RESTAPIError) Error

func (r *RESTAPIError) Error() string

type RESTErrorCode

type RESTErrorCode string
const (
	RESTErrAccessDenied                                 RESTErrorCode = "ACCESS_DENIED"
	RESTErrAccountDisabled                              RESTErrorCode = "ACCOUNT_DISABLED"
	RESTErrBadGateway                                   RESTErrorCode = "BAD_GATEWAY"
	RESTErrBadRequest                                   RESTErrorCode = "BAD_REQUEST"
	RESTErrBlueskyOAuthAuthorizationFailed              RESTErrorCode = "BLUESKY_OAUTH_AUTHORIZATION_FAILED"
	RESTErrBlueskyOAuthCallbackFailed                   RESTErrorCode = "BLUESKY_OAUTH_CALLBACK_FAILED"
	RESTErrBlueskyOAuthNotEnabled                       RESTErrorCode = "BLUESKY_OAUTH_NOT_ENABLED"
	RESTErrBlueskyOAuthSessionExpired                   RESTErrorCode = "BLUESKY_OAUTH_SESSION_EXPIRED"
	RESTErrBlueskyOAuthStateInvalid                     RESTErrorCode = "BLUESKY_OAUTH_STATE_INVALID"
	RESTErrAccountScheduledForDeletion                  RESTErrorCode = "ACCOUNT_SCHEDULED_FOR_DELETION"
	RESTErrAccountSuspendedPermanently                  RESTErrorCode = "ACCOUNT_SUSPENDED_PERMANENTLY"
	RESTErrAccountSuspendedTemporarily                  RESTErrorCode = "ACCOUNT_SUSPENDED_TEMPORARILY"
	RESTErrAccountSuspiciousActivity                    RESTErrorCode = "ACCOUNT_SUSPICIOUS_ACTIVITY"
	RESTErrAccountTooNewForGuild                        RESTErrorCode = "ACCOUNT_TOO_NEW_FOR_GUILD"
	RESTErrACLsMustBeNonEmpty                           RESTErrorCode = "ACLS_MUST_BE_NON_EMPTY"
	RESTErrAdminAPIKeyNotFound                          RESTErrorCode = "ADMIN_API_KEY_NOT_FOUND"
	RESTErrApplicationNotFound                          RESTErrorCode = "APPLICATION_NOT_FOUND"
	RESTErrApplicationNotOwned                          RESTErrorCode = "APPLICATION_NOT_OWNED"
	RESTErrAlreadyFriends                               RESTErrorCode = "ALREADY_FRIENDS"
	RESTErrAuditLogIndexing                             RESTErrorCode = "AUDIT_LOG_INDEXING"
	RESTErrBotsCannotSendFriendRequests                 RESTErrorCode = "BOTS_CANNOT_SEND_FRIEND_REQUESTS"
	RESTErrBotAlreadyInGuild                            RESTErrorCode = "BOT_ALREADY_IN_GUILD"
	RESTErrBotApplicationNotFound                       RESTErrorCode = "BOT_APPLICATION_NOT_FOUND"
	RESTErrBotIsPrivate                                 RESTErrorCode = "BOT_IS_PRIVATE"
	RESTErrBotUserAuthEndpointAccessDenied              RESTErrorCode = "BOT_USER_AUTH_ENDPOINT_ACCESS_DENIED"
	RESTErrBotUserAuthSessionCreationDenied             RESTErrorCode = "BOT_USER_AUTH_SESSION_CREATION_DENIED"
	RESTErrBotUserGenerationFailed                      RESTErrorCode = "BOT_USER_GENERATION_FAILED"
	RESTErrBotUserNotFound                              RESTErrorCode = "BOT_USER_NOT_FOUND"
	RESTErrCallAlreadyExists                            RESTErrorCode = "CALL_ALREADY_EXISTS"
	RESTErrCannotEditOtherUserMessage                   RESTErrorCode = "CANNOT_EDIT_OTHER_USER_MESSAGE"
	RESTErrCannotExecuteOnDM                            RESTErrorCode = "CANNOT_EXECUTE_ON_DM"
	RESTErrCannotModifySystemWebhook                    RESTErrorCode = "CANNOT_MODIFY_SYSTEM_WEBHOOK"
	RESTErrCannotModifyVoiceState                       RESTErrorCode = "CANNOT_MODIFY_VOICE_STATE"
	RESTErrCannotRedeemPlutoniumWithVisionary           RESTErrorCode = "CANNOT_REDEEM_PLUTONIUM_WITH_VISIONARY"
	RESTErrCannotReportOwnGuild                         RESTErrorCode = "CANNOT_REPORT_OWN_GUILD"
	RESTErrCannotReportOwnMessage                       RESTErrorCode = "CANNOT_REPORT_OWN_MESSAGE"
	RESTErrCannotReportYourself                         RESTErrorCode = "CANNOT_REPORT_YOURSELF"
	RESTErrCannotSendEmptyMessage                       RESTErrorCode = "CANNOT_SEND_EMPTY_MESSAGE"
	RESTErrCannotSendFriendRequestToBlockedUser         RESTErrorCode = "CANNOT_SEND_FRIEND_REQUEST_TO_BLOCKED_USER"
	RESTErrCannotSendFriendRequestToSelf                RESTErrorCode = "CANNOT_SEND_FRIEND_REQUEST_TO_SELF"
	RESTErrCannotSendMessagesInNonTextChannel           RESTErrorCode = "CANNOT_SEND_MESSAGES_IN_NON_TEXT_CHANNEL"
	RESTErrCannotSendMessagesToUser                     RESTErrorCode = "CANNOT_SEND_MESSAGES_TO_USER"
	RESTErrCannotTransferOwnershipToBot                 RESTErrorCode = "CANNOT_TRANSFER_OWNERSHIP_TO_BOT"
	RESTErrCannotShrinkReservedSlots                    RESTErrorCode = "CANNOT_SHRINK_RESERVED_SLOTS"
	RESTErrCaptchaRequired                              RESTErrorCode = "CAPTCHA_REQUIRED"
	RESTErrChannelIndexing                              RESTErrorCode = "CHANNEL_INDEXING"
	RESTErrCommunicationDisabled                        RESTErrorCode = "COMMUNICATION_DISABLED"
	RESTErrConnectionAlreadyExists                      RESTErrorCode = "CONNECTION_ALREADY_EXISTS"
	RESTErrConnectionInitiationTokenInvalid             RESTErrorCode = "CONNECTION_INITIATION_TOKEN_INVALID"
	RESTErrConnectionInvalidIdentifier                  RESTErrorCode = "CONNECTION_INVALID_IDENTIFIER"
	RESTErrConnectionInvalidType                        RESTErrorCode = "CONNECTION_INVALID_TYPE"
	RESTErrConnectionLimitReached                       RESTErrorCode = "CONNECTION_LIMIT_REACHED"
	RESTErrConnectionNotFound                           RESTErrorCode = "CONNECTION_NOT_FOUND"
	RESTErrConnectionVerificationFailed                 RESTErrorCode = "CONNECTION_VERIFICATION_FAILED"
	RESTErrConflict                                     RESTErrorCode = "CONFLICT"
	RESTErrContentBlocked                               RESTErrorCode = "CONTENT_BLOCKED"
	RESTErrCreationFailed                               RESTErrorCode = "CREATION_FAILED"
	RESTErrCSAMScanFailed                               RESTErrorCode = "CSAM_SCAN_FAILED"
	RESTErrCSAMScanParseError                           RESTErrorCode = "CSAM_SCAN_PARSE_ERROR"
	RESTErrCSAMScanSubscriptionError                    RESTErrorCode = "CSAM_SCAN_SUBSCRIPTION_ERROR"
	RESTErrCSAMScanTimeout                              RESTErrorCode = "CSAM_SCAN_TIMEOUT"
	RESTErrDecryptionFailed                             RESTErrorCode = "DECRYPTION_FAILED"
	RESTErrDeletionFailed                               RESTErrorCode = "DELETION_FAILED"
	RESTErrDiscoveryAlreadyApplied                      RESTErrorCode = "DISCOVERY_ALREADY_APPLIED"
	RESTErrDiscoveryApplicationAlreadyReviewed          RESTErrorCode = "DISCOVERY_APPLICATION_ALREADY_REVIEWED"
	RESTErrDiscoveryApplicationNotFound                 RESTErrorCode = "DISCOVERY_APPLICATION_NOT_FOUND"
	RESTErrDiscoveryDescriptionRequired                 RESTErrorCode = "DISCOVERY_DESCRIPTION_REQUIRED"
	RESTErrDiscoveryDisabled                            RESTErrorCode = "DISCOVERY_DISABLED"
	RESTErrDiscoveryInsufficientMembers                 RESTErrorCode = "DISCOVERY_INSUFFICIENT_MEMBERS"
	RESTErrDiscoveryInvalidCategory                     RESTErrorCode = "DISCOVERY_INVALID_CATEGORY"
	RESTErrDiscoveryNotDiscoverable                     RESTErrorCode = "DISCOVERY_NOT_DISCOVERABLE"
	RESTErrDiscriminatorRequired                        RESTErrorCode = "DISCRIMINATOR_REQUIRED"
	RESTErrEmailServiceNotTestable                      RESTErrorCode = "EMAIL_SERVICE_NOT_TESTABLE"
	RESTErrEmailVerificationRequired                    RESTErrorCode = "EMAIL_VERIFICATION_REQUIRED"
	RESTErrEmptyEncryptedBody                           RESTErrorCode = "EMPTY_ENCRYPTED_BODY"
	RESTErrEncryptionFailed                             RESTErrorCode = "ENCRYPTION_FAILED"
	RESTErrExplicitContentCannotBeSent                  RESTErrorCode = "EXPLICIT_CONTENT_CANNOT_BE_SENT"
	RESTErrFeatureNotAvailableSelfHosted                RESTErrorCode = "FEATURE_NOT_AVAILABLE_SELF_HOSTED"
	RESTErrFeatureTemporarilyDisabled                   RESTErrorCode = "FEATURE_TEMPORARILY_DISABLED"
	RESTErrFileSizeTooLarge                             RESTErrorCode = "FILE_SIZE_TOO_LARGE"
	RESTErrForbidden                                    RESTErrorCode = "FORBIDDEN"
	RESTErrFriendRequestBlocked                         RESTErrorCode = "FRIEND_REQUEST_BLOCKED"
	RESTErrGatewayTimeout                               RESTErrorCode = "GATEWAY_TIMEOUT"
	RESTErrGeneralError                                 RESTErrorCode = "GENERAL_ERROR"
	RESTErrGone                                         RESTErrorCode = "GONE"
	RESTErrGiftCodeAlreadyRedeemed                      RESTErrorCode = "GIFT_CODE_ALREADY_REDEEMED"
	RESTErrGuildPhoneVerificationRequired               RESTErrorCode = "GUILD_PHONE_VERIFICATION_REQUIRED"
	RESTErrGuildVerificationRequired                    RESTErrorCode = "GUILD_VERIFICATION_REQUIRED"
	RESTErrHandoffCodeExpired                           RESTErrorCode = "HANDOFF_CODE_EXPIRED"
	RESTErrHarvestExpired                               RESTErrorCode = "HARVEST_EXPIRED"
	RESTErrHarvestFailed                                RESTErrorCode = "HARVEST_FAILED"
	RESTErrHarvestNotReady                              RESTErrorCode = "HARVEST_NOT_READY"
	RESTErrHarvestOnCooldown                            RESTErrorCode = "HARVEST_ON_COOLDOWN"
	RESTErrHttpGetAuthorizeNotSupported                 RESTErrorCode = "HTTP_GET_AUTHORIZE_NOT_SUPPORTED"
	RESTErrInstanceVersionMismatch                      RESTErrorCode = "INSTANCE_VERSION_MISMATCH"
	RESTErrInternalServerError                          RESTErrorCode = "INTERNAL_SERVER_ERROR"
	RESTErrInvalidACLsFormat                            RESTErrorCode = "INVALID_ACLS_FORMAT"
	RESTErrInvalidAPIOrigin                             RESTErrorCode = "INVALID_API_ORIGIN"
	RESTErrInvalidAuthToken                             RESTErrorCode = "INVALID_AUTH_TOKEN"
	RESTErrInvalidBotFlag                               RESTErrorCode = "INVALID_BOT_FLAG"
	RESTErrInvalidCaptcha                               RESTErrorCode = "INVALID_CAPTCHA"
	RESTErrInvalidChannelTypeForCall                    RESTErrorCode = "INVALID_CHANNEL_TYPE_FOR_CALL"
	RESTErrInvalidChannelType                           RESTErrorCode = "INVALID_CHANNEL_TYPE"
	RESTErrInvalidClient                                RESTErrorCode = "INVALID_CLIENT"
	RESTErrInvalidClientSecret                          RESTErrorCode = "INVALID_CLIENT_SECRET"
	RESTErrInvalidDSAReportTarget                       RESTErrorCode = "INVALID_DSA_REPORT_TARGET"
	RESTErrInvalidDSATicket                             RESTErrorCode = "INVALID_DSA_TICKET"
	RESTErrInvalidDSAVerificationCode                   RESTErrorCode = "INVALID_DSA_VERIFICATION_CODE"
	RESTErrInvalidDecryptedJson                         RESTErrorCode = "INVALID_DECRYPTED_JSON"
	RESTErrInvalidEphemeralKey                          RESTErrorCode = "INVALID_EPHEMERAL_KEY"
	RESTErrInvalidFlagsFormat                           RESTErrorCode = "INVALID_FLAGS_FORMAT"
	RESTErrInvalidIV                                    RESTErrorCode = "INVALID_IV"
	RESTErrInvalidFormBody                              RESTErrorCode = "INVALID_FORM_BODY"
	RESTErrInvalidGrant                                 RESTErrorCode = "INVALID_GRANT"
	RESTErrInvalidHandoffCode                           RESTErrorCode = "INVALID_HANDOFF_CODE"
	RESTErrInvalidPackType                              RESTErrorCode = "INVALID_PACK_TYPE"
	RESTErrInvalidPermissionsInteger                    RESTErrorCode = "INVALID_PERMISSIONS_INTEGER"
	RESTErrInvalidPermissionsNegative                   RESTErrorCode = "INVALID_PERMISSIONS_NEGATIVE"
	RESTErrInvalidPhoneNumber                           RESTErrorCode = "INVALID_PHONE_NUMBER"
	RESTErrInvalidPhoneVerificationCode                 RESTErrorCode = "INVALID_PHONE_VERIFICATION_CODE"
	RESTErrInvalidRedirectURI                           RESTErrorCode = "INVALID_REDIRECT_URI"
	RESTErrInvalidRequest                               RESTErrorCode = "INVALID_REQUEST"
	RESTErrInvalidResponseTypeForNonBot                 RESTErrorCode = "INVALID_RESPONSE_TYPE_FOR_NON_BOT"
	RESTErrInvalidScope                                 RESTErrorCode = "INVALID_SCOPE"
	RESTErrInvalidStreamKeyFormat                       RESTErrorCode = "INVALID_STREAM_KEY_FORMAT"
	RESTErrInvalidStreamThumbnailPayload                RESTErrorCode = "INVALID_STREAM_THUMBNAIL_PAYLOAD"
	RESTErrInvalidSudoToken                             RESTErrorCode = "INVALID_SUDO_TOKEN"
	RESTErrInvalidSuspiciousFlagsFormat                 RESTErrorCode = "INVALID_SUSPICIOUS_FLAGS_FORMAT"
	RESTErrInvalidSystemFlag                            RESTErrorCode = "INVALID_SYSTEM_FLAG"
	RESTErrInvalidTimestamp                             RESTErrorCode = "INVALID_TIMESTAMP"
	RESTErrInvalidToken                                 RESTErrorCode = "INVALID_TOKEN"
	RESTErrInvalidWebAuthnAuthenticationCounter         RESTErrorCode = "INVALID_WEBAUTHN_AUTHENTICATION_COUNTER"
	RESTErrInvalidWebAuthnCredentialCounter             RESTErrorCode = "INVALID_WEBAUTHN_CREDENTIAL_COUNTER"
	RESTErrInvalidWebAuthnCredential                    RESTErrorCode = "INVALID_WEBAUTHN_CREDENTIAL"
	RESTErrInvalidWebAuthnPublicKeyFormat               RESTErrorCode = "INVALID_WEBAUTHN_PUBLIC_KEY_FORMAT"
	RESTErrInvitesDisabled                              RESTErrorCode = "INVITES_DISABLED"
	RESTErrIPAuthorizationRequired                      RESTErrorCode = "IP_AUTHORIZATION_REQUIRED"
	RESTErrIPAuthorizationResendCooldown                RESTErrorCode = "IP_AUTHORIZATION_RESEND_COOLDOWN"
	RESTErrIPAuthorizationResendLimitExceeded           RESTErrorCode = "IP_AUTHORIZATION_RESEND_LIMIT_EXCEEDED"
	RESTErrIPBanned                                     RESTErrorCode = "IP_BANNED"
	RESTErrMaxAnimatedEmojis                            RESTErrorCode = "MAX_ANIMATED_EMOJIS"
	RESTErrMaxBookmarks                                 RESTErrorCode = "MAX_BOOKMARKS"
	RESTErrMaxCategoryChannels                          RESTErrorCode = "MAX_CATEGORY_CHANNELS"
	RESTErrMaxEmojis                                    RESTErrorCode = "MAX_EMOJIS"
	RESTErrMaxFavoriteMemes                             RESTErrorCode = "MAX_FAVORITE_MEMES"
	RESTErrMaxFriends                                   RESTErrorCode = "MAX_FRIENDS"
	RESTErrMaxGroupDMRecipients                         RESTErrorCode = "MAX_GROUP_DM_RECIPIENTS"
	RESTErrMaxGroupDMs                                  RESTErrorCode = "MAX_GROUP_DMS"
	RESTErrMaxGuildChannels                             RESTErrorCode = "MAX_GUILD_CHANNELS"
	RESTErrMaxGuildMembers                              RESTErrorCode = "MAX_GUILD_MEMBERS"
	RESTErrMaxGuildRoles                                RESTErrorCode = "MAX_GUILD_ROLES"
	RESTErrMaxGuilds                                    RESTErrorCode = "MAX_GUILDS"
	RESTErrMaxInvites                                   RESTErrorCode = "MAX_INVITES"
	RESTErrMaxPackExpressions                           RESTErrorCode = "MAX_PACK_EXPRESSIONS"
	RESTErrMaxPacks                                     RESTErrorCode = "MAX_PACKS"
	RESTErrMaxPinsPerChannel                            RESTErrorCode = "MAX_PINS_PER_CHANNEL"
	RESTErrMessageTotalAttachmentSizeTooLarge           RESTErrorCode = "MESSAGE_TOTAL_ATTACHMENT_SIZE_TOO_LARGE"
	RESTErrMaxReactions                                 RESTErrorCode = "MAX_REACTIONS"
	RESTErrMaxStickers                                  RESTErrorCode = "MAX_STICKERS"
	RESTErrMaxWebhooksPerChannel                        RESTErrorCode = "MAX_WEBHOOKS_PER_CHANNEL"
	RESTErrMaxWebhooksPerGuild                          RESTErrorCode = "MAX_WEBHOOKS_PER_GUILD"
	RESTErrMaxWebhooks                                  RESTErrorCode = "MAX_WEBHOOKS"
	RESTErrNcmecAlreadySubmitted                        RESTErrorCode = "NCMEC_ALREADY_SUBMITTED"
	RESTErrNcmecSubmissionFailed                        RESTErrorCode = "NCMEC_SUBMISSION_FAILED"
	RESTErrMediaMetadataError                           RESTErrorCode = "MEDIA_METADATA_ERROR"
	RESTErrMethodNotAllowed                             RESTErrorCode = "METHOD_NOT_ALLOWED"
	RESTErrMissingAccess                                RESTErrorCode = "MISSING_ACCESS"
	RESTErrMissingACL                                   RESTErrorCode = "MISSING_ACL"
	RESTErrMissingAuthorization                         RESTErrorCode = "MISSING_AUTHORIZATION"
	RESTErrMissingClientSecret                          RESTErrorCode = "MISSING_CLIENT_SECRET"
	RESTErrMissingEphemeralKey                          RESTErrorCode = "MISSING_EPHEMERAL_KEY"
	RESTErrMissingIV                                    RESTErrorCode = "MISSING_IV"
	RESTErrMissingOAuthAdminScope                       RESTErrorCode = "MISSING_OAUTH_ADMIN_SCOPE"
	RESTErrMissingOAuthFields                           RESTErrorCode = "MISSING_OAUTH_FIELDS"
	RESTErrMissingOAuthScope                            RESTErrorCode = "MISSING_OAUTH_SCOPE"
	RESTErrMissingPermissions                           RESTErrorCode = "MISSING_PERMISSIONS"
	RESTErrMissingRedirectURI                           RESTErrorCode = "MISSING_REDIRECT_URI"
	RESTErrNoActiveCall                                 RESTErrorCode = "NO_ACTIVE_CALL"
	RESTErrNoActiveSubscription                         RESTErrorCode = "NO_ACTIVE_SUBSCRIPTION"
	RESTErrNotFound                                     RESTErrorCode = "NOT_FOUND"
	RESTErrNotImplemented                               RESTErrorCode = "NOT_IMPLEMENTED"
	RESTErrNoPasskeysRegistered                         RESTErrorCode = "NO_PASSKEYS_REGISTERED"
	RESTErrNoPendingDeletion                            RESTErrorCode = "NO_PENDING_DELETION"
	RESTErrNoUsersWithFluxertagExist                    RESTErrorCode = "NO_USERS_WITH_FLUXERTAG_EXIST"
	RESTErrNoVisionarySlotsAvailable                    RESTErrorCode = "NO_VISIONARY_SLOTS_AVAILABLE"
	RESTErrNotABotApplication                           RESTErrorCode = "NOT_A_BOT_APPLICATION"
	RESTErrNotFriendsWithUser                           RESTErrorCode = "NOT_FRIENDS_WITH_USER"
	RESTErrNotOwnerOfAdminAPIKey                        RESTErrorCode = "NOT_OWNER_OF_ADMIN_API_KEY"
	RESTErrNSFWContentAgeRestricted                     RESTErrorCode = "NSFW_CONTENT_AGE_RESTRICTED"
	RESTErrPackAccessDenied                             RESTErrorCode = "PACK_ACCESS_DENIED"
	RESTErrPasskeyAuthenticationFailed                  RESTErrorCode = "PASSKEY_AUTHENTICATION_FAILED"
	RESTErrPasskeysDisabled                             RESTErrorCode = "PASSKEYS_DISABLED"
	RESTErrPhoneAlreadyUsed                             RESTErrorCode = "PHONE_ALREADY_USED"
	RESTErrPhoneRateLimitExceeded                       RESTErrorCode = "PHONE_RATE_LIMIT_EXCEEDED"
	RESTErrPhoneRequiredForSMSMFA                       RESTErrorCode = "PHONE_REQUIRED_FOR_SMS_MFA"
	RESTErrPhoneVerificationRequired                    RESTErrorCode = "PHONE_VERIFICATION_REQUIRED"
	RESTErrPremiumPurchaseBlocked                       RESTErrorCode = "PREMIUM_PURCHASE_BLOCKED"
	RESTErrPreviewMustBeJPEG                            RESTErrorCode = "PREVIEW_MUST_BE_JPEG"
	RESTErrProcessingFailed                             RESTErrorCode = "PROCESSING_FAILED"
	RESTErrRateLimited                                  RESTErrorCode = "RATE_LIMITED"
	RESTErrRedirectURIRequiredForNonBot                 RESTErrorCode = "REDIRECT_URI_REQUIRED_FOR_NON_BOT"
	RESTErrReportAlreadyResolved                        RESTErrorCode = "REPORT_ALREADY_RESOLVED"
	RESTErrReportBanned                                 RESTErrorCode = "REPORT_BANNED"
	RESTErrResponseValidationError                      RESTErrorCode = "RESPONSE_VALIDATION_ERROR"
	RESTErrServiceUnavailable                           RESTErrorCode = "SERVICE_UNAVAILABLE"
	RESTErrSessionTokenMismatch                         RESTErrorCode = "SESSION_TOKEN_MISMATCH"
	RESTErrSlowmodeRateLimited                          RESTErrorCode = "SLOWMODE_RATE_LIMITED"
	RESTErrSMSMFANotEnabled                             RESTErrorCode = "SMS_MFA_NOT_ENABLED"
	RESTErrSMSMFARequiresTOTP                           RESTErrorCode = "SMS_MFA_REQUIRES_TOTP"
	RESTErrSMSVerificationUnavailable                   RESTErrorCode = "SMS_VERIFICATION_UNAVAILABLE"
	RESTErrSsoRequired                                  RESTErrorCode = "SSO_REQUIRED"
	RESTErrStreamKeyChannelMismatch                     RESTErrorCode = "STREAM_KEY_CHANNEL_MISMATCH"
	RESTErrStreamKeyScopeMismatch                       RESTErrorCode = "STREAM_KEY_SCOPE_MISMATCH"
	RESTErrStreamThumbnailPayloadEmpty                  RESTErrorCode = "STREAM_THUMBNAIL_PAYLOAD_EMPTY"
	RESTErrStripeError                                  RESTErrorCode = "STRIPE_ERROR"
	RESTErrStripeGiftRedemptionInProgress               RESTErrorCode = "STRIPE_GIFT_REDEMPTION_IN_PROGRESS"
	RESTErrStripeInvalidProduct                         RESTErrorCode = "STRIPE_INVALID_PRODUCT"
	RESTErrStripeInvalidProductConfiguration            RESTErrorCode = "STRIPE_INVALID_PRODUCT_CONFIGURATION"
	RESTErrStripeNoActiveSubscription                   RESTErrorCode = "STRIPE_NO_ACTIVE_SUBSCRIPTION"
	RESTErrStripeNoPurchaseHistory                      RESTErrorCode = "STRIPE_NO_PURCHASE_HISTORY"
	RESTErrStripeNoSubscription                         RESTErrorCode = "STRIPE_NO_SUBSCRIPTION"
	RESTErrStripePaymentNotAvailable                    RESTErrorCode = "STRIPE_PAYMENT_NOT_AVAILABLE"
	RESTErrStripeSubscriptionAlreadyCanceling           RESTErrorCode = "STRIPE_SUBSCRIPTION_ALREADY_CANCELING"
	RESTErrStripeSubscriptionNotCanceling               RESTErrorCode = "STRIPE_SUBSCRIPTION_NOT_CANCELING"
	RESTErrStripeSubscriptionPeriodEndMissing           RESTErrorCode = "STRIPE_SUBSCRIPTION_PERIOD_END_MISSING"
	RESTErrStripeWebhookNotAvailable                    RESTErrorCode = "STRIPE_WEBHOOK_NOT_AVAILABLE"
	RESTErrStripeWebhookSignatureInvalid                RESTErrorCode = "STRIPE_WEBHOOK_SIGNATURE_INVALID"
	RESTErrStripeWebhookSignatureMissing                RESTErrorCode = "STRIPE_WEBHOOK_SIGNATURE_MISSING"
	RESTErrDonationAmountInvalid                        RESTErrorCode = "DONATION_AMOUNT_INVALID"
	RESTErrDonationMagicLinkExpired                     RESTErrorCode = "DONATION_MAGIC_LINK_EXPIRED"
	RESTErrDonationMagicLinkInvalid                     RESTErrorCode = "DONATION_MAGIC_LINK_INVALID"
	RESTErrDonationMagicLinkUsed                        RESTErrorCode = "DONATION_MAGIC_LINK_USED"
	RESTErrDonorNotFound                                RESTErrorCode = "DONOR_NOT_FOUND"
	RESTErrSudoModeRequired                             RESTErrorCode = "SUDO_MODE_REQUIRED"
	RESTErrTagAlreadyTaken                              RESTErrorCode = "TAG_ALREADY_TAKEN"
	RESTErrTemporaryInviteRequiresPresence              RESTErrorCode = "TEMPORARY_INVITE_REQUIRES_PRESENCE"
	RESTErrTestHarnessDisabled                          RESTErrorCode = "TEST_HARNESS_DISABLED"
	RESTErrTestHarnessForbidden                         RESTErrorCode = "TEST_HARNESS_FORBIDDEN"
	RESTErrTwoFaNotEnabled                              RESTErrorCode = "TWO_FA_NOT_ENABLED"
	RESTErrTwoFactorRequired                            RESTErrorCode = "TWO_FACTOR_REQUIRED"
	RESTErrUnauthorized                                 RESTErrorCode = "UNAUTHORIZED"
	RESTErrUnclaimedAccountCannotAcceptFriendRequests   RESTErrorCode = "UNCLAIMED_ACCOUNT_CANNOT_ACCEPT_FRIEND_REQUESTS"
	RESTErrUnclaimedAccountCannotAddReactions           RESTErrorCode = "UNCLAIMED_ACCOUNT_CANNOT_ADD_REACTIONS"
	RESTErrUnclaimedAccountCannotCreateApplications     RESTErrorCode = "UNCLAIMED_ACCOUNT_CANNOT_CREATE_APPLICATIONS"
	RESTErrUnclaimedAccountCannotJoinGroupDMs           RESTErrorCode = "UNCLAIMED_ACCOUNT_CANNOT_JOIN_GROUP_DMS"
	RESTErrUnclaimedAccountCannotJoinOneOnOneVoiceCalls RESTErrorCode = "UNCLAIMED_ACCOUNT_CANNOT_JOIN_ONE_ON_ONE_VOICE_CALLS"
	RESTErrUnclaimedAccountCannotJoinVoiceChannels      RESTErrorCode = "UNCLAIMED_ACCOUNT_CANNOT_JOIN_VOICE_CHANNELS"
	RESTErrUnclaimedAccountCannotMakePurchases          RESTErrorCode = "UNCLAIMED_ACCOUNT_CANNOT_MAKE_PURCHASES"
	RESTErrUnclaimedAccountCannotSendDirectMessages     RESTErrorCode = "UNCLAIMED_ACCOUNT_CANNOT_SEND_DIRECT_MESSAGES"
	RESTErrUnclaimedAccountCannotSendFriendRequests     RESTErrorCode = "UNCLAIMED_ACCOUNT_CANNOT_SEND_FRIEND_REQUESTS"
	RESTErrUnclaimedAccountCannotSendMessages           RESTErrorCode = "UNCLAIMED_ACCOUNT_CANNOT_SEND_MESSAGES"
	RESTErrUnknownChannel                               RESTErrorCode = "UNKNOWN_CHANNEL"
	RESTErrUnknownEmoji                                 RESTErrorCode = "UNKNOWN_EMOJI"
	RESTErrUnknownFavoriteMeme                          RESTErrorCode = "UNKNOWN_FAVORITE_MEME"
	RESTErrUnknownGiftCode                              RESTErrorCode = "UNKNOWN_GIFT_CODE"
	RESTErrUnknownGuild                                 RESTErrorCode = "UNKNOWN_GUILD"
	RESTErrUnknownHarvest                               RESTErrorCode = "UNKNOWN_HARVEST"
	RESTErrUnknownInvite                                RESTErrorCode = "UNKNOWN_INVITE"
	RESTErrUnknownMember                                RESTErrorCode = "UNKNOWN_MEMBER"
	RESTErrUnknownMessage                               RESTErrorCode = "UNKNOWN_MESSAGE"
	RESTErrUnknownPack                                  RESTErrorCode = "UNKNOWN_PACK"
	RESTErrUnknownReport                                RESTErrorCode = "UNKNOWN_REPORT"
	RESTErrUnknownRole                                  RESTErrorCode = "UNKNOWN_ROLE"
	RESTErrUnknownSticker                               RESTErrorCode = "UNKNOWN_STICKER"
	RESTErrUnknownSuspiciousFlag                        RESTErrorCode = "UNKNOWN_SUSPICIOUS_FLAG"
	RESTErrUnknownUserFlag                              RESTErrorCode = "UNKNOWN_USER_FLAG"
	RESTErrUnknownUser                                  RESTErrorCode = "UNKNOWN_USER"
	RESTErrUnknownVoiceRegion                           RESTErrorCode = "UNKNOWN_VOICE_REGION"
	RESTErrUnknownVoiceServer                           RESTErrorCode = "UNKNOWN_VOICE_SERVER"
	RESTErrUnknownWebAuthnCredential                    RESTErrorCode = "UNKNOWN_WEBAUTHN_CREDENTIAL"
	RESTErrUnknownApplication                           RESTErrorCode = "UNKNOWN_APPLICATION"
	RESTErrUnknownWebhook                               RESTErrorCode = "UNKNOWN_WEBHOOK"
	RESTErrUnsupportedResponseType                      RESTErrorCode = "UNSUPPORTED_RESPONSE_TYPE"
	RESTErrUsernameNotAvailable                         RESTErrorCode = "USERNAME_NOT_AVAILABLE"
	RESTErrUpdateFailed                                 RESTErrorCode = "UPDATE_FAILED"
	RESTErrUserBannedFromGuild                          RESTErrorCode = "USER_BANNED_FROM_GUILD"
	RESTErrUserIPBannedFromGuild                        RESTErrorCode = "USER_IP_BANNED_FROM_GUILD"
	RESTErrUserNotInVoice                               RESTErrorCode = "USER_NOT_IN_VOICE"
	RESTErrUserOwnsGuilds                               RESTErrorCode = "USER_OWNS_GUILDS"
	RESTErrValidationError                              RESTErrorCode = "VALIDATION_ERROR"
	RESTErrVoiceChannelFull                             RESTErrorCode = "VOICE_CHANNEL_FULL"
	RESTErrWebAuthnCredentialLimitReached               RESTErrorCode = "WEBAUTHN_CREDENTIAL_LIMIT_REACHED"
)

type RESTFormField

type RESTFormField struct {
	FieldName string
	FileName  string
	// Content has the content copied from it into the form body.
	// It can be assumed to be closed after it is passed into Request.
	Content io.ReadCloser
}

type RESTHTTPError

type RESTHTTPError struct {
	Method   string
	Path     string
	Response http.Response
}

RESTHTTPError represents an error response in an unexpected format. Unlike a typical http.Response, the body does not need to be closed.

func (*RESTHTTPError) Error

func (r *RESTHTTPError) Error() string

type RESTRequest

type RESTRequest struct {
	Method string
	// Path is the request path appended to the base URL.
	// It should contain the API version as /v[num].
	Path string
	// RedactedPath is the path with any tokens redacted to be used in errors.
	RedactedPath string
	// Query is the query string passed after '?' in the URL, not including the '?'.
	Query string
	// Bucket is a string used to ratelimit requests together.
	// A ratelimit being hit for one request for a given bucket string will pause all other requests with the same string until the ratelimit resets.
	Bucket string

	// Payload specifies a JSON body.
	// If used in combination with Form, it will be added as payload_json.
	Payload any
	// Form specifies a set of form fields.
	// If it is not empty, the content type will be set to multipart/form-data and these fields will be sent as the payload.
	Form []RESTFormField

	// AuditLogReason specifies the X-Audit-Log-Reason header, which for some requests displays an additional message in the audit log entry.
	AuditLogReason string
}

type ReactionEmoji

type ReactionEmoji struct {
	ID       *ID    `json:"id"`
	Name     string `json:"name"`
	Animated bool   `json:"animated"`
}

func (*ReactionEmoji) CustomEmoji

func (e *ReactionEmoji) CustomEmoji() (ID, string, bool)

CustomEmoji returns the custom emoji ID and name if a custom (non-unicode) emoji was reacted with. Otherwise, the returned bool will be false.

func (*ReactionEmoji) IsCustom

func (e *ReactionEmoji) IsCustom() bool

func (*ReactionEmoji) IsUnicode

func (e *ReactionEmoji) IsUnicode() bool

func (*ReactionEmoji) Render

func (e *ReactionEmoji) Render() string

Render creates a string that can be used to display the emoji in chat.

func (*ReactionEmoji) UnicodeEmoji

func (e *ReactionEmoji) UnicodeEmoji() (string, bool)

UnicodeEmoji returns the emoji string if a unicode emoji was reacted with. Otherwise, the returned bool will be false.

type ReadyGuild

type ReadyGuild struct {
	Unavailable bool
	ID          ID
	// Guild is the full guild if unavailable is false.
	Guild *Guild
	// Cached is the guild removed from cache if unavailable is true and it was cached.
	Cached *Guild
}

ReadyGuild represents a guild in the READY payload which may or may not have its properties available.

type Role

type Role struct {
	ID            ID       `json:"id"`
	Name          string   `json:"name"`
	Color         ColorInt `json:"color"`
	Position      int      `json:"position"`
	HoistPosition *int     `json:"hoist_position"`
	Perms         Perms    `json:"permissions"`
	Hoist         bool     `json:"hoist"`
	Mentionable   bool     `json:"mentionable"`
	UnicodeEmoji  *string  `json:"unicode_emoji"`
}

func (*Role) Mention

func (r *Role) Mention() string

type RoleCreateEvent

type RoleCreateEvent struct {
	Shard   *Shard `json:"-"`
	GuildID ID     `json:"-"`
	Role
}

func (*RoleCreateEvent) Guild

func (e *RoleCreateEvent) Guild(cache *Cache) (Guild, bool)

Guild returns the guild where the role is being added if it is cached.

type RoleDeleteEvent

type RoleDeleteEvent struct {
	Shard   *Shard `json:"-"`
	GuildID ID     `json:"guild_id"`
	RoleID  ID     `json:"role_id"`
	// Cached is the role that was removed from the cache by this event, if any.
	Cached *Role `json:"-"`
}

func (*RoleDeleteEvent) Guild

func (e *RoleDeleteEvent) Guild(cache *Cache) (Guild, bool)

Guild returns the guild where the role is being deleted if it is cached.

type RoleUpdateBulkEvent

type RoleUpdateBulkEvent struct {
	Shard   *Shard `json:"-"`
	GuildID ID     `json:"guild_id"`
	Roles   []Role `json:"roles"`
}

func (*RoleUpdateBulkEvent) Guild

func (e *RoleUpdateBulkEvent) Guild(cache *Cache) (Guild, bool)

Guild returns the guild where the role is being updated if it is cached.

type RoleUpdateEvent

type RoleUpdateEvent struct {
	Shard   *Shard `json:"-"`
	GuildID ID     `json:"-"`
	Role
}

func (*RoleUpdateEvent) Guild

func (e *RoleUpdateEvent) Guild(cache *Cache) (Guild, bool)

Guild returns the guild where the role is being updated if it is cached.

type Shard

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

func (*Shard) Gateway

func (s *Shard) Gateway() *Gateway

func (*Shard) ID

func (s *Shard) ID() uint

func (*Shard) Latency

func (s *Shard) Latency() (time.Duration, bool)

Latency returns the latency if the shard is running and has determined it. Otherwise it returns 0, false.

func (*Shard) Presence

func (s *Shard) Presence() PresenceOpts

Presence returns the presence the shard currently has set.

func (*Shard) Reconnect

func (s *Shard) Reconnect() error

Reconnect signals for the shard to be reconnected. If the shard is not running, this will return ErrShardNotRunning. If the shard is already in the process of being disconnected/stopped, this will return ErrShardAlreadyDisconnecting.

func (*Shard) Running

func (s *Shard) Running() bool

Running is true if the shard has an actively running gorountine from calling Connect.

func (*Shard) SetPresence

func (s *Shard) SetPresence(opts PresenceOpts)

SetPresence sets the presence to be used by the shard. If the shard is currently connected it will be sent immediately, otherwise it will be sent the next time the shard connects. This means you can call this before Start!

func (*Shard) Start

func (s *Shard) Start() error

Start starts the shard on a new gorountine. After this, calls will return ErrShardAlreadyRunning until Disconnect(false) is called and the disconnection completes.

func (*Shard) Stop

func (s *Shard) Stop() error

Disconnect signals for the shard to be stopped. If the shard is not running, this will return ErrShardNotRunning. If the shard is already in the process of being stopped, this will return ErrShardAlreadyStopping.

type ShardConnectedEvent

type ShardConnectedEvent struct {
	Shard *Shard
}

type ShardDisconnectedEvent

type ShardDisconnectedEvent struct {
	Shard *Shard
	Err   error
	// Reconnecting is true if the shard will try to reconnect.
	Reconnecting bool
}

type ShardPacketEvent

type ShardPacketEvent struct {
	Shard *Shard `json:"-"`
	GatewayPacket
}

type ShardReadyEvent

type ShardReadyEvent struct {
	Shard     *Shard       `json:"-"`
	SessionID string       `json:"session_id"`
	User      UserPrivate  `json:"user"`
	Guilds    []ReadyGuild `json:"guilds"`
}

type ShardResumedEvent

type ShardResumedEvent struct {
	Shard *Shard
}

type ShardStartedEvent

type ShardStartedEvent struct {
	Shard *Shard
}

type ShardStoppedEvent

type ShardStoppedEvent struct {
	Shard *Shard
	Err   error
}

type Signal

type Signal[T any] struct {
	// contains filtered or unexported fields
}

A Signal can have listeners attached which are called when it is emitted. Adding a listener is done in a thread-safe manner.

func (*Signal[T]) Chan

func (s *Signal[T]) Chan() (<-chan T, ListenerRemoveFunc)

func (*Signal[T]) ClearListeners

func (s *Signal[T]) ClearListeners()

ClearListeners removes all listeners from the signal.

func (*Signal[T]) ListenerCount

func (s *Signal[T]) ListenerCount() int

func (*Signal[T]) On

func (s *Signal[T]) On(f func(T)) ListenerRemoveFunc

On adds a listener to the the signal which will be spawned on a new goroutine. You can also use OnSync to listen on whatever goroutine emitted it.

func (*Signal[T]) OnSync

func (s *Signal[T]) OnSync(f func(T)) ListenerRemoveFunc

OnSync adds a listener to the the signal which will be fired on the same gorountine as it is emitted.

func (*Signal[T]) Once

func (s *Signal[T]) Once(f func(T)) ListenerRemoveFunc

Once adds a one-time listener to the the signal which will be spawned on a new goroutine. You can also use OnceSync to listen on whatever goroutine emitted it.

func (*Signal[T]) OnceChan

func (s *Signal[T]) OnceChan() (chan T, ListenerRemoveFunc)

func (*Signal[T]) OnceSync

func (s *Signal[T]) OnceSync(f func(T)) ListenerRemoveFunc

OnceSync adds a one-time listener to the the signal which will be fired on the same gorountine as it is emitted.

type TypingStartEvent

type TypingStartEvent struct {
	Shard     *Shard
	ChannelID ID
	UserID    ID
	Timestamp time.Time
	GuildID   *ID
	Member    *Member
}

type UpdateChannelOpts

type UpdateChannelOpts struct {
	Name           *string                `json:"name,omitempty"`
	Topic          *string                `json:"topic,omitempty"`
	URL            *string                `json:"url,omitempty"`
	Icon           *string                `json:"icon,omitempty"`
	OwnerID        *string                `json:"owner_id,omitempty"`
	Position       *int                   `json:"position,omitempty"`
	ParentID       *ID                    `json:"parent_id,omitempty"`
	Bitrate        *int                   `json:"bitrate,omitempty"`
	UserLimit      *int                   `json:"user_limit,omitempty"`
	RTCRegion      *string                `json:"rtc_region,omitempty"`
	PermOverwrites []ChannelPermOverwrite `json:"permission_overwrites,omitzero"`
	Recipients     []User                 `json:"recipients,omitzero"`
	NSFW           *bool                  `json:"nsfw,omitempty"`
	RateLimitSecs  *int                   `json:"rate_limit_per_user,omitempty"`
	Nicks          map[ID]string          `json:"nicks,omitzero"`
}

type UpdateCurrentMemberOpts

type UpdateCurrentMemberOpts struct {
	AuditLogReason    string     `json:"-"`
	Nick              *string    `json:"nick,omitempty"`
	Avatar            *string    `json:"avatar,omitempty"`
	Banner            *string    `json:"banner,omitempty"`
	Bio               *string    `json:"bio,omitempty"`
	Pronouns          *string    `json:"pronouns,omitempty"`
	AccentColor       *ColorInt  `json:"accent_color,omitempty"`
	Mute              *bool      `json:"mute,omitempty"`
	Deaf              *bool      `json:"deaf,omitempty"`
	CommDisabledUntil *time.Time `json:"communication_disabled_until,omitempty"`
	TimeoutReason     *string    `json:"timeout_reason,omitempty"`
	ChannelID         *ID        `json:"channel_id,omitempty"`
}

type UpdateGuildEmojiOpts

type UpdateGuildEmojiOpts struct {
	Name *string `json:"name,omitempty"`
}

type UpdateGuildStickerOpts

type UpdateGuildStickerOpts struct {
	Name        *string  `json:"name,omitempty"`
	Description *string  `json:"description,omitempty"`
	Tags        []string `json:"tags,omitzero"`
}

type UpdateMemberOpts

type UpdateMemberOpts struct {
	AuditLogReason    string     `json:"-"`
	Nick              *string    `json:"nick,omitempty"`
	Roles             []ID       `json:"roles,omitzero"`
	Mute              *bool      `json:"mute,omitempty"`
	Deaf              *bool      `json:"deaf,omitempty"`
	CommDisabledUntil *time.Time `json:"communication_disabled_until,omitempty"`
	TimeoutReason     *string    `json:"timeout_reason,omitempty"`
	ChannelID         *ID        `json:"channel_id,omitempty"`
}

type UpdateRoleOpts

type UpdateRoleOpts struct {
	Name          *string   `json:"name,omitempty"`
	Color         *ColorInt `json:"color,omitempty"`
	Perms         *Perms    `json:"permissions,omitempty"`
	Hoist         *bool     `json:"hoist,omitempty"`
	HoistPosition *int      `json:"hoist_position,omitempty"`
	Mentionable   *bool     `json:"mentionable,omitempty"`
}

type UpdateWebhookOpts

type UpdateWebhookOpts struct {
	Name *string `json:"name,omitempty"`
	// Avatar is the webhook avatar in base64.
	Avatar *string `json:"avatar,omitempty"`
}

type User

type User struct {
	ID            ID        `json:"id"`
	Username      string    `json:"username"`
	Discriminator string    `json:"discriminator"`
	GlobalName    *string   `json:"global_name"`
	Avatar        *string   `json:"avatar"`
	AvatarColor   *ColorInt `json:"avatar_color"`
	Bot           bool      `json:"bot"`
	System        bool      `json:"system"`
	Flags         UserFlags `json:"flags"`
}

func (*User) CreatedAt

func (u *User) CreatedAt() time.Time

func (*User) DisplayName

func (u *User) DisplayName() string

DisplayName returns the user's rendered name in chat outside of any guilds.

func (*User) IsDeleted

func (u *User) IsDeleted() bool

IsDeleted returns true if the user is a placeholder for a deleted user. This is currently indicated by a tag of DeletedUser#0000.

func (*User) Mention

func (u *User) Mention() string

func (*User) Tag

func (u *User) Tag() string

Tag returns a string of Username#Discriminator.

type UserFlags

type UserFlags uint
const (
	UserFlagStaff                     UserFlags = 1 << 0
	UserFlagCTPMember                 UserFlags = 1 << 1
	UserFlagPartner                   UserFlags = 1 << 2
	UserFlagBugHunter                 UserFlags = 1 << 3
	UserFlagFriendlyBot               UserFlags = 1 << 4
	UserFlagFriendlyBotManualApproval UserFlags = 1 << 5
)

type UserNotifSettings

type UserNotifSettings uint
const (
	UserNotifSettingsAllMessages  UserNotifSettings = 0
	UserNotifSettingsOnlyMentions UserNotifSettings = 1
	UserNotifSettingsNoMessages   UserNotifSettings = 2
	UserNotifSettingsInherit      UserNotifSettings = 3
)

func (UserNotifSettings) String

func (i UserNotifSettings) String() string

type UserPrivate

type UserPrivate struct {
	User
	IsStaff     bool      `json:"is_staff"`
	Traits      []string  `json:"traits"`
	Bio         string    `json:"bio"`
	AccentColor *ColorInt `json:"accent_color"`
	Banner      *string   `json:"banner"`
	BannerColor *ColorInt `json:"banner_color"`
	MFAEnabled  bool      `json:"mfa_enabled"`
	NSFWAllowed bool      `json:"nsfw_allowed"`
}

type UserStatus

type UserStatus string
var (
	UserStatusOnline       UserStatus = "online"
	UserStatusOffline      UserStatus = "offline"
	UserStatusIdle         UserStatus = "idle"
	UserStatusDoNotDisturb UserStatus = "dnd"
	UserStatusInvisible    UserStatus = "invisible"
)

type UserUpdateEvent

type UserUpdateEvent struct {
	Shard *Shard `json:"-"`
	UserPrivate
}

type Webhook

type Webhook struct {
	ID        ID      `json:"id"`
	GuildID   ID      `json:"guild_id"`
	ChannelID ID      `json:"channel_id"`
	Name      string  `json:"name"`
	Token     string  `json:"token"`
	User      *User   `json:"user"`
	Avatar    *string `json:"avatar"`
}

func (*Webhook) Auth

func (w *Webhook) Auth() WebhookAuth

Auth returns a WebhookAuth value which can be used to perform actions through the webhook.

func (*Webhook) Delete

func (w *Webhook) Delete(ctx context.Context, rest *REST) error

func (*Webhook) DeleteMessage

func (w *Webhook) DeleteMessage(ctx context.Context, rest *REST, messageID ID) error

func (*Webhook) EditMessage

func (w *Webhook) EditMessage(ctx context.Context, rest *REST, messageID ID, opts EditWebhookMessageOpts) (Message, error)

func (*Webhook) Exec

func (w *Webhook) Exec(ctx context.Context, rest *REST, opts ExecWebhookOpts) error

func (*Webhook) ExecWait

func (w *Webhook) ExecWait(ctx context.Context, rest *REST, opts ExecWebhookOpts) (Message, error)

func (*Webhook) Path

func (w *Webhook) Path() string

Path returns the path of the webhook URL with a leading slash. It can be appended to the base API URL to form the webhook URL.

func (*Webhook) Update

func (w *Webhook) Update(ctx context.Context, rest *REST, opts UpdateWebhookOpts) error

type WebhookAuth

type WebhookAuth struct {
	ID    ID
	Token string
}

func (WebhookAuth) Path

func (a WebhookAuth) Path() string

Path returns the path of the webhook URL with a leading slash. It can be appended to the base API URL to form the webhook URL.

Jump to

Keyboard shortcuts

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