Documentation
¶
Overview ¶
Package flo provides a high-level way to use the Fluxer API.
Index ¶
- Constants
- Variables
- func IsRESTError(err error, codes ...RESTErrorCode) bool
- type AllShardsStoppedEvent
- type AllowedMentions
- type AllowedMentionsParse
- type Attachment
- type AttachmentFlags
- type BulkDeletedMessage
- type Cache
- func (c *Cache) Channel(channelID ID) (Channel, bool)
- func (c *Cache) ClearCurrentUser()
- func (c *Cache) CurrentUser() (UserPrivate, bool)
- func (c *Cache) ExpectCurrentUser() UserPrivate
- func (c *Cache) UpdateChannel(channelID ID, update func(channel *Channel)) bool
- func (c *Cache) UpdateCurrentUser(user UserPrivate)
- type Channel
- func (c *Channel) BulkDeleteMessages(ctx context.Context, rest *REST, messageIDs []ID) error
- func (c *Channel) CreateMessage(ctx context.Context, rest *REST, opts CreateMessageOpts) (Message, error)
- func (c *Channel) CreateReaction(ctx context.Context, rest *REST, msgID ID, emoji string) error
- func (c *Channel) CreateWebhook(ctx context.Context, rest *REST, opts CreateWebhookOpts) (Webhook, error)
- func (c *Channel) CreatedAt() time.Time
- func (c *Channel) Delete(ctx context.Context, rest *REST) error
- func (c *Channel) DeleteMessage(ctx context.Context, rest *REST, msgID ID) error
- func (c *Channel) EditMessage(ctx context.Context, rest *REST, msgID ID, opts EditMessageOpts) (Message, error)
- func (c *Channel) GetMessage(ctx context.Context, rest *REST, msgID ID) (Message, error)
- func (c *Channel) GetMessages(ctx context.Context, rest *REST, opts GetMessagesOpts) ([]Message, error)
- func (c *Channel) GetWebhooks(ctx context.Context, rest *REST) ([]Webhook, error)
- func (c *Channel) IsTextable() bool
- func (c *Channel) MemberOverwrite(userID ID) (ChannelPermOverwrite, bool)
- func (c *Channel) Mention() string
- func (c *Channel) RemoveAllReactions(ctx context.Context, rest *REST, msgID ID) error
- func (c *Channel) RemoveEmojiReactions(ctx context.Context, rest *REST, msgID ID, emoji string) error
- func (c *Channel) RemoveOwnReaction(ctx context.Context, rest *REST, msgID ID, emoji string) error
- func (c *Channel) RemoveReaction(ctx context.Context, rest *REST, msgID ID, emoji string, userID ID) error
- func (c *Channel) RoleOverwrite(roleID ID) (ChannelPermOverwrite, bool)
- func (c *Channel) StartTyping(ctx context.Context, rest *REST) error
- func (c *Channel) Update(ctx context.Context, rest *REST, opts UpdateChannelOpts) error
- type ChannelCreateEvent
- type ChannelDeleteEvent
- type ChannelPermOverwrite
- type ChannelPermOverwriteType
- type ChannelType
- type ChannelUpdateBulkEvent
- type ChannelUpdateEvent
- type Collection
- func (c *Collection[T]) Clear()
- func (c *Collection[T]) Contains(id ID) bool
- func (c *Collection[T]) Delete(id ID) (*T, bool)
- func (c *Collection[T]) Get(id ID) (T, bool)
- func (c *Collection[T]) IDs() iter.Seq[ID]
- func (c *Collection[T]) Items() iter.Seq2[ID, T]
- func (c *Collection[T]) Len() int
- func (c *Collection[T]) Limit() (int, bool)
- func (c *Collection[T]) Set(id ID, val T)
- func (c *Collection[T]) Update(id ID, update func(val *T)) bool
- func (c *Collection[T]) Upsert(id ID, val T, update func(val *T)) bool
- type ColorInt
- type CreateAttachmentOpts
- type CreateGuildBanOpts
- type CreateGuildChannelOpts
- type CreateGuildEmojiOpts
- type CreateGuildStickerOpts
- type CreateMessageOpts
- type CreateRoleOpts
- type CreateWebhookOpts
- type CustomStatusOpts
- type EditAttachmentOpts
- type EditMessageOpts
- type EditWebhookMessageOpts
- type Embed
- type EmbedAuthor
- type EmbedAuthorOpts
- type EmbedField
- type EmbedFooter
- type EmbedFooterOpts
- type EmbedMedia
- type EmbedMediaFlags
- type EmbedMediaOpts
- type EmbedOpts
- type EmbedType
- type ExecWebhookOpts
- type Gateway
- func (g *Gateway) ExpectShard(id uint) *Shard
- func (g *Gateway) Reconnect() error
- func (g *Gateway) RunningShards() uint
- func (g *Gateway) SetPresence(opts PresenceOpts)
- func (g *Gateway) Shard(id uint) (*Shard, bool)
- func (g *Gateway) Shards() []*Shard
- func (g *Gateway) Start() error
- func (g *Gateway) Stop() error
- type GatewayOpcode
- type GatewayPacket
- type GetMembersOpts
- type GetMessagesOpts
- type Guild
- func (g *Guild) AddMemberRole(ctx context.Context, rest *REST, userID ID, roleID ID) error
- func (g *Guild) AddMemberRoleWithReason(ctx context.Context, rest *REST, userID ID, roleID ID, reason string) error
- func (g *Guild) CreateBan(ctx context.Context, rest *REST, userID ID, opts CreateGuildBanOpts) error
- func (g *Guild) CreateChannel(ctx context.Context, rest *REST, opts CreateGuildChannelOpts) (Channel, error)
- func (g *Guild) CreateEmoji(ctx context.Context, rest *REST, opts CreateGuildEmojiOpts) (GuildEmoji, error)
- func (g *Guild) CreateRole(ctx context.Context, rest *REST, opts CreateRoleOpts) (Role, error)
- func (g *Guild) CreateSticker(ctx context.Context, rest *REST, opts CreateGuildStickerOpts) (GuildSticker, error)
- func (g *Guild) CreatedAt() time.Time
- func (g *Guild) DeleteEmoji(ctx context.Context, rest *REST, emojiID ID) error
- func (g *Guild) DeleteRole(ctx context.Context, rest *REST, roleID ID) error
- func (g *Guild) DeleteSticker(ctx context.Context, rest *REST, stickerID ID) error
- func (g *Guild) GetBans(ctx context.Context, rest *REST) ([]GuildBan, error)
- func (g *Guild) GetCurrentMember(ctx context.Context, rest *REST) (Member, error)
- func (g *Guild) GetEmoji(ctx context.Context, rest *REST, emojiID ID) (GuildEmoji, error)
- func (g *Guild) GetMember(ctx context.Context, rest *REST, userID ID) (Member, error)
- func (g *Guild) GetMembers(ctx context.Context, rest *REST, opts GetMembersOpts) ([]Member, error)
- func (g *Guild) GetRole(ctx context.Context, rest *REST, roleID ID) (Role, error)
- func (g *Guild) GetSticker(ctx context.Context, rest *REST, stickerID ID) (GuildSticker, error)
- func (g *Guild) GetWebhooks(ctx context.Context, rest *REST) ([]Webhook, error)
- func (g *Guild) Leave(ctx context.Context, rest *REST) error
- func (g *Guild) RemoveBan(ctx context.Context, rest *REST, userID ID) error
- func (g *Guild) RemoveBanWithReason(ctx context.Context, rest *REST, userID ID, reason string) error
- func (g *Guild) RemoveMember(ctx context.Context, rest *REST, userID ID) error
- func (g *Guild) RemoveMemberRole(ctx context.Context, rest *REST, userID ID, roleID ID) error
- func (g *Guild) RemoveMemberRoleWithReason(ctx context.Context, rest *REST, userID ID, roleID ID, reason string) error
- func (g *Guild) RemoveMemberWithReason(ctx context.Context, rest *REST, userID ID, reason string) error
- func (g *Guild) ResolvePerms(member Member) Perms
- func (g *Guild) ResolvePermsInChannel(member Member, channel Channel) (Perms, bool)
- func (g *Guild) UpdateCurrentMember(ctx context.Context, rest *REST, opts UpdateCurrentMemberOpts) (Member, error)
- func (g *Guild) UpdateEmoji(ctx context.Context, rest *REST, emojiID ID, opts UpdateGuildEmojiOpts) (GuildEmoji, error)
- func (g *Guild) UpdateMember(ctx context.Context, rest *REST, userID ID, opts UpdateMemberOpts) (Member, error)
- func (g *Guild) UpdateRole(ctx context.Context, rest *REST, roleID ID, opts UpdateRoleOpts) (Role, error)
- func (g *Guild) UpdateSticker(ctx context.Context, rest *REST, stickerID ID, opts UpdateGuildStickerOpts) (GuildSticker, error)
- type GuildAddEvent
- type GuildBan
- type GuildBanAddEvent
- type GuildBanRemoveEvent
- type GuildEmoji
- type GuildEmojisUpdateEvent
- type GuildExplicitContentFilter
- type GuildFeature
- type GuildMFALevel
- type GuildNSFWLevel
- type GuildOperations
- type GuildRemoveEvent
- type GuildSplashCardAlignment
- type GuildSticker
- type GuildStickersUpdateEvent
- type GuildSystemChannelFlags
- type GuildUpdateEvent
- type GuildVerifLevel
- type ID
- type InstanceAppPublicConfig
- type InstanceCaptchaConfig
- type InstanceEndpoints
- type InstanceFeatures
- type InstanceGIFConfig
- type InstanceInfo
- type InstanceLimitConfig
- type InstanceLimitRule
- type InstanceLimitRuleFilters
- type InstancePushNotifConfig
- type InstanceSSOConfig
- type ListenerRemoveFunc
- type Member
- type MemberAddEvent
- type MemberRemoveEvent
- type MemberUpdateEvent
- type Message
- func (m *Message) Channel(cache *Cache) (Channel, bool)
- func (m *Message) CreateReaction(ctx context.Context, rest *REST, emoji string) error
- func (m *Message) CreatedAt() time.Time
- func (m *Message) Delete(ctx context.Context, rest *REST) error
- func (m *Message) Edit(ctx context.Context, rest *REST, opts EditMessageOpts) error
- func (m *Message) IsDeletable() bool
- func (m *Message) RemoveAllReactions(ctx context.Context, rest *REST) error
- func (m *Message) RemoveEmojiReactions(ctx context.Context, rest *REST, emoji string) error
- func (m *Message) RemoveOwnReaction(ctx context.Context, rest *REST, emoji string) error
- func (m *Message) RemoveReaction(ctx context.Context, rest *REST, emoji string, userID ID) error
- type MessageCall
- type MessageCreateEvent
- type MessageDeleteBulkEvent
- type MessageDeleteEvent
- type MessageFlags
- type MessageReaction
- type MessageReference
- type MessageReferenceOpts
- type MessageReferenceType
- type MessageSticker
- type MessageType
- type MessageUpdateEvent
- type Perms
- func (p *Perms) Clear(p2 ...Perms)
- func (p Perms) Difference(p2 Perms) Perms
- func (p Perms) Equal(p2 Perms) bool
- func (p Perms) Has(p2 ...Perms) bool
- func (p Perms) Intersection(p2 Perms) Perms
- func (p Perms) MarshalJSON() ([]byte, error)
- func (p *Perms) Set(p2 ...Perms)
- func (p Perms) String() string
- func (p Perms) ToUint64() uint64
- func (p Perms) Union(p2 Perms) Perms
- func (p *Perms) UnmarshalJSON(data []byte) error
- type PresenceOpts
- type REST
- func (r *REST) AddMemberRole(ctx context.Context, guildID ID, userID ID, roleID ID) error
- func (r *REST) AddMemberRoleWithReason(ctx context.Context, guildID ID, userID ID, roleID ID, reason string) error
- func (r *REST) BulkDeleteMessages(ctx context.Context, channelID ID, messageIDs []ID) error
- func (r *REST) CreateDMChannel(ctx context.Context, userID ID) (Channel, error)
- func (r *REST) CreateGuildBan(ctx context.Context, guildID ID, userID ID, opts CreateGuildBanOpts) error
- func (r *REST) CreateGuildChannel(ctx context.Context, guildID ID, opts CreateGuildChannelOpts) (Channel, error)
- func (r *REST) CreateGuildEmoji(ctx context.Context, guildID ID, opts CreateGuildEmojiOpts) (GuildEmoji, error)
- func (r *REST) CreateGuildSticker(ctx context.Context, guildID ID, opts CreateGuildStickerOpts) (GuildSticker, error)
- func (r *REST) CreateMessage(ctx context.Context, channelID ID, opts CreateMessageOpts) (Message, error)
- func (r *REST) CreateReaction(ctx context.Context, channelID ID, messageID ID, emoji string) error
- func (r *REST) CreateRole(ctx context.Context, guildID ID, opts CreateRoleOpts) (Role, error)
- func (r *REST) CreateWebhook(ctx context.Context, channelID ID, opts CreateWebhookOpts) (Webhook, error)
- func (r *REST) DeleteChannel(ctx context.Context, channelID ID) error
- func (r *REST) DeleteGuildEmoji(ctx context.Context, guildID ID, emojiID ID) error
- func (r *REST) DeleteGuildSticker(ctx context.Context, guildID ID, emojiID ID) error
- func (r *REST) DeleteMessage(ctx context.Context, channelID ID, msgID ID) error
- func (r *REST) DeleteRole(ctx context.Context, guildID ID, roleID ID) error
- func (r *REST) DeleteWebhook(ctx context.Context, webhookID ID) error
- func (r *REST) DeleteWebhookMessage(ctx context.Context, auth WebhookAuth, messageID ID) error
- func (r *REST) DeleteWebhookWithAuth(ctx context.Context, auth WebhookAuth) error
- func (r *REST) EditMessage(ctx context.Context, channelID ID, msgID ID, opts EditMessageOpts) (Message, error)
- func (r *REST) EditWebhookMessage(ctx context.Context, auth WebhookAuth, messageID ID, ...) (Message, error)
- func (r *REST) ExecWebhook(ctx context.Context, auth WebhookAuth, opts ExecWebhookOpts) error
- func (r *REST) ExecWebhookWait(ctx context.Context, auth WebhookAuth, opts ExecWebhookOpts) (Message, error)
- func (r *REST) GetChannel(ctx context.Context, channelID ID) (Channel, error)
- func (r *REST) GetChannelWebhooks(ctx context.Context, channelID ID) ([]Webhook, error)
- func (r *REST) GetCurrentMember(ctx context.Context, guildID ID) (Member, error)
- func (r *REST) GetCurrentUser(ctx context.Context) (UserPrivate, error)
- func (r *REST) GetGuild(ctx context.Context, guildID ID) (Guild, error)
- func (r *REST) GetGuildBans(ctx context.Context, guildID ID) ([]GuildBan, error)
- func (r *REST) GetGuildEmoji(ctx context.Context, guildID ID, emojiID ID) (GuildEmoji, error)
- func (r *REST) GetGuildSticker(ctx context.Context, guildID ID, stickerID ID) (GuildSticker, error)
- func (r *REST) GetGuildWebhooks(ctx context.Context, channelID ID) ([]Webhook, error)
- func (r *REST) GetInstanceInfo(ctx context.Context) (InstanceInfo, error)
- func (r *REST) GetMember(ctx context.Context, guildID ID, userID ID) (Member, error)
- func (r *REST) GetMembers(ctx context.Context, guildID ID, opts GetMembersOpts) ([]Member, error)
- func (r *REST) GetMessage(ctx context.Context, channelID ID, msgID ID) (Message, error)
- func (r *REST) GetMessages(ctx context.Context, channelID ID, opts GetMessagesOpts) ([]Message, error)
- func (r *REST) GetRole(ctx context.Context, guildID ID, roleID ID) (Role, error)
- func (r *REST) GetUser(ctx context.Context, userID ID) (User, error)
- func (r *REST) GetWebhook(ctx context.Context, webhookID ID) (Webhook, error)
- func (r *REST) GetWebhookWithAuth(ctx context.Context, auth WebhookAuth) (Webhook, error)
- func (r *REST) LeaveGuild(ctx context.Context, guildID ID) error
- func (r *REST) RemoveAllReactions(ctx context.Context, channelID ID, messageID ID) error
- func (r *REST) RemoveEmojiReactions(ctx context.Context, channelID ID, messageID ID, emoji string) error
- func (r *REST) RemoveGuildBan(ctx context.Context, guildID ID, userID ID) error
- func (r *REST) RemoveGuildBanWithReason(ctx context.Context, guildID ID, userID ID, reason string) error
- func (r *REST) RemoveMember(ctx context.Context, guildID ID, userID ID) error
- func (r *REST) RemoveMemberRole(ctx context.Context, guildID ID, userID ID, roleID ID) error
- func (r *REST) RemoveMemberRoleWithReason(ctx context.Context, guildID ID, userID ID, roleID ID, reason string) error
- func (r *REST) RemoveMemberWithReason(ctx context.Context, guildID ID, userID ID, reason string) error
- func (r *REST) RemoveOwnReaction(ctx context.Context, channelID ID, messageID ID, emoji string) error
- func (r *REST) RemoveReaction(ctx context.Context, channelID ID, messageID ID, emoji string, userID ID) error
- func (r *REST) Request(ctx context.Context, req RESTRequest) (*http.Response, error)
- func (r *REST) RequestJSON(ctx context.Context, req RESTRequest, result any) error
- func (r *REST) RequestNoContent(ctx context.Context, req RESTRequest) error
- func (r *REST) StartTyping(ctx context.Context, channelID ID) error
- func (r *REST) UpdateChannel(ctx context.Context, channelID ID, opts UpdateChannelOpts) (Channel, error)
- func (r *REST) UpdateCurrentMember(ctx context.Context, guildID ID, opts UpdateCurrentMemberOpts) (Member, error)
- func (r *REST) UpdateGuildEmoji(ctx context.Context, guildID ID, emojiID ID, opts UpdateGuildEmojiOpts) (GuildEmoji, error)
- func (r *REST) UpdateGuildSticker(ctx context.Context, guildID ID, stickerID ID, opts UpdateGuildStickerOpts) (GuildSticker, error)
- func (r *REST) UpdateMember(ctx context.Context, guildID ID, userID ID, opts UpdateMemberOpts) (Member, error)
- func (r *REST) UpdateRole(ctx context.Context, guildID ID, roleID ID, opts UpdateRoleOpts) (Role, error)
- func (r *REST) UpdateWebhook(ctx context.Context, webhookID ID, opts UpdateWebhookOpts) (Webhook, error)
- func (r *REST) UpdateWebhookWithAuth(ctx context.Context, auth WebhookAuth, opts UpdateWebhookOpts) (Webhook, error)
- type RESTAPIError
- type RESTErrorCode
- type RESTFormField
- type RESTHTTPError
- type RESTRequest
- type ReactionEmoji
- type ReadyGuild
- type Role
- type RoleCreateEvent
- type RoleDeleteEvent
- type RoleUpdateBulkEvent
- type RoleUpdateEvent
- type Shard
- func (s *Shard) Gateway() *Gateway
- func (s *Shard) ID() uint
- func (s *Shard) Latency() (time.Duration, bool)
- func (s *Shard) Presence() PresenceOpts
- func (s *Shard) Reconnect() error
- func (s *Shard) Running() bool
- func (s *Shard) SetPresence(opts PresenceOpts)
- func (s *Shard) Start() error
- func (s *Shard) Stop() error
- type ShardConnectedEvent
- type ShardDisconnectedEvent
- type ShardPacketEvent
- type ShardReadyEvent
- type ShardResumedEvent
- type ShardStartedEvent
- type ShardStoppedEvent
- type Signal
- func (s *Signal[T]) Chan() (<-chan T, ListenerRemoveFunc)
- func (s *Signal[T]) ClearListeners()
- func (s *Signal[T]) ListenerCount() int
- func (s *Signal[T]) On(f func(T)) ListenerRemoveFunc
- func (s *Signal[T]) OnSync(f func(T)) ListenerRemoveFunc
- func (s *Signal[T]) Once(f func(T)) ListenerRemoveFunc
- func (s *Signal[T]) OnceChan() (chan T, ListenerRemoveFunc)
- func (s *Signal[T]) OnceSync(f func(T)) ListenerRemoveFunc
- type TypingStartEvent
- type UpdateChannelOpts
- type UpdateCurrentMemberOpts
- type UpdateGuildEmojiOpts
- type UpdateGuildStickerOpts
- type UpdateMemberOpts
- type UpdateRoleOpts
- type UpdateWebhookOpts
- type User
- type UserFlags
- type UserNotifSettings
- type UserPrivate
- type UserStatus
- type UserUpdateEvent
- type Webhook
- func (w *Webhook) Auth() WebhookAuth
- func (w *Webhook) Delete(ctx context.Context, rest *REST) error
- func (w *Webhook) DeleteMessage(ctx context.Context, rest *REST, messageID ID) error
- func (w *Webhook) EditMessage(ctx context.Context, rest *REST, messageID ID, opts EditWebhookMessageOpts) (Message, error)
- func (w *Webhook) Exec(ctx context.Context, rest *REST, opts ExecWebhookOpts) error
- func (w *Webhook) ExecWait(ctx context.Context, rest *REST, opts ExecWebhookOpts) (Message, error)
- func (w *Webhook) Path() string
- func (w *Webhook) Update(ctx context.Context, rest *REST, opts UpdateWebhookOpts) error
- type WebhookAuth
Constants ¶
const ( EmbedMediaFlagNSFW = 1 << 4 EmbedMediaFlagAnimated = 1 << 5 )
const ( AttachmentFlagSpoiler = 1 << 3 AttachmentFlagNSFW = 1 << 4 AttachmentFlagAnimated = 1 << 5 )
const DefaultGatewayVersion = 1
DefaultGatewayVersion is the default gateway version if not specified in Gateway.ConnURL.
Variables ¶
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") )
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, ) )
var AllowedMentionsNone = func() AllowedMentions { f := false return AllowedMentions{ Parse: []AllowedMentionsParse{}, RepliedUser: &f, } }()
AllowedMentionsNone is an AllowedMentions value which disables all mentions.
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.
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.
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 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 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 ¶
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 (*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 (*Channel) CreateMessage ¶
func (*Channel) CreateReaction ¶
func (*Channel) CreateWebhook ¶
func (*Channel) DeleteMessage ¶
func (*Channel) EditMessage ¶
func (*Channel) GetMessage ¶
func (*Channel) GetMessages ¶
func (*Channel) GetWebhooks ¶
func (*Channel) IsTextable ¶
IsTextable returns true if the channel can contains messages.
func (*Channel) MemberOverwrite ¶
func (c *Channel) MemberOverwrite(userID ID) (ChannelPermOverwrite, bool)
func (*Channel) Mention ¶
Mention creates a string which can be used to display the channel in chat.
func (*Channel) RemoveAllReactions ¶
func (*Channel) RemoveEmojiReactions ¶
func (*Channel) RemoveOwnReaction ¶
func (*Channel) RemoveReaction ¶
func (*Channel) RoleOverwrite ¶
func (c *Channel) RoleOverwrite(roleID ID) (ChannelPermOverwrite, bool)
type ChannelCreateEvent ¶
type ChannelDeleteEvent ¶
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 ChannelUpdateEvent ¶
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.
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 CreateGuildEmojiOpts ¶
type CreateGuildStickerOpts ¶
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 CreateWebhookOpts ¶
type CustomStatusOpts ¶
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"`
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 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 EmbedFooter ¶
type EmbedFooter struct {
}
type EmbedFooterOpts ¶
type EmbedFooterOpts struct {
}
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"`
Fields []EmbedField `json:"fields,omitempty"`
}
EmbedOpts specifies a rich embed when creating or editing a message.
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
Shards returns the list of shards which will be connected to. The sharding parameters should not be changed after this is called.
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 GetMessagesOpts ¶
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 (*Guild) AddMemberRoleWithReason ¶
func (*Guild) CreateChannel ¶
func (*Guild) CreateEmoji ¶
func (g *Guild) CreateEmoji(ctx context.Context, rest *REST, opts CreateGuildEmojiOpts) (GuildEmoji, error)
func (*Guild) CreateRole ¶
func (*Guild) CreateSticker ¶
func (g *Guild) CreateSticker(ctx context.Context, rest *REST, opts CreateGuildStickerOpts) (GuildSticker, error)
func (*Guild) DeleteEmoji ¶
func (*Guild) DeleteRole ¶
func (*Guild) DeleteSticker ¶
func (*Guild) GetCurrentMember ¶
func (*Guild) GetMembers ¶
func (*Guild) GetSticker ¶
func (*Guild) GetWebhooks ¶
func (*Guild) RemoveBanWithReason ¶
func (*Guild) RemoveMember ¶
func (*Guild) RemoveMemberRole ¶
func (*Guild) RemoveMemberRoleWithReason ¶
func (*Guild) RemoveMemberWithReason ¶
func (*Guild) ResolvePerms ¶
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 ¶
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 (*Guild) UpdateEmoji ¶
func (g *Guild) UpdateEmoji(ctx context.Context, rest *REST, emojiID ID, opts UpdateGuildEmojiOpts) (GuildEmoji, error)
func (*Guild) UpdateMember ¶
func (*Guild) UpdateRole ¶
func (*Guild) UpdateSticker ¶
func (g *Guild) UpdateSticker(ctx context.Context, rest *REST, stickerID ID, opts UpdateGuildStickerOpts) (GuildSticker, error)
type GuildAddEvent ¶
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 GuildBanRemoveEvent ¶
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"`
}
type GuildExplicitContentFilter ¶
type GuildExplicitContentFilter uint
const ( GuildExplicitContentFilterDisabled GuildExplicitContentFilter = 0 GuildExplicitContentFilterMembersWithoutRoles GuildExplicitContentFilter = 1 GuildExplicitContentFilterAllMembers GuildExplicitContentFilter = 2 )
func (GuildExplicitContentFilter) String ¶
func (i GuildExplicitContentFilter) String() 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" 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"`
}
type GuildSystemChannelFlags ¶
type GuildSystemChannelFlags uint
const (
SystemChannelFlagSupressJoinNotifications GuildSystemChannelFlags = 1 << 0
)
type GuildUpdateEvent ¶
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 ¶
NewID creates a new dummy ID with the timestamp provided. Two IDs created with the same timestamp using this function will be identical.
func (ID) MarshalJSON ¶
func (*ID) UnmarshalJSON ¶
type InstanceAppPublicConfig ¶
type InstanceAppPublicConfig struct {
SentryDSN *string `json:"sentry_dsn"`
}
type InstanceCaptchaConfig ¶
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 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 InstancePushNotifConfig ¶
type InstancePushNotifConfig struct {
PublicVAPIDKey *string `json:"public_vapid_key"`
}
type InstanceSSOConfig ¶
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) DisplayName ¶
DisplayName returns the member's rendered name in chat.
type MemberAddEvent ¶
type MemberRemoveEvent ¶
type MemberUpdateEvent ¶
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 ¶
Channel returns the channel the message was sent in which may or may not be cached.
func (*Message) CreateReaction ¶
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) IsDeletable ¶
func (*Message) RemoveAllReactions ¶
func (*Message) RemoveEmojiReactions ¶
func (*Message) RemoveOwnReaction ¶
type MessageCall ¶
type MessageCreateEvent ¶
type MessageCreateEvent struct {
Shard *Shard `json:"-"`
Member *Member `json:"member"`
GuildID *ID `json:"guild_id"`
Message
}
MessageCreateEvent represents a received message.
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:"-"`
}
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 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
}
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 NewPermsBit ¶
func PermsFromUint64 ¶
func (*Perms) Clear ¶
Clear removes all of the permissions on p2 from p. If p2 is empty, p is fully cleared instead.
func (Perms) Difference ¶
Difference returns the set of permissions which are in p but not in p2.
func (Perms) Intersection ¶
Intersection returns the common permissions between p and p2.
func (Perms) MarshalJSON ¶
func (*Perms) UnmarshalJSON ¶
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 (*REST) AddMemberRoleWithReason ¶
func (*REST) BulkDeleteMessages ¶
func (*REST) CreateDMChannel ¶
func (*REST) CreateGuildBan ¶
func (*REST) CreateGuildChannel ¶
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 (*REST) CreateReaction ¶
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 (*REST) CreateWebhook ¶
func (*REST) DeleteGuildEmoji ¶
func (*REST) DeleteGuildSticker ¶
func (*REST) DeleteMessage ¶
func (*REST) DeleteRole ¶
func (*REST) DeleteWebhookMessage ¶
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 (*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 (*REST) GetChannelWebhooks ¶
GetGuildWebhooks gets a list of channel webhooks, so long as the authenticated user has PermManageWebhooks.
func (*REST) GetCurrentMember ¶
func (*REST) GetCurrentUser ¶
func (r *REST) GetCurrentUser(ctx context.Context) (UserPrivate, error)
func (*REST) GetGuildBans ¶
func (*REST) GetGuildEmoji ¶
func (*REST) GetGuildSticker ¶
func (*REST) GetGuildWebhooks ¶
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) GetMembers ¶
func (*REST) GetMessage ¶
func (*REST) GetMessages ¶
func (*REST) GetWebhook ¶
GetWebhook gets the webhook by the provided ID, so long as the authenticated user has PermManageWebhooks.
func (*REST) GetWebhookWithAuth ¶
GetWebhookWithAuth gets the webhook by the provided ID using its token. Webhook.User is not returned in the response.
func (*REST) RemoveAllReactions ¶
func (*REST) RemoveEmojiReactions ¶
func (*REST) RemoveGuildBan ¶
func (*REST) RemoveGuildBanWithReason ¶
func (*REST) RemoveMember ¶
func (*REST) RemoveMemberRole ¶
func (*REST) RemoveMemberRoleWithReason ¶
func (*REST) RemoveMemberWithReason ¶
func (*REST) RemoveOwnReaction ¶
func (*REST) RemoveReaction ¶
func (*REST) Request ¶
Request sends a Request to a Fluxer endpoint. If the returned error is nil, the response body should be closed.
func (*REST) RequestJSON ¶
func (*REST) RequestNoContent ¶
func (r *REST) RequestNoContent(ctx context.Context, req RESTRequest) error
func (*REST) UpdateChannel ¶
func (*REST) UpdateCurrentMember ¶
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 (*REST) UpdateRole ¶
func (*REST) UpdateWebhook ¶
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" RESTErrSessionTokenMismatch RESTErrorCode = "SESSION_TOKEN_MISMATCH" RESTErrSlowmodeRateLimited RESTErrorCode = "SLOWMODE_RATE_LIMITED" RESTErrSMSMFANotEnabled RESTErrorCode = "SMS_MFA_NOT_ENABLED" RESTErrSMSMFARequiresTOTP RESTErrorCode = "SMS_MFA_REQUIRES_TOTP" 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" 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 ¶
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 {
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"`
}
type RoleCreateEvent ¶
type RoleDeleteEvent ¶
type RoleUpdateBulkEvent ¶
type RoleUpdateEvent ¶
type Shard ¶
type Shard struct {
// contains filtered or unexported fields
}
func (*Shard) Latency ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 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 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 (*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 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 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 UpdateWebhookOpts ¶
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) DisplayName ¶
DisplayName returns the user's rendered name in chat outside of any guilds.
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) DeleteMessage ¶
func (*Webhook) EditMessage ¶
type WebhookAuth ¶
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.