#[non_exhaustive]#[repr(u16)]pub enum CloseCode {
Show 14 variants
UnknownError = 4_000,
UnknownOpcode = 4_001,
DecodeError = 4_002,
NotAuthenticated = 4_003,
AuthenticationFailed = 4_004,
AlreadyAuthenticated = 4_005,
InvalidSequence = 4_007,
RateLimited = 4_008,
SessionTimedOut = 4_009,
InvalidShard = 4_010,
ShardingRequired = 4_011,
InvalidApiVersion = 4_012,
InvalidIntents = 4_013,
DisallowedIntents = 4_014,
}
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 = 4_000
An unknown error occurred.
UnknownOpcode = 4_001
An invalid opcode or payload for an opcode was sent.
DecodeError = 4_002
An invalid payload was sent.
NotAuthenticated = 4_003
A payload was sent prior to identifying.
AuthenticationFailed = 4_004
An invalid token was sent when identifying.
AlreadyAuthenticated = 4_005
Multiple identify payloads were sent.
InvalidSequence = 4_007
An invalid sequence was sent for resuming.
RateLimited = 4_008
Too many payloads were sent in a certain amount of time.
SessionTimedOut = 4_009
The session timed out.
InvalidShard = 4_010
An invalid shard was sent when identifying.
ShardingRequired = 4_011
Sharding is required because there are too many guilds.
InvalidApiVersion = 4_012
An invalid version for the gateway was sent.
InvalidIntents = 4_013
An invalid intent was sent.
DisallowedIntents = 4_014
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