glyde/model/ready
READY, the first dispatch on a fresh session.
The host-facing view, and nothing the connection reads.
glyde/gateway/ready takes session_id and resume_gateway_url off the
same payload with its own small decode, so a bug in the tens of kilobytes
here cannot cost a session.
Types
The privileged-intent flags are the ones a bot reads here. Discord’s
application-flags table gives each of those intents two bits, and either
one means it is on: the plain bit is approval for a bot in 100 or more
servers, the Limited bit is the Bot-page toggle a bot under 100 servers
sets itself. With neither, IDENTIFY asking for that intent closes the
socket with 4014.
pub type ApplicationFlag {
AutoModerationRuleCreateBadge
GatewayPresence
GatewayPresenceLimited
GatewayGuildMembers
GatewayGuildMembersLimited
VerificationPendingGuildLimit
Embedded
GatewayMessageContent
GatewayMessageContentLimited
ApplicationCommandBadge
}
Constructors
-
AutoModerationRuleCreateBadge -
GatewayPresence -
GatewayPresenceLimited -
GatewayGuildMembers -
GatewayGuildMembersLimited -
VerificationPendingGuildLimit -
Embedded -
GatewayMessageContent -
GatewayMessageContentLimited -
ApplicationCommandBadge
pub type ApplicationFlags =
flags.Flags(ApplicationFlag)
The two application fields READY sends, not the full REST object.
pub type PartialApplication {
PartialApplication(
id: id.Id(id.Application),
flags: flags.Flags(ApplicationFlag),
)
}
Constructors
-
PartialApplication( id: id.Id(id.Application), flags: flags.Flags(ApplicationFlag), )
pub type Ready {
Ready(
version: Int,
me: user.CurrentUser,
guilds: List(id.Id(id.Guild)),
session_id: String,
resume_gateway_url: String,
shard: option.Option(frame.Sharding),
application: option.Option(PartialApplication),
)
}
Constructors
-
Ready( version: Int, me: user.CurrentUser, guilds: List(id.Id(id.Guild)), session_id: String, resume_gateway_url: String, shard: option.Option(frame.Sharding), application: option.Option(PartialApplication), )Arguments
- version
-
Should be 10. Anything else means the gateway URL lost its
?v=. - me
-
The bot’s own user, and the only user object that carries
email. - guilds
-
Every guild the bot is in, all unavailable until their GUILD_CREATE.
- session_id
-
Opaque, not a snowflake.
- resume_gateway_url
-
Reconnect here, not to the cached
GET /gatewayurl. - shard
-
Absent unless IDENTIFY sent a shard tuple.
- application
-
Documented as required, and often missing.
Values
pub fn decoder() -> decode.Decoder(Ready)
pub fn has_flag(
bits: flags.Flags(ApplicationFlag),
flag: ApplicationFlag,
) -> Bool
pub fn partial_application_decoder() -> decode.Decoder(
PartialApplication,
)
flags is required, not defaulted: a 0 reads as “no privileged intents
enabled”, which is a claim we cannot make from a payload that never said.
Failing sends the whole object through soft_field to None instead.