gateway

package
v0.0.0-...-8fd61c5 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: BSD-3-Clause Imports: 38 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterCacheListeners

func RegisterCacheListeners(sm *ShardManager)

Types

type Hooks

type Hooks struct {
	ReconnectHook func(*Shard)
	IdentifyHook  func(*Shard)
	RestHook      func(token string, req *http.Request)
}

type Shard

type Shard struct {
	ShardManager *ShardManager
	Token        string
	ShardId      int

	WebSocket *websocket.Conn

	Cache cache.Cache
	// contains filtered or unexported fields
}

func NewShard

func NewShard(shardManager *ShardManager, token string, shardId int) Shard

func (*Shard) AddGuildMemberRole

func (s *Shard) AddGuildMemberRole(ctx context.Context, guildId, userId, roleId uint64) error

func (*Shard) AddPinnedChannelMessage

func (s *Shard) AddPinnedChannelMessage(ctx context.Context, channelId, messageId uint64) error

func (*Shard) AddThreadMember

func (s *Shard) AddThreadMember(ctx context.Context, channelId, userId uint64) error

func (*Shard) BeginGuildPrune

func (s *Shard) BeginGuildPrune(ctx context.Context, guildId uint64, days int, computePruneCount bool) error

computePruneCount = whether 'pruned' is returned, discouraged for large guilds

func (*Shard) BulkDeleteMessages

func (s *Shard) BulkDeleteMessages(ctx context.Context, channelId uint64, messages []uint64) error

func (*Shard) Connect

func (s *Shard) Connect() error

func (*Shard) CountdownHeartbeat

func (s *Shard) CountdownHeartbeat(ticker *time.Ticker)

func (*Shard) CreateChannelInvite

func (s *Shard) CreateChannelInvite(ctx context.Context, channelId uint64, data rest.CreateInviteData) (invite.Invite, error)

func (*Shard) CreateDM

func (s *Shard) CreateDM(ctx context.Context, recipientId uint64) (channel.Channel, error)

func (*Shard) CreateGlobalCommand

func (s *Shard) CreateGlobalCommand(ctx context.Context, applicationId uint64, data rest.CreateCommandData) (interaction.ApplicationCommand, error)

func (*Shard) CreateGuild

func (s *Shard) CreateGuild(ctx context.Context, data rest.CreateGuildData) (guild.Guild, error)

func (*Shard) CreateGuildBan

func (s *Shard) CreateGuildBan(ctx context.Context, guildId, userId uint64, data rest.CreateGuildBanData) error

func (*Shard) CreateGuildChannel

func (s *Shard) CreateGuildChannel(ctx context.Context, guildId uint64, data rest.CreateChannelData) (channel.Channel, error)

func (*Shard) CreateGuildCommand

func (s *Shard) CreateGuildCommand(ctx context.Context, applicationId, guildId uint64, data rest.CreateCommandData) (interaction.ApplicationCommand, error)

func (*Shard) CreateGuildEmoji

func (s *Shard) CreateGuildEmoji(ctx context.Context, guildId uint64, data rest.CreateEmojiData) (emoji.Emoji, error)

func (*Shard) CreateGuildIntegration

func (s *Shard) CreateGuildIntegration(ctx context.Context, guildId uint64, data rest.CreateIntegrationData) error

func (*Shard) CreateGuildRole

func (s *Shard) CreateGuildRole(ctx context.Context, guildId uint64, data rest.GuildRoleData) (guild.Role, error)

func (*Shard) CreateMessage

func (s *Shard) CreateMessage(ctx context.Context, channelId uint64, content string) (message.Message, error)

func (*Shard) CreateMessageComplex

func (s *Shard) CreateMessageComplex(ctx context.Context, channelId uint64, data rest.CreateMessageData) (message.Message, error)

func (*Shard) CreateMessageEmbed

func (s *Shard) CreateMessageEmbed(ctx context.Context, channelId uint64, embed ...*embed.Embed) (message.Message, error)

func (*Shard) CreateMessageEmbedReply

func (s *Shard) CreateMessageEmbedReply(ctx context.Context, channelId uint64, e *embed.Embed, reference *message.MessageReference) (message.Message, error)

func (*Shard) CreateMessageReply

func (s *Shard) CreateMessageReply(ctx context.Context, channelId uint64, content string, reference *message.MessageReference) (message.Message, error)

func (*Shard) CreatePrivateThread

func (s *Shard) CreatePrivateThread(ctx context.Context, channelId uint64, name string, autoArchiveDuration uint16, invitable bool) (channel.Channel, error)

