Enum twilight_model::gateway::CloseCode
source · #[non_exhaustive]#[repr(u16)]pub enum CloseCode {
Show 14 variants
UnknownError,
UnknownOpcode,
DecodeError,
NotAuthenticated,
AuthenticationFailed,
AlreadyAuthenticated,
InvalidSequence,
RateLimited,
SessionTimedOut,
InvalidShard,
ShardingRequired,
InvalidApiVersion,
InvalidIntents,
DisallowedIntents,
}
Expand description
Gateway close event codes.
See Discord Docs/Gateway Close Event Codes for more information.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
UnknownError
An unknown error occurred.
UnknownOpcode
An invalid opcode or payload for an opcode was sent.
DecodeError
An invalid payload was sent.
NotAuthenticated
A payload was sent prior to identifying.
AuthenticationFailed
An invalid token was sent when identifying.
AlreadyAuthenticated
Multiple identify payloads were sent.
InvalidSequence
An invalid sequence was sent for resuming.
RateLimited
Too many payloads were sent in a certain amount of time.
SessionTimedOut
The session timed out.
InvalidShard
An invalid shard was sent when identifying.
ShardingRequired
Sharding is required because there are too many guilds.
InvalidApiVersion
An invalid version for the gateway was sent.
InvalidIntents
An invalid intent was sent.
DisallowedIntents
A disallowed intent was sent, may need allowlisting.
Implementations§
source§impl CloseCode
impl CloseCode
sourcepub const fn can_reconnect(self) -> bool
pub const fn can_reconnect(self) -> bool
Whether the close code is one that allows reconnection of a shard.
Some close codes are considered fatal, meaning that using the same
gateway shard configuration would error. For example, the
AuthenticationFailed
close code occurs when the provided Discord bot
token is invalid, and so attempting to reconnect with the same token
would fail. On the other hand, a close code such as RateLimited
occurs when too many gateway commands are sent in a short time, and so
creating a new connection would succeed.
Refer to Discord Docs/Gateway Close Event Codes for more information.
Reconnectable close codes
UnknownError
DecodeError
NotAuthenticated
AlreadyAuthenticated
InvalidSequence
RateLimited
SessionTimedOut