glyde/event/guilds
GUILD_* dispatches: the guild coming and going, its members, roles, bans
and emojis. Decoders take the constructor to build, so Event stays out.
Types
pub type MembersChunk {
MembersChunk(
guild_id: id.Id(id.Guild),
members: List(member.GuildMember),
chunk_index: Int,
chunk_count: Int,
not_found: List(id.Id(id.User)),
nonce: option.Option(String),
)
}
Constructors
-
MembersChunk( guild_id: id.Id(id.Guild), members: List(member.GuildMember), chunk_index: Int, chunk_count: Int, not_found: List(id.Id(id.User)), nonce: option.Option(String), )Arguments
- members
-
At most 1000. glyde does not reassemble the chunks: count them with
chunk_indexandchunk_count. - not_found
-
Echoes the request back, so this is whatever the caller sent, a real snowflake or not.
- nonce
-
Absent when the request’s nonce was over 32 bytes, which Discord drops silently.
Values
pub fn create_decoder(
available available: fn(guild.Guild) -> event,
unavailable unavailable: fn(id.Id(id.Guild)) -> event,
) -> decode.Decoder(event)
GUILD_CREATE. On the VALUE of unavailable: true is a two-key stub,
absent or false is the whole guild. GUILD_DELETE goes on the key instead.
pub fn delete_decoder(
outage outage: fn(id.Id(id.Guild)) -> event,
removed removed: fn(id.Id(id.Guild)) -> event,
) -> decode.Decoder(event)
GUILD_DELETE. On the PRESENCE of unavailable, not its value. The two are
different events: an outage stays in the cache, a removal leaves it.
pub fn emojis_update_decoder(
build: fn(id.Id(id.Guild), List(emoji.GuildEmoji)) -> event,
) -> decode.Decoder(event)
emojis is required, unlike nearly every other list here: the array
replaces the guild’s whole set, so a missing key must not read as [].
pub fn member_decoder(
build: fn(id.Id(id.Guild), member.GuildMember) -> event,
) -> decode.Decoder(event)
GUILD_MEMBER_ADD and GUILD_MEMBER_UPDATE: d is the member object itself
with guild_id bolted on.
pub fn members_chunk_decoder() -> decode.Decoder(MembersChunk)
pub fn role_decoder(
build: fn(id.Id(id.Guild), role.Role) -> event,
) -> decode.Decoder(event)
GUILD_ROLE_CREATE and GUILD_ROLE_UPDATE.
pub fn role_delete_decoder(
build: fn(id.Id(id.Guild), id.Id(id.Role)) -> event,
) -> decode.Decoder(event)
pub fn user_decoder(
build: fn(id.Id(id.Guild), user.User) -> event,
) -> decode.Decoder(event)
GUILD_MEMBER_REMOVE, GUILD_BAN_ADD and GUILD_BAN_REMOVE, which share the
shape {"guild_id": .., "user": {..}}.