func (*Shard) CreatePublicThread

func (s *Shard) CreatePublicThread(ctx context.Context, channelId uint64, name string, autoArchiveDuration uint16) (channel.Channel, error)

func (*Shard) CreateReaction

func (s *Shard) CreateReaction(ctx context.Context, channelId, messageId uint64, emoji string) error

func (*Shard) CreateWebhook

func (s *Shard) CreateWebhook(ctx context.Context, channelId uint64, data rest.WebhookData) (guild.Webhook, error)

func (*Shard) DeleteAllReactions

func (s *Shard) DeleteAllReactions(ctx context.Context, channelId, messageId uint64) error

func (*Shard) DeleteAllReactionsEmoji

func (s *Shard) DeleteAllReactionsEmoji(ctx context.Context, channelId, messageId uint64, emoji string) error

func (*Shard) DeleteChannel

func (s *Shard) DeleteChannel(ctx context.Context, channelId uint64) (channel.Channel, error)

func (*Shard) DeleteChannelPermissions

func (s *Shard) DeleteChannelPermissions(ctx context.Context, channelId, overwriteId uint64) error

func (*Shard) DeleteGlobalCommand

func (s *Shard) DeleteGlobalCommand(ctx context.Context, applicationId, commandId uint64) error

func (*Shard) DeleteGuild

func (s *Shard) DeleteGuild(ctx context.Context, guildId uint64) error

func (*Shard) DeleteGuildCommand

func (s *Shard) DeleteGuildCommand(ctx context.Context, applicationId, guildId, commandId uint64) error

func (*Shard) DeleteGuildIntegration

func (s *Shard) DeleteGuildIntegration(ctx context.Context, guildId, integrationId uint64) error

func (*Shard) DeleteGuildRole

func (s *Shard) DeleteGuildRole(ctx context.Context, guildId, roleId uint64) error

func (*Shard) DeleteInvite

func (s *Shard) DeleteInvite(ctx context.Context, inviteCode string) (invite.Invite, error)

func (*Shard) DeleteMessage

func (s *Shard) DeleteMessage(ctx context.Context, channelId, messageId uint64) error

func (*Shard) DeleteOwnReaction

func (s *Shard) DeleteOwnReaction(ctx context.Context, channelId, messageId uint64, emoji string) error

func (*Shard) DeletePinnedChannelMessage

func (s *Shard) DeletePinnedChannelMessage(ctx context.Context, channelId, messageId uint64) error

func (*Shard) DeleteUserReaction

func (s *Shard) DeleteUserReaction(ctx context.Context, channelId, messageId, userId uint64, emoji string) error

func (*Shard) DeleteWebhook

func (s *Shard) DeleteWebhook(ctx context.Context, webhookId uint64) error

func (*Shard) EditBulkCommandPermissions

func (s *Shard) EditBulkCommandPermissions(ctx context.Context, applicationId, guildId uint64, data []rest.CommandWithPermissionsData) ([]rest.CommandWithPermissionsData, error)

func (*Shard) EditChannelPermissions

func (s *Shard) EditChannelPermissions(ctx context.Context, channelId uint64, updated channel.PermissionOverwrite) error

func (*Shard) EditCommandPermissions

func (s *Shard) EditCommandPermissions(ctx context.Context, applicationId, guildId, commandId uint64, data rest.CommandWithPermissionsData) (rest.CommandWithPermissionsData, error)

func (*Shard) EditMessage

func (s *Shard) EditMessage(ctx context.Context, channelId, messageId uint64, data rest.EditMessageData) (message.Message, error)

func (*Shard) EditWebhookMessage

func (s *Shard) EditWebhookMessage(ctx context.Context, webhookId uint64, webhookToken string, messageId uint64, data rest.WebhookEditBody) (message.Message, error)

func (*Shard) EnsureConnect

func (s *Shard) EnsureConnect()

func (*Shard) ExecuteEvent

func (s *Shard) ExecuteEvent(eventType events.EventType, data json.RawMessage)

func (*Shard) ExecuteWebhook

func (s *Shard) ExecuteWebhook(ctx context.Context, webhookId uint64, webhookToken string, wait bool, data rest.WebhookBody) (*message.Message, error)

if wait=true, a message object will be returned

func (*Shard) GetBulkCommandPermissions

func (s *Shard) GetBulkCommandPermissions(ctx context.Context, applicationId, guildId uint64) ([]rest.CommandWithPermissionsData, error)

func (*Shard) GetChannel

func (s *Shard) GetChannel(ctx context.Context, channelId uint64) (channel.Channel, error)

func (*Shard) GetChannelInvites

