Documentation
¶
Index ¶
- func GenerateEncryptionKey(size int) ([]byte, error)
- func IsStatus(err error, statusCodes ...int) bool
- type ChannelConfig
- type Client
- func (c *Client) AddGuildMember(ctx context.Context, guildID, userID snowflake.ID, accessToken string, ...) (*discord.Member, error)
- func (c *Client) AddGuildMemberRole(ctx context.Context, guildID, userID, roleID snowflake.ID, ...) error
- func (c *Client) AllGuildMembers(ctx context.Context, guildID snowflake.ID) iter.Seq2[*discord.Member, error]
- func (c *Client) AllReactions(ctx context.Context, channelID, messageID snowflake.ID, emoji string) iter.Seq2[*discord.User, error]
- func (c *Client) BeginGuildPrune(ctx context.Context, guildID snowflake.ID, days int, computePruneCount bool, ...) (int, error)
- func (c *Client) BulkDeleteMessages(ctx context.Context, channelID snowflake.ID, messageIDs []snowflake.ID, ...) error
- func (c *Client) ClearReactions(ctx context.Context, channelID, messageID snowflake.ID, opts ...RequestOption) error
- func (c *Client) ClearReactionsForEmoji(ctx context.Context, channelID, messageID snowflake.ID, emoji string, ...) error
- func (c *Client) Close() error
- func (c *Client) CreateChannel(ctx context.Context, guildID snowflake.ID, opts *CreateChannelOptions, ...) (*discord.Channel, error)
- func (c *Client) CreateChannelInvite(ctx context.Context, channelID snowflake.ID, opts *CreateChannelInviteOptions, ...) (*discord.Invite, error)
- func (c *Client) CreateGuild(ctx context.Context, guild *discord.GuildCreate, opts ...RequestOption) (*discord.Guild, error)
- func (c *Client) CreateGuildBan(ctx context.Context, guildID, userID snowflake.ID, ...) error
- func (c *Client) CreateGuildRole(ctx context.Context, guildID snowflake.ID, role *discord.GuildRoleCreate, ...) (*discord.Role, error)
- func (c *Client) CreateMessage(ctx context.Context, channelID snowflake.ID, msg *discord.CreateMessage, ...) (*discord.Message, error)
- func (c *Client) CreateMessageWithFiles(ctx context.Context, channelID snowflake.ID, msg *discord.CreateMessage, ...) (*discord.Message, error)
- func (c *Client) CrosspostMessage(ctx context.Context, channelID, messageID snowflake.ID, opts ...RequestOption) (*discord.Message, error)
- func (c *Client) DeleteChannel(ctx context.Context, channelID snowflake.ID, opts ...RequestOption) error
- func (c *Client) DeleteChannelPermission(ctx context.Context, channelID, overwriteID snowflake.ID, ...) error
- func (c *Client) DeleteGuild(ctx context.Context, guildID snowflake.ID, opts ...RequestOption) error
- func (c *Client) DeleteGuildRole(ctx context.Context, guildID, roleID snowflake.ID, opts ...RequestOption) error
- func (c *Client) DeleteMessage(ctx context.Context, channelID, messageID snowflake.ID, opts ...RequestOption) error
- func (c *Client) DeleteReaction(ctx context.Context, channelID, messageID snowflake.ID, emoji string, ...) error
- func (c *Client) EditChannelPermissions(ctx context.Context, channelID, overwriteID snowflake.ID, ...) error
- func (c *Client) EditMessage(ctx context.Context, channelID, messageID snowflake.ID, ...) (*discord.Message, error)
- func (c *Client) FollowAnnouncementChannel(ctx context.Context, channelID snowflake.ID, ...) (*discord.FollowedChannel, error)
- func (c *Client) GetChannel(ctx context.Context, channelID snowflake.ID, opts ...RequestOption) (*discord.Channel, error)
- func (c *Client) GetChannelInvites(ctx context.Context, channelID snowflake.ID, opts ...RequestOption) ([]*discord.Invite, error)
- func (c *Client) GetGuild(ctx context.Context, guildID snowflake.ID, opts ...RequestOption) (*discord.Guild, error)
- func (c *Client) GetGuildBan(ctx context.Context, guildID, userID snowflake.ID, opts ...RequestOption) (*discord.GuildBanAdd, error)
- func (c *Client) GetGuildBans(ctx context.Context, guildID snowflake.ID, opts *GetGuildBansOptions, ...) ([]*discord.GuildBanAdd, error)
- func (c *Client) GetGuildChannels(ctx context.Context, guildID snowflake.ID, opts ...RequestOption) ([]*discord.Channel, error)
- func (c *Client) GetGuildMember(ctx context.Context, guildID, userID snowflake.ID, opts ...RequestOption) (*discord.Member, error)
- func (c *Client) GetGuildPreview(ctx context.Context, guildID snowflake.ID, opts ...RequestOption) (*discord.Guild, error)
- func (c *Client) GetGuildPruneCount(ctx context.Context, guildID snowflake.ID, days int, ...) (int, error)
- func (c *Client) GetGuildRoles(ctx context.Context, guildID snowflake.ID, opts ...RequestOption) ([]*discord.Role, error)
- func (c *Client) GetMessage(ctx context.Context, channelID, messageID snowflake.ID, opts ...RequestOption) (*discord.Message, error)
- func (c *Client) GetMessages(ctx context.Context, channelID snowflake.ID, opts *GetMessagesOptions, ...) ([]*discord.Message, error)
- func (c *Client) GetPins(ctx context.Context, channelID snowflake.ID, opts ...RequestOption) ([]*discord.Message, error)
- func (c *Client) GetReactions(ctx context.Context, channelID, messageID snowflake.ID, emoji string, ...) ([]*discord.User, error)
- func (c *Client) ListGuildMembers(ctx context.Context, guildID snowflake.ID, opts *ListGuildMembersOptions, ...) ([]*discord.Member, error)
- func (c *Client) Messages(ctx context.Context, channelID snowflake.ID, opts *GetMessagesOptions) iter.Seq2[*discord.Message, error]
- func (c *Client) ModifyChannel(ctx context.Context, channelID snowflake.ID, opts *ModifyChannelOptions, ...) (*discord.Channel, error)
- func (c *Client) ModifyCurrentMember(ctx context.Context, guildID snowflake.ID, member *discord.GuildMemberUpdate, ...) (*discord.Member, error)
- func (c *Client) ModifyCurrentUserNick(ctx context.Context, guildID snowflake.ID, nick string, opts ...RequestOption) error
- func (c *Client) ModifyGuild(ctx context.Context, guildID snowflake.ID, guild *discord.GuildUpdate, ...) (*discord.Guild, error)
- func (c *Client) ModifyGuildChannelPositions(ctx context.Context, guildID snowflake.ID, positions []map[string]any, ...) error
- func (c *Client) ModifyGuildMember(ctx context.Context, guildID, userID snowflake.ID, ...) (*discord.Member, error)
- func (c *Client) ModifyGuildRole(ctx context.Context, guildID, roleID snowflake.ID, ...) (*discord.Role, error)
- func (c *Client) ModifyGuildRolePositions(ctx context.Context, guildID snowflake.ID, positions []map[string]any, ...) ([]*discord.Role, error)
- func (c *Client) Pin(ctx context.Context, channelID, messageID snowflake.ID, opts ...RequestOption) error
- func (c *Client) React(ctx context.Context, channelID, messageID snowflake.ID, emoji string, ...) error
- func (c *Client) RemoveGuildBan(ctx context.Context, guildID, userID snowflake.ID, opts ...RequestOption) error
- func (c *Client) RemoveGuildMember(ctx context.Context, guildID, userID snowflake.ID, opts ...RequestOption) error
- func (c *Client) RemoveGuildMemberRole(ctx context.Context, guildID, userID, roleID snowflake.ID, ...) error
- func (c *Client) Reply(ctx context.Context, channelID, messageID snowflake.ID, content string, ...) (*discord.Message, error)
- func (c *Client) SearchGuildMembers(ctx context.Context, guildID snowflake.ID, opts *SearchGuildMembersOptions, ...) ([]*discord.Member, error)
- func (c *Client) Send(ctx context.Context, channelID snowflake.ID, content string, ...) (*discord.Message, error)
- func (c *Client) SessionStats() SessionStats
- func (c *Client) Stats() ratelimit.Stats
- func (c *Client) TriggerTypingIndicator(ctx context.Context, channelID snowflake.ID, opts ...RequestOption) error
- func (c *Client) Unpin(ctx context.Context, channelID, messageID snowflake.ID, opts ...RequestOption) error
- func (c *Client) Unreact(ctx context.Context, channelID, messageID snowflake.ID, emoji string, ...) error
- type CreateChannelInviteOptions
- type CreateChannelOptions
- type CreateGuildBanOptions
- type Encryption
- type Error
- type FollowAnnouncementChannelOptions
- type GetGuildBansOptions
- type GetMessagesOptions
- type GetReactionsOptions
- type HeaderConfig
- type ListGuildMembersOptions
- type MetricsSink
- type ModifyChannelOptions
- type NoopMetrics
- type Option
- func WithBrazilianLocale() Option
- func WithEuropeanLocale() Option
- func WithHTTPClient(client *http.Client) Option
- func WithHeaderConfig(cfg HeaderConfig) Option
- func WithLinux() Option
- func WithLogger(logger *slog.Logger) Option
- func WithMacOS() Option
- func WithMaxRetries(max int) Option
- func WithMetrics(sink MetricsSink) Option
- func WithRequestCoalescing(enabled bool) Option
- func WithRequestInterceptor(i RequestInterceptor) Option
- func WithResponseInterceptor(i ResponseInterceptor) Option
- func WithSession(opts ...SessionOption) Option
- func WithStaticSession(fingerprint string, cookies []*http.Cookie, superProps string) Option
- func WithTimeout(timeout time.Duration) Option
- func WithUnsafeBodyLogging(enabled bool) Option
- type RequestInterceptor
- type RequestOption
- type ResponseInterceptor
- type SearchGuildMembersOptions
- type SessionOption
- type SessionStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateEncryptionKey ¶
Types ¶
type ChannelConfig ¶
type ChannelConfig struct {
Topic *string `json:"topic,omitempty"`
Bitrate *int `json:"bitrate,omitempty"`
UserLimit *int `json:"user_limit,omitempty"`
RateLimitPerUser *int `json:"rate_limit_per_user,omitempty"`
Position *int `json:"position,omitempty"`
PermissionOverwrites []*discord.PermissionOverwrite `json:"permission_overwrites,omitempty"`
ParentID *snowflake.ID `json:"parent_id,omitempty"`
NSFW *bool `json:"nsfw,omitempty"`
RTCRegion *string `json:"rtc_region,omitempty"`
VideoQualityMode *int `json:"video_quality_mode,omitempty"`
DefaultAutoArchiveDuration *int `json:"default_auto_archive_duration,omitempty"`
DefaultReactionEmoji *discord.DefaultReaction `json:"default_reaction_emoji,omitempty"`
AvailableTags []*discord.ForumTag `json:"available_tags,omitempty"`
DefaultSortOrder *int `json:"default_sort_order,omitempty"`
DefaultForumLayout *int `json:"default_forum_layout,omitempty"`
DefaultThreadRateLimitPerUser *int `json:"default_thread_rate_limit_per_user,omitempty"`
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) AddGuildMember ¶
func (*Client) AddGuildMemberRole ¶
func (*Client) AllGuildMembers ¶
func (*Client) AllReactions ¶
func (*Client) BeginGuildPrune ¶
func (*Client) BulkDeleteMessages ¶
func (*Client) ClearReactions ¶
func (*Client) ClearReactionsForEmoji ¶
func (*Client) CreateChannel ¶
func (c *Client) CreateChannel(ctx context.Context, guildID snowflake.ID, opts *CreateChannelOptions, reqOpts ...RequestOption) (*discord.Channel, error)
func (*Client) CreateChannelInvite ¶
func (c *Client) CreateChannelInvite(ctx context.Context, channelID snowflake.ID, opts *CreateChannelInviteOptions, reqOpts ...RequestOption) (*discord.Invite, error)
func (*Client) CreateGuild ¶
func (c *Client) CreateGuild(ctx context.Context, guild *discord.GuildCreate, opts ...RequestOption) (*discord.Guild, error)
func (*Client) CreateGuildBan ¶
func (c *Client) CreateGuildBan(ctx context.Context, guildID, userID snowflake.ID, banOpts *CreateGuildBanOptions, opts ...RequestOption) error
func (*Client) CreateGuildRole ¶
func (*Client) CreateMessage ¶
func (*Client) CreateMessageWithFiles ¶
func (*Client) CrosspostMessage ¶
func (*Client) DeleteChannel ¶
func (*Client) DeleteChannelPermission ¶
func (*Client) DeleteGuild ¶
func (*Client) DeleteGuildRole ¶
func (*Client) DeleteMessage ¶
func (*Client) DeleteReaction ¶
func (*Client) EditChannelPermissions ¶
func (c *Client) EditChannelPermissions(ctx context.Context, channelID, overwriteID snowflake.ID, perms *discord.PermissionOverwrite, reqOpts ...RequestOption) error
func (*Client) EditMessage ¶
func (*Client) FollowAnnouncementChannel ¶
func (c *Client) FollowAnnouncementChannel(ctx context.Context, channelID snowflake.ID, opts *FollowAnnouncementChannelOptions, reqOpts ...RequestOption) (*discord.FollowedChannel, error)
func (*Client) GetChannel ¶
func (*Client) GetChannelInvites ¶
func (*Client) GetGuildBan ¶
func (c *Client) GetGuildBan(ctx context.Context, guildID, userID snowflake.ID, opts ...RequestOption) (*discord.GuildBanAdd, error)
func (*Client) GetGuildBans ¶
func (c *Client) GetGuildBans(ctx context.Context, guildID snowflake.ID, opts *GetGuildBansOptions, reqOpts ...RequestOption) ([]*discord.GuildBanAdd, error)
func (*Client) GetGuildChannels ¶
func (*Client) GetGuildMember ¶
func (*Client) GetGuildPreview ¶
func (*Client) GetGuildPruneCount ¶
func (*Client) GetGuildRoles ¶
func (*Client) GetMessage ¶
func (*Client) GetMessages ¶
func (c *Client) GetMessages(ctx context.Context, channelID snowflake.ID, opts *GetMessagesOptions, reqOpts ...RequestOption) ([]*discord.Message, error)
func (*Client) GetReactions ¶
func (*Client) ListGuildMembers ¶
func (c *Client) ListGuildMembers(ctx context.Context, guildID snowflake.ID, opts *ListGuildMembersOptions, reqOpts ...RequestOption) ([]*discord.Member, error)
func (*Client) ModifyChannel ¶
func (c *Client) ModifyChannel(ctx context.Context, channelID snowflake.ID, opts *ModifyChannelOptions, reqOpts ...RequestOption) (*discord.Channel, error)
func (*Client) ModifyCurrentMember ¶
func (*Client) ModifyCurrentUserNick ¶
func (*Client) ModifyGuild ¶
func (*Client) ModifyGuildChannelPositions ¶
func (*Client) ModifyGuildMember ¶
func (*Client) ModifyGuildRole ¶
func (*Client) ModifyGuildRolePositions ¶
func (*Client) RemoveGuildBan ¶
func (*Client) RemoveGuildMember ¶
func (*Client) RemoveGuildMemberRole ¶
func (*Client) SearchGuildMembers ¶
func (c *Client) SearchGuildMembers(ctx context.Context, guildID snowflake.ID, opts *SearchGuildMembersOptions, reqOpts ...RequestOption) ([]*discord.Member, error)
func (*Client) SessionStats ¶
func (c *Client) SessionStats() SessionStats
func (*Client) TriggerTypingIndicator ¶
type CreateChannelInviteOptions ¶
type CreateChannelInviteOptions struct {
MaxAge *int `json:"max_age,omitempty"`
MaxUses *int `json:"max_uses,omitempty"`
Temporary *bool `json:"temporary,omitempty"`
Unique *bool `json:"unique,omitempty"`
TargetType *int `json:"target_type,omitempty"`
TargetUserID *snowflake.ID `json:"target_user_id,omitempty"`
TargetApplicationID *snowflake.ID `json:"target_application_id,omitempty"`
}
type CreateChannelOptions ¶
type CreateChannelOptions struct {
Name string `json:"name"`
Type int `json:"type"`
ChannelConfig
}
type CreateGuildBanOptions ¶
type Encryption ¶
type Encryption struct {
Key []byte
}
type Error ¶
type Error struct {
Request *http.Request
RequestBody []byte
Response *http.Response
ResponseBody []byte
APIError *discord.APIError
}
Error contains HTTP request/response context and parsed Discord API error details.
func (*Error) StatusCode ¶
type GetGuildBansOptions ¶
type GetMessagesOptions ¶
type GetReactionsOptions ¶
type HeaderConfig ¶
type HeaderConfig struct {
UserAgent string
Accept string
AcceptLanguage string
Origin string
Referer string
SecChUa string
SecChUaMobile string
SecChUaPlatform string
SecFetchDest string
SecFetchMode string
SecFetchSite string
DiscordLocale string
DiscordTimezone string
DebugOptions string
BrowserVersion string
OS string
OSVersion string
SystemLocale string
ReleaseChannel string
}
HeaderConfig holds all configurable HTTP headers
func BrazilianLocale ¶
func BrazilianLocale() HeaderConfig
Preset configurations for common use cases
func DefaultHeaderConfig ¶
func DefaultHeaderConfig() HeaderConfig
DefaultHeaderConfig returns the default header configuration
func EuropeanLocale ¶
func EuropeanLocale() HeaderConfig
func LinuxConfig ¶
func LinuxConfig() HeaderConfig
func MacOSConfig ¶
func MacOSConfig() HeaderConfig
func (*HeaderConfig) ApplyToRequest ¶
func (h *HeaderConfig) ApplyToRequest(req *http.Request, contentType string, fingerprint string, superProps string)
ApplyToRequest applies the header configuration to an HTTP request
func (*HeaderConfig) GenerateSuperProperties ¶
func (h *HeaderConfig) GenerateSuperProperties(buildNumber int) (string, error)
GenerateSuperProperties generates the X-Super-Properties
type ListGuildMembersOptions ¶
type MetricsSink ¶
type MetricsSink interface {
Inc(key string)
}
MetricsSink receives internal counters from the REST client.
type ModifyChannelOptions ¶
type ModifyChannelOptions struct {
Name *string `json:"name,omitempty"`
Type *int `json:"type,omitempty"`
ChannelConfig
}
type NoopMetrics ¶
type NoopMetrics struct{}
NoopMetrics ignores all emitted metrics.
func (NoopMetrics) Inc ¶
func (NoopMetrics) Inc(string)
type Option ¶
type Option func(*Client)
func WithBrazilianLocale ¶
func WithBrazilianLocale() Option
func WithEuropeanLocale ¶
func WithEuropeanLocale() Option
func WithHTTPClient ¶
func WithHeaderConfig ¶
func WithHeaderConfig(cfg HeaderConfig) Option
func WithLogger ¶
func WithMaxRetries ¶
func WithMetrics ¶
func WithMetrics(sink MetricsSink) Option
WithMetrics sets the metrics sink used by internal counters.
func WithRequestCoalescing ¶
WithRequestCoalescing enables/disables inflight deduplication for GET requests.
func WithRequestInterceptor ¶
func WithRequestInterceptor(i RequestInterceptor) Option
func WithResponseInterceptor ¶
func WithResponseInterceptor(i ResponseInterceptor) Option
func WithSession ¶
func WithSession(opts ...SessionOption) Option
func WithStaticSession ¶
func WithTimeout ¶
func WithUnsafeBodyLogging ¶
WithUnsafeBodyLogging enables logging raw request/response payloads. This is disabled by default because payloads can contain sensitive data.
type RequestInterceptor ¶
type RequestOption ¶
func WithHeader ¶
func WithHeader(key, value string) RequestOption
func WithReason ¶
func WithReason(reason string) RequestOption
type ResponseInterceptor ¶
type SessionOption ¶
type SessionOption func(*sessionConfig)
func WithAutoRotate ¶
func WithAutoRotate(threshold float64) SessionOption
func WithBuildNumber ¶
func WithBuildNumber(build int) SessionOption
func WithPersist ¶
func WithPersist(path string, encryption ...*Encryption) SessionOption
func WithSessionLogger ¶
func WithSessionLogger(logger *slog.Logger) SessionOption
func WithoutAutoRotate ¶
func WithoutAutoRotate() SessionOption