Documentation
¶
Index ¶
- Constants
- Variables
- func ShardForGuild(guildID string, shardCount int) (int, error)
- type APIError
- type Channel
- type Client
- func (c *Client) Channel(ctx context.Context, channelID string) (Channel, error)
- func (c *Client) DeferInteraction(ctx context.Context, interaction Interaction, ephemeral bool) error
- func (c *Client) Gateway(ctx context.Context, handler EventHandler) error
- func (c *Client) GatewayEndpoint() string
- func (c *Client) NewSession(options SessionOptions) *Session
- func (c *Client) NewShardManager(options ShardManagerOptions) (*ShardManager, error)
- func (c *Client) REST(ctx context.Context, method, path string, body, dest any) error
- func (c *Client) RespondToInteraction(ctx context.Context, interaction Interaction, options MessageOptions, ...) error
- func (c *Client) SendInteractionFollowup(ctx context.Context, interaction Interaction, options MessageOptions, ...) (Message, error)
- func (c *Client) SendMessage(ctx context.Context, channelID, content, replyTo string) (Message, error)
- func (c *Client) SendMessageWithOptions(ctx context.Context, channelID string, options MessageOptions) (Message, error)
- type CloseError
- type Config
- type Embed
- type EmbedAuthor
- type EmbedField
- type EmbedFooter
- type EmbedMedia
- type Event
- type EventHandler
- type Guild
- type Interaction
- type Message
- type MessageCreate
- type MessageOptions
- type Session
- func (s *Session) JoinVoice(ctx context.Context, guildID, channelID string, options VoiceJoin) (VoiceServerUpdate, error)
- func (s *Session) LeaveVoice(guildID, connectionID string) error
- func (s *Session) Ready() bool
- func (s *Session) ResolveGuild(ctx context.Context, channelID string) (string, error)
- func (s *Session) Run(ctx context.Context) error
- func (s *Session) Send(opcode int, data any) error
- func (s *Session) ShardID() int
- func (s *Session) State() *State
- func (s *Session) Voice(guildID string) (VoiceServerUpdate, bool)
- type SessionOptions
- type ShardManager
- func (m *ShardManager) ForGuild(guildID string) (*Session, error)
- func (m *ShardManager) JoinVoice(ctx context.Context, guildID, channelID string, options VoiceJoin) (VoiceServerUpdate, error)
- func (m *ShardManager) LeaveVoice(guildID, connectionID string) error
- func (m *ShardManager) Ready() bool
- func (m *ShardManager) ResolveGuild(ctx context.Context, channelID string) (string, error)
- func (m *ShardManager) Run(ctx context.Context) error
- func (m *ShardManager) Shard(shardID int) (*Session, bool)
- func (m *ShardManager) ShardCount() int
- func (m *ShardManager) Shards() []*Session
- func (m *ShardManager) Voice(guildID string) (VoiceServerUpdate, bool)
- type ShardManagerOptions
- type State
- type User
- type VoiceJoin
- type VoiceServerUpdate
- type VoiceState
Constants ¶
View Source
const ( EventReady = "READY" EventResumed = "RESUMED" EventGuildCreate = "GUILD_CREATE" EventGuildDelete = "GUILD_DELETE" EventChannelCreate = "CHANNEL_CREATE" EventChannelUpdate = "CHANNEL_UPDATE" EventChannelDelete = "CHANNEL_DELETE" EventMessageCreate = "MESSAGE_CREATE" EventInteractionCreate = "INTERACTION_CREATE" EventVoiceStateUpdate = "VOICE_STATE_UPDATE" EventVoiceServerUpdate = "VOICE_SERVER_UPDATE" )
View Source
const ( OpDispatch = 0 OpHeartbeat = 1 OpIdentify = 2 OpVoiceStateUpdate = 4 OpResume = 6 OpReconnect = 7 OpInvalidSession = 9 OpHello = 10 OpHeartbeatAck = 11 )
View Source
const ( MessageTypeDefault = 0 MessageTypeReply = 19 )
View Source
const DefaultIdentifyInterval = 5 * time.Second
View Source
const (
DefaultOrigin = "https://micup.gg"
)
View Source
const Version = "0.3.0"
Variables ¶
View Source
var ( ErrReconnectRequested = errors.New("Micup Gateway requested reconnect") ErrSessionInvalidated = errors.New("Micup Gateway invalidated the session") ErrGatewayClosed = errors.New("Micup Gateway is disconnected") )
View Source
var ( ErrVoiceJoinPending = errors.New("Micup voice join is already pending") ErrVoiceGrant = errors.New("invalid Micup voice grant") ErrVoiceMoved = errors.New("Micup voice channel changed during join") )
View Source
var ( ErrShardNotOwned = errors.New("Micup guild belongs to a shard this manager does not run") ErrShardManagerRunning = errors.New("Micup shard manager is already running") )
View Source
var ErrNotReady = errors.New("Micup Gateway session is not ready")
Functions ¶
Types ¶
type Client ¶
type Client struct {
BotID string
MessageContentEnabled *bool
// contains filtered or unexported fields
}
func (*Client) DeferInteraction ¶ added in v0.2.0
func (*Client) GatewayEndpoint ¶ added in v0.2.0
func (*Client) NewSession ¶ added in v0.3.0
func (c *Client) NewSession(options SessionOptions) *Session
func (*Client) NewShardManager ¶ added in v0.3.0
func (c *Client) NewShardManager(options ShardManagerOptions) (*ShardManager, error)
func (*Client) RespondToInteraction ¶ added in v0.2.0
func (c *Client) RespondToInteraction(ctx context.Context, interaction Interaction, options MessageOptions, ephemeral bool) error
func (*Client) SendInteractionFollowup ¶ added in v0.2.0
func (c *Client) SendInteractionFollowup(ctx context.Context, interaction Interaction, options MessageOptions, ephemeral bool) (Message, error)
func (*Client) SendMessage ¶
func (*Client) SendMessageWithOptions ¶ added in v0.2.0
type CloseError ¶ added in v0.3.0
func (*CloseError) Error ¶ added in v0.3.0
func (e *CloseError) Error() string
func (*CloseError) Fatal ¶ added in v0.3.0
func (e *CloseError) Fatal() bool
type Embed ¶ added in v0.2.0
type Embed struct {
Title string `json:"title,omitempty"`
Type string `json:"type,omitempty"`
Description string `json:"description,omitempty"`
URL string `json:"url,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
Color int `json:"color,omitempty"`
Image *EmbedMedia `json:"image,omitempty"`
Thumbnail *EmbedMedia `json:"thumbnail,omitempty"`
Author *EmbedAuthor `json:"author,omitempty"`
Fields []EmbedField `json:"fields,omitempty"`
}
type EmbedAuthor ¶ added in v0.2.0
type EmbedField ¶ added in v0.2.0
type EmbedFooter ¶ added in v0.2.0
type EmbedFooter struct {
}
type EmbedMedia ¶ added in v0.2.0
type EmbedMedia struct {
URL string `json:"url"`
}
type Event ¶
type Event struct {
Name string
Sequence *int64
ShardID int
Data json.RawMessage
// contains filtered or unexported fields
}
type Interaction ¶ added in v0.2.0
type Interaction struct {
ID string `json:"id"`
ApplicationID string `json:"application_id"`
Type int `json:"type"`
Data json.RawMessage `json:"data,omitempty"`
GuildID string `json:"guild_id,omitempty"`
ChannelID string `json:"channel_id,omitempty"`
Token string `json:"token"`
Version int `json:"version,omitempty"`
Member json.RawMessage `json:"member,omitempty"`
User json.RawMessage `json:"user,omitempty"`
}
type MessageCreate ¶
type MessageOptions ¶ added in v0.2.0
type Session ¶ added in v0.3.0
type Session struct {
// contains filtered or unexported fields
}
func (*Session) LeaveVoice ¶ added in v0.3.0
func (*Session) ResolveGuild ¶ added in v0.3.0
type SessionOptions ¶ added in v0.3.0
type ShardManager ¶ added in v0.3.0
type ShardManager struct {
// contains filtered or unexported fields
}
func (*ShardManager) ForGuild ¶ added in v0.3.0
func (m *ShardManager) ForGuild(guildID string) (*Session, error)
func (*ShardManager) JoinVoice ¶ added in v0.3.0
func (m *ShardManager) JoinVoice(ctx context.Context, guildID, channelID string, options VoiceJoin) (VoiceServerUpdate, error)
func (*ShardManager) LeaveVoice ¶ added in v0.3.0
func (m *ShardManager) LeaveVoice(guildID, connectionID string) error
func (*ShardManager) Ready ¶ added in v0.3.0
func (m *ShardManager) Ready() bool
func (*ShardManager) ResolveGuild ¶ added in v0.3.0
func (*ShardManager) Shard ¶ added in v0.3.0
func (m *ShardManager) Shard(shardID int) (*Session, bool)
func (*ShardManager) ShardCount ¶ added in v0.3.0
func (m *ShardManager) ShardCount() int
func (*ShardManager) Shards ¶ added in v0.3.0
func (m *ShardManager) Shards() []*Session
func (*ShardManager) Voice ¶ added in v0.3.0
func (m *ShardManager) Voice(guildID string) (VoiceServerUpdate, bool)
type ShardManagerOptions ¶ added in v0.3.0
type ShardManagerOptions struct {
ShardCount int
ShardIDs []int
IdentifyInterval time.Duration
Session SessionOptions
}
type State ¶ added in v0.3.0
type State struct {
// contains filtered or unexported fields
}
func (*State) BotVoiceChannel ¶ added in v0.3.0
func (*State) GuildForChannel ¶ added in v0.3.0
func (*State) VoiceChannel ¶ added in v0.3.0
type VoiceServerUpdate ¶
type VoiceState ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.