func (s *Shard) GetChannelInvites(ctx context.Context, channelId uint64) ([]invite.InviteMetadata, error)

func (*Shard) GetChannelMessage

func (s *Shard) GetChannelMessage(ctx context.Context, channelId, messageId uint64) (message.Message, error)

func (*Shard) GetChannelMessages

func (s *Shard) GetChannelMessages(ctx context.Context, channelId uint64, options rest.GetChannelMessagesData) ([]message.Message, error)

func (*Shard) GetChannelWebhooks

func (s *Shard) GetChannelWebhooks(ctx context.Context, channelId uint64) ([]guild.Webhook, error)

func (*Shard) GetCommandPermissions

func (s *Shard) GetCommandPermissions(ctx context.Context, applicationId, guildId, commandId uint64) (rest.CommandWithPermissionsData, error)

func (*Shard) GetCurrentUser

func (s *Shard) GetCurrentUser(ctx context.Context) (user.User, error)

func (*Shard) GetCurrentUserGuilds

func (s *Shard) GetCurrentUserGuilds(ctx context.Context, data rest.CurrentUserGuildsData) ([]guild.Guild, error)

func (*Shard) GetGlobalCommands

func (s *Shard) GetGlobalCommands(ctx context.Context, applicationId uint64) ([]interaction.ApplicationCommand, error)

func (*Shard) GetGuild

func (s *Shard) GetGuild(ctx context.Context, guildId uint64) (guild.Guild, error)

func (*Shard) GetGuildAuditLog

func (s *Shard) GetGuildAuditLog(ctx context.Context, guildId uint64, data rest.GetGuildAuditLogData) (auditlog.AuditLog, error)

func (*Shard) GetGuildBan

func (s *Shard) GetGuildBan(ctx context.Context, guildId, userId uint64) (guild.Ban, error)

func (*Shard) GetGuildBans

func (s *Shard) GetGuildBans(ctx context.Context, guildId uint64, data rest.GetGuildBansData) ([]guild.Ban, error)

func (*Shard) GetGuildChannels

func (s *Shard) GetGuildChannels(ctx context.Context, guildId uint64) ([]channel.Channel, error)

func (*Shard) GetGuildCommands

func (s *Shard) GetGuildCommands(ctx context.Context, applicationId, guildId uint64) ([]interaction.ApplicationCommand, error)

func (*Shard) GetGuildEmoji

func (s *Shard) GetGuildEmoji(ctx context.Context, guildId uint64, emojiId uint64) (emoji.Emoji, error)

func (*Shard) GetGuildIntegrations

func (s *Shard) GetGuildIntegrations(ctx context.Context, guildId uint64) ([]integration.Integration, error)

func (*Shard) GetGuildInvites

func (s *Shard) GetGuildInvites(ctx context.Context, guildId uint64) ([]invite.InviteMetadata, error)

func (*Shard) GetGuildMember

func (s *Shard) GetGuildMember(ctx context.Context, guildId, userId uint64) (member.Member, error)

func (*Shard) GetGuildPreview

func (s *Shard) GetGuildPreview(ctx context.Context, guildId uint64) (guild.GuildPreview, error)

func (*Shard) GetGuildPruneCount

func (s *Shard) GetGuildPruneCount(ctx context.Context, guildId uint64, days int) (int, error)

func (*Shard) GetGuildRoles

func (s *Shard) GetGuildRoles(ctx context.Context, guildId uint64) ([]guild.Role, error)

func (*Shard) GetGuildVanityUrl

func (s *Shard) GetGuildVanityUrl(ctx context.Context, guildId uint64) (invite.Invite, error)

returns invite object with only "code" and "uses" fields

func (*Shard) GetGuildVoiceRegions

func (s *Shard) GetGuildVoiceRegions(ctx context.Context, guildId uint64) ([]guild.VoiceRegion, error)

func (*Shard) GetGuildWebhooks

func (s *Shard) GetGuildWebhooks(ctx context.Context, guildId uint64) ([]guild.Webhook, error)

func (*Shard) GetGuildWidget

func (s *Shard) GetGuildWidget(ctx context.Context, guildId uint64) (guild.GuildWidget, error)

func (*Shard) GetInvite

func (s *Shard) GetInvite(ctx context.Context, inviteCode string, withCounts bool) (invite.Invite, error)

func (*Shard) GetPinnedMessages

func (s *Shard) GetPinnedMessages(ctx context.Context, channelId uint64) ([]message.Message, error)

func (*Shard) GetReactions

func (s *Shard) GetReactions(ctx context.Context, channelId, messageId uint64, emoji string, options rest.GetReactionsData) ([]user.User, error)

func (*Shard) GetThreadMember

func (s *Shard) GetThreadMember(ctx context.Context, channelId, userId uint64) (channel.ThreadMember, error)

func (*Shard) GetUser

func (s *Shard) GetUser(ctx context.Context, userId uint64) (user.User, error)

func (*Shard) GetUserConnections

func (s *Shard) GetUserConnections(ctx context.Context) ([]integration.Connection, error)

func (*Shard) GetWebhook

func (s *Shard) GetWebhook(ctx context.Context, webhookId uint64) (guild.Webhook, error)

func (*Shard) Heartbeat

func (s *Shard) Heartbeat() error

func (*Shard) HeartbeatLatency

func (s *Shard) HeartbeatLatency() int64

millis

func (*Shard) JoinThread

func (s *Shard) JoinThread(ctx context.Context, channelId uint64) error

func (*Shard) Kill

func (s *Shard) Kill() error

func (*Shard) LeaveGuild

func (s *Shard) LeaveGuild(ctx context.Context, guildId uint64) error

func (*Shard) LeaveThread

func (s *Shard) LeaveThread(ctx context.Context, channelId uint64) error

func (*Shard) ListActiveThreads

func (s *Shard) ListActiveThreads(ctx context.Context, guildId uint64) (rest.ThreadsResponse, error)

func (*Shard) ListGuildEmojis

func (s *Shard) ListGuildEmojis(ctx context.Context, guildId uint64) ([]emoji.Emoji, error)

func (*Shard) ListGuildMembers

func (s *Shard) ListGuildMembers(ctx context.Context, guildId uint64, data rest.ListGuildMembersData) ([]member.Member, error)

func (*Shard) ListJoinedPrivateArchivedThreads

func (s *Shard) ListJoinedPrivateArchivedThreads(ctx context.Context, channelId uint64, data rest.ListThreadsData) (rest.ThreadsResponse, error)

func (*Shard) ListPrivateArchivedThreads

func (s *Shard) ListPrivateArchivedThreads(ctx context.Context, channelId uint64, data rest.ListThreadsData) (rest.ThreadsResponse, error)

func (*Shard) ListPublicArchivedThreads

func (s *Shard) ListPublicArchivedThreads(ctx context.Context, channelId uint64, data rest.ListThreadsData) (rest.ThreadsResponse, error)

func (*Shard) ListThreadMembers

func (s *Shard) ListThreadMembers(ctx context.Context, channelId uint64) ([]channel.ThreadMember, error)

func (*Shard) ListVoiceRegions

func (s *Shard) ListVoiceRegions(ctx context.Context) ([]guild.VoiceRegion, error)

GetGuildVoiceRegions should be preferred, as it returns VIP servers if available to the guild

func (*Shard) ModifyChannel

func (s *Shard) ModifyChannel(ctx context.Context, channelId uint64, data rest.ModifyChannelData) (channel.Channel, error)

func (*Shard) ModifyCurrentUser

func (s *Shard) ModifyCurrentUser(ctx context.Context, data rest.ModifyUserData) (user.User, error)

func (*Shard) ModifyCurrentUserNick

func (s *Shard) ModifyCurrentUserNick(ctx context.Context, guildId uint64, nick string) error

func (*Shard) ModifyGlobalCommand

func (s *Shard) ModifyGlobalCommand(ctx context.Context, applicationId, commandId uint64, data rest.CreateCommandData) (interaction.ApplicationCommand, error)

func (*Shard) ModifyGlobalCommands

func (s *Shard) ModifyGlobalCommands(ctx context.Context, applicationId uint64, data []rest.CreateCommandData) ([]interaction.ApplicationCommand, error)

func (*Shard) ModifyGuild

func (s *Shard) ModifyGuild(ctx context.Context, guildId uint64, data rest.ModifyGuildData) (guild.Guild, error)

func (*Shard) ModifyGuildChannelPositions

func (s *Shard) ModifyGuildChannelPositions(ctx context.Context, guildId uint64, positions []rest.Position) error

func (*Shard) ModifyGuildCommand

func (s *Shard) ModifyGuildCommand(ctx context.Context, applicationId, guildId, commandId uint64, data rest.CreateCommandData) (interaction.ApplicationCommand, error)

func (*Shard) ModifyGuildCommands

func (s *Shard) ModifyGuildCommands(ctx context.Context, applicationId, guildId uint64, data []rest.CreateCommandData) ([]interaction.ApplicationCommand, error)

func (*Shard) ModifyGuildEmbed

func (s *Shard) ModifyGuildEmbed(ctx context.Context, guildId uint64, data guild.GuildEmbed) (guild.GuildEmbed, error)

func (*Shard) ModifyGuildEmoji

func (s *Shard) ModifyGuildEmoji(ctx context.Context, guildId, emojiId uint64, data rest.CreateEmojiData) (emoji.Emoji, error)

func (*Shard) ModifyGuildIntegration

func (s *Shard) ModifyGuildIntegration(ctx context.Context, guildId, integrationId uint64, data rest.ModifyIntegrationData) error

func (*Shard) ModifyGuildMember

func (s *Shard) ModifyGuildMember(ctx context.Context, guildId, userId uint64, data rest.ModifyGuildMemberData) error

func (*Shard) ModifyGuildRole

func (s *Shard) ModifyGuildRole(ctx context.Context, guildId, roleId uint64, data rest.GuildRoleData) (guild.Role, error)

func (*Shard) ModifyGuildRolePositions

func (s *Shard) ModifyGuildRolePositions(ctx context.Context, guildId uint64, positions []rest.Position) ([]guild.Role, error)

func (*Shard) ModifyWebhook

func (s *Shard) ModifyWebhook(ctx context.Context, webhookId uint64, data rest.ModifyWebhookData) (guild.Webhook, error)

func (*Shard) RemoveGuildBan

func (s *Shard) RemoveGuildBan(ctx context.Context, guildId, userId uint64) error

func (*Shard) RemoveGuildMember

func (s *Shard) RemoveGuildMember(ctx context.Context, guildId, userId uint64) error

func (*Shard) RemoveGuildMemberRole

func (s *Shard) RemoveGuildMemberRole(ctx context.Context, guildId, userId, roleId uint64) error

func (*Shard) RemoveThreadMember

func (s *Shard) RemoveThreadMember(ctx context.Context, channelId, userId uint64) error

func (*Shard) SearchGuildMembers

func (s *Shard) SearchGuildMembers(ctx context.Context, guildId uint64, data rest.SearchGuildMembersData) ([]member.Member, error)

func (*Shard) SelfAvatar

func (s *Shard) SelfAvatar(size int) string

func (*Shard) SelfId

func (s *Shard) SelfId() uint64

func (*Shard) SelfUsername

func (s *Shard) SelfUsername() string

func (*Shard) StartThreadWithMessage

func (s *Shard) StartThreadWithMessage(ctx context.Context, channelId, messageId uint64, data rest.StartThreadWithMessageData) (channel.Channel, error)

func (*Shard) StartThreadWithoutMessage

func (s *Shard) StartThreadWithoutMessage(ctx context.Context, channelId, messageId uint64, data rest.StartThreadWithoutMessageData) (channel.Channel, error)

func (*Shard) SyncGuildIntegration

func (s *Shard) SyncGuildIntegration(ctx context.Context, guildId, integrationId uint64) error

func (*Shard) TriggerTypingIndicator

func (s *Shard) TriggerTypingIndicator(ctx context.Context, channelId uint64) error

func (*Shard) UpdateStatus

func (s *Shard) UpdateStatus(data user.UpdateStatus) error

type ShardCount

type ShardCount struct {
	Total   int
	Lowest  int // Inclusive
	Highest int // Exclusive
}

type ShardManager

type ShardManager struct {
	Token string

	RateLimiter *ratelimit.Ratelimiter

	ShardOptions ShardOptions
	Shards       map[int]*Shard

	EventBus *events.EventBus
}

func NewShardManager

func NewShardManager(token string, shardOptions ShardOptions) *ShardManager

func (*ShardManager) Connect

func (sm *ShardManager) Connect()

func (*ShardManager) RegisterListeners

func (sm *ShardManager) RegisterListeners(listeners ...interface{})

func (*ShardManager) ShardForGuild

func (sm *ShardManager) ShardForGuild(guildId uint64) *Shard

func (*ShardManager) WaitForInterrupt

func (sm *ShardManager) WaitForInterrupt()

type ShardOptions

type ShardOptions struct {
	ShardCount           ShardCount
	CacheFactory         cache.CacheFactory
	RateLimitStore       ratelimit.RateLimitStore
	GuildSubscriptions   bool
	Presence             user.UpdateStatus
	Hooks                Hooks
	Debug                bool
	Intents              []intents.Intent
	LargeShardingBuckets int // defaults to 1. don't touch unless discord tell you to
}

type State

type State int
const (
	CONNECTED State = iota
	CONNECTING
	DISCONNECTING
	DEAD
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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