Crux v2020-03-17 17:55:51Z Crux.Base.Processor View Source
Module processing gateway packets into event/0
s making necessary cache lookups / insertions.
Link to this section Summary
Types
Emitted whenever a channel was created.
Emitted whenever a channel was deleted.
The id of a channel.
Emitted whenever a message was pinned or unpinned.
Emitted whenever a channel was updated.
Union type of all available events.
Emitted whenever a user was banned from a guild.
Emitted whenever a user was unbanned from a guild.
Emitted whenever the client joined a guild.
Emitted whenever the client left a guild or a guild became unavailable.
Emitted whenever a guild's emojis updated.
The id of a guild.
Emitted whenever one of a guild's integration was updated.
Emitted whenever a user joined a guild.
Emitted whenever a user left a guild.
This includes kicks and bans.
Emitted whenever a guild member was updated.
Emitted whenever a chunk of guild members was received.
Emitted whenever a role was created.
Emitted whenever a role was deleted.
Emitted whenever a role was updated.
Emitted whenever a guild updated.
Emitted whenever a message was created. (Sent to a channel)
Emitted whenever a bulk of messages was deleted.
Emitted whenever a channel was deleted.
The id of a message.
Emitted whenever a reaction was added to a message.
Emitted whenever a user explicitly removed all reactions from a message.
Emitted whenever a reaction was removed from a message.
Emitted whenever a message was updated.
Emitted whenever a user's presence or any of the user's properties updated.
Emitted when a gateway connection completed the initial handshake with the gateway.
The guilds are not yet sent, those are partial unavailable guilds!
Emitted whenever a gateway connection resumed after unexpectedly disconnecting.
The id of a role.
The id of a shard.
A discord snowflake.
See t:Crux.Rest.Snowflake/0
for more information.
Emitted whenever a user started typing in a channel.
The id of a user.
Emitted whenever properties about the current user changed.
Emitted whenever guild's voice server was updated.
Emitted whenever the voice state of a member changed.
Emitted whenever a channel's webhook was created, updated, or deleted.
Functions
Processes the type
(t
value of a packet) along its data
(d
portion of a packet).
This will do necessary transformation, cache lookups, and cache insertions.
Link to this section Types
channel_create_event()
View Source
channel_create_event() ::
{:CHANNEL_CREATE, Crux.Structs.Channel.t(), shard_id()}
channel_create_event() :: {:CHANNEL_CREATE, Crux.Structs.Channel.t(), shard_id()}
Emitted whenever a channel was created.
For more information see Discord Docs.
channel_delete_event()
View Source
channel_delete_event() ::
{:CHANNEL_DELETE, Crux.Structs.Channel.t(), shard_id()}
channel_delete_event() :: {:CHANNEL_DELETE, Crux.Structs.Channel.t(), shard_id()}
Emitted whenever a channel was deleted.
For more information see Discord Docs.
channel_id()
View Source
channel_id() :: snowflake()
channel_id() :: snowflake()
The id of a channel.
channel_pins_update_event()
View Source
channel_pins_update_event() ::
{:CHANNEL_PINS_UPDATE, {Crux.Structs.Channel.t() | channel_id(), String.t()},
shard_id()}
channel_pins_update_event() :: {:CHANNEL_PINS_UPDATE, {Crux.Structs.Channel.t() | channel_id(), String.t()}, shard_id()}
Emitted whenever a message was pinned or unpinned.
Emits the channel id if the channel was uncached.
> The second element of the tuple is the timestamp of when the last pinned message was pinned.
> The timestamp will be the Unix Epoch if last pinned message was removed.
For more information see Discord Docs.
channel_update_event()
View Source
channel_update_event() ::
{:CHANNEL_UPDATE, {Crux.Structs.Channel.t() | nil, Crux.Structs.Channel.t()},
shard_id()}
channel_update_event() :: {:CHANNEL_UPDATE, {Crux.Structs.Channel.t() | nil, Crux.Structs.Channel.t()}, shard_id()}
Emitted whenever a channel was updated.
Emits nil if the channel was uncached previously.
For more information see Discord Docs.
event()
View Source
event() ::
ready_event()
| resumed_event()
| channel_create_event()
| channel_update_event()
| channel_update_event()
| channel_delete_event()
| channel_pins_update_event()
| guild_create_event()
| guild_update_event()
| guild_delete_event()
| guild_ban_add_event()
| guild_ban_remove_event()
| guild_emojis_update_event()
| guild_integrations_update_event()
| guild_member_add_event()
| guild_member_remove_event()
| guild_member_update_event()
| guild_members_chunk_event()
| guild_role_create_event()
| guild_role_update_event()
| guild_role_delete_event()
| message_create_event()
| message_update_event()
| message_delete_event()
| message_delete_bulk_event()
| message_reaction_add_event()
| message_reaction_remove_event()
| message_reaction_remove_all_event()
| presence_update_event()
| typing_start_event()
| user_update_event()
| voice_state_update_event()
| voice_server_update_event()
| webhooks_update_event()
event() :: ready_event() | resumed_event() | channel_create_event() | channel_update_event() | channel_update_event() | channel_delete_event() | channel_pins_update_event() | guild_create_event() | guild_update_event() | guild_delete_event() | guild_ban_add_event() | guild_ban_remove_event() | guild_emojis_update_event() | guild_integrations_update_event() | guild_member_add_event() | guild_member_remove_event() | guild_member_update_event() | guild_members_chunk_event() | guild_role_create_event() | guild_role_update_event() | guild_role_delete_event() | message_create_event() | message_update_event() | message_delete_event() | message_delete_bulk_event() | message_reaction_add_event() | message_reaction_remove_event() | message_reaction_remove_all_event() | presence_update_event() | typing_start_event() | user_update_event() | voice_state_update_event() | voice_server_update_event() | webhooks_update_event()
Union type of all available events.
guild_ban_add_event()
View Source
guild_ban_add_event() ::
{:GUILD_BAN_ADD,
{Crux.Structs.User.t() | Crux.Structs.Member.t(),
Crux.Structs.Guild.t() | guild_id()}, shard_id()}
guild_ban_add_event() :: {:GUILD_BAN_ADD, {Crux.Structs.User.t() | Crux.Structs.Member.t(), Crux.Structs.Guild.t() | guild_id()}, shard_id()}
Emitted whenever a user was banned from a guild.
Emits a user if the member was not cached.
Emits the guild id if the guild was not cached.
For more information see Discord Docs.
guild_ban_remove_event()
View Source
guild_ban_remove_event() ::
{:GUILD_BAN_REMOVE,
{Crux.Structs.User.t(), Crux.Structs.Guild.t() | guild_id()}, shard_id()}
guild_ban_remove_event() :: {:GUILD_BAN_REMOVE, {Crux.Structs.User.t(), Crux.Structs.Guild.t() | guild_id()}, shard_id()}
Emitted whenever a user was unbanned from a guild.
Emits the guild id if the guild was not cached.
For more information see Discord Docs.
guild_create_event()
View Source
guild_create_event() :: {:GUILD_CREATE, Crux.Structs.Guild.t(), shard_id()}
guild_create_event() :: {:GUILD_CREATE, Crux.Structs.Guild.t(), shard_id()}
Emitted whenever the client joined a guild.
For more information see Discord Docs.
guild_delete_event()
View Source
guild_delete_event() :: {:GUILD_DELETE, Crux.Structs.Guild.t(), shard_id()}
guild_delete_event() :: {:GUILD_DELETE, Crux.Structs.Guild.t(), shard_id()}
Emitted whenever the client left a guild or a guild became unavailable.
For more information see Discord Docs.
guild_emojis_update_event()
View Source
guild_emojis_update_event() ::
{:GUILD_EMOJIS_UPDATE, {[Crux.Structs.Emoji.t()], [Crux.Structs.Emoji.t()]},
shard_id()}
guild_emojis_update_event() :: {:GUILD_EMOJIS_UPDATE, {[Crux.Structs.Emoji.t()], [Crux.Structs.Emoji.t()]}, shard_id()}
Emitted whenever a guild's emojis updated.
The first element is a list of the emojis before the update.
The second element is al ist of the emojis after the update.
For more information see Discord Docs.
guild_id()
View Source
guild_id() :: snowflake()
guild_id() :: snowflake()
The id of a guild.
guild_integrations_update_event()
View Source
guild_integrations_update_event() ::
{:GUILD_INTEGRATIONS_UPDATE, Crux.Structs.Guild.t() | guild_id(), shard_id()}
guild_integrations_update_event() :: {:GUILD_INTEGRATIONS_UPDATE, Crux.Structs.Guild.t() | guild_id(), shard_id()}
Emitted whenever one of a guild's integration was updated.
Emits the guild id if the guild was not cached.
For more information see Discord Docs.
guild_member_add_event()
View Source
guild_member_add_event() ::
{:GUILD_MEMBER_ADD, Crux.Structs.Member.t(), shard_id()}
guild_member_add_event() :: {:GUILD_MEMBER_ADD, Crux.Structs.Member.t(), shard_id()}
Emitted whenever a user joined a guild.
For more information see Discord Docs.
guild_member_remove_event()
View Source
guild_member_remove_event() ::
{:GUILD_MEMBER_REMOVE,
{Crux.Structs.User.t() | Crux.Structs.Member.t(),
Crux.Structs.Guild.t() | guild_id()}, shard_id()}
guild_member_remove_event() :: {:GUILD_MEMBER_REMOVE, {Crux.Structs.User.t() | Crux.Structs.Member.t(), Crux.Structs.Guild.t() | guild_id()}, shard_id()}
Emitted whenever a user left a guild.
This includes kicks and bans.
Emits the user if the member was not cached.
Emits the guild id if the guild was not cached.
For more information see Discord Docs.
guild_member_update_event()
View Source
guild_member_update_event() ::
{:GUILD_MEMBER_UPDATE,
{Crux.Structs.Member.t() | nil, Crux.Structs.Member.t()}, shard_id()}
guild_member_update_event() :: {:GUILD_MEMBER_UPDATE, {Crux.Structs.Member.t() | nil, Crux.Structs.Member.t()}, shard_id()}
Emitted whenever a guild member was updated.
Emits nil as the member before the updated if it was uncached.
For more information see Discord Docs.
guild_members_chunk_event()
View Source
guild_members_chunk_event() ::
{:GUILD_MEMBERS_CHUNK,
%{
members: [Crux.Structs.Member.t()],
presences: [Crux.Structs.Presence.t()],
not_found: [Crux.Structs.Snowflake.t()]
}, shard_id()}
guild_members_chunk_event() :: {:GUILD_MEMBERS_CHUNK, %{ members: [Crux.Structs.Member.t()], presences: [Crux.Structs.Presence.t()], not_found: [Crux.Structs.Snowflake.t()] }, shard_id()}
Emitted whenever a chunk of guild members was received.
For more information see Crux.Gateway.Command.request_guild_members/2
and Discord Docs.
guild_role_create_event()
View Source
guild_role_create_event() ::
{:GUILD_ROLE_CREATE, Crux.Structs.Role.t(), shard_id()}
guild_role_create_event() :: {:GUILD_ROLE_CREATE, Crux.Structs.Role.t(), shard_id()}
Emitted whenever a role was created.
For more information see Discord Docs.
guild_role_delete_event()
View Source
guild_role_delete_event() ::
{:GUILD_ROLE_DELETE,
Crux.Structs.Role.t() | {role_id(), Crux.Structs.Guild.t() | guild_id()},
shard_id()}
guild_role_delete_event() :: {:GUILD_ROLE_DELETE, Crux.Structs.Role.t() | {role_id(), Crux.Structs.Guild.t() | guild_id()}, shard_id()}
Emitted whenever a role was deleted.
Emits a tuple of role and guild or guild id if uncached.
For more information see Discord Docs.
guild_role_update_event()
View Source
guild_role_update_event() ::
{:GUILD_ROLE_UPDATE, {Crux.Structs.Role.t() | nil, Crux.Structs.Role.t()},
shard_id()}
guild_role_update_event() :: {:GUILD_ROLE_UPDATE, {Crux.Structs.Role.t() | nil, Crux.Structs.Role.t()}, shard_id()}
Emitted whenever a role was updated.
Emits nil as the role before the update if it was uncached previously.
For more information see Discord Docs.
guild_update_event()
View Source
guild_update_event() ::
{:GUILD_UPDATE, {Crux.Structs.Guild.t() | nil, Crux.Structs.Guild.t()},
shard_id()}
guild_update_event() :: {:GUILD_UPDATE, {Crux.Structs.Guild.t() | nil, Crux.Structs.Guild.t()}, shard_id()}
Emitted whenever a guild updated.
Emits nil as guild before the update if it was uncached previously.
Fore more information see Discord Docs.
message_create_event()
View Source
message_create_event() ::
{:MESSAGE_CREATE, Crux.Structs.Message.t(), shard_id()}
message_create_event() :: {:MESSAGE_CREATE, Crux.Structs.Message.t(), shard_id()}
Emitted whenever a message was created. (Sent to a channel)
For more information see Discord Docs.
message_delete_bulk_event()
View Source
message_delete_bulk_event() ::
{:MESSAGE_DELETE_BULK,
{[message_id()], Crux.Structs.Channel.t() | {channel_id(), guild_id()}},
shard_id()}
message_delete_bulk_event() :: {:MESSAGE_DELETE_BULK, {[message_id()], Crux.Structs.Channel.t() | {channel_id(), guild_id()}}, shard_id()}
Emitted whenever a bulk of messages was deleted.
Emits a tuple of channel and guild id if the channel was not cached.
For more information see Discord Docs.
message_delete_event()
View Source
message_delete_event() ::
{:MESSAGE_DELETE,
{message_id(), Crux.Structs.Channel.t() | {channel_id(), guild_id()}},
shard_id()}
message_delete_event() :: {:MESSAGE_DELETE, {message_id(), Crux.Structs.Channel.t() | {channel_id(), guild_id()}}, shard_id()}
Emitted whenever a channel was deleted.
Emits a tuple of channel and guild id if the channel was not cached.
For more information see Discord Docs.
message_id()
View Source
message_id() :: snowflake()
message_id() :: snowflake()
The id of a message.
message_reaction_add_event()
View Source
message_reaction_add_event() ::
{:MESSAGE_REACTION_ADD,
{Crux.Structs.User.t() | user_id(),
Crux.Structs.Channel.t() | {channel_id(), guild_id()}, message_id(),
Crux.Structs.Emoji.t()}, shard_id()}
message_reaction_add_event() :: {:MESSAGE_REACTION_ADD, {Crux.Structs.User.t() | user_id(), Crux.Structs.Channel.t() | {channel_id(), guild_id()}, message_id(), Crux.Structs.Emoji.t()}, shard_id()}
Emitted whenever a reaction was added to a message.
Emits the user id if the user was not cached.
Emits a tuple of channel and guild id if the channel was not cached.
For more information see Discord Docs.
message_reaction_remove_all_event()
View Source
message_reaction_remove_all_event() ::
{:MESSAGE_REACTION_REMOVE_ALL,
{message_id(), Crux.Structs.Channel.t() | {channel_id(), guild_id()}}}
message_reaction_remove_all_event() :: {:MESSAGE_REACTION_REMOVE_ALL, {message_id(), Crux.Structs.Channel.t() | {channel_id(), guild_id()}}}
Emitted whenever a user explicitly removed all reactions from a message.
For more information see Discord Docs.
message_reaction_remove_event()
View Source
message_reaction_remove_event() ::
{:MESSAGE_REACTION_REMOVE,
{Crux.Structs.User.t() | user_id(),
Crux.Structs.Channel.t() | {channel_id(), guild_id() | nil}, message_id(),
Crux.Structs.Emoji.t()}, shard_id()}
message_reaction_remove_event() :: {:MESSAGE_REACTION_REMOVE, {Crux.Structs.User.t() | user_id(), Crux.Structs.Channel.t() | {channel_id(), guild_id() | nil}, message_id(), Crux.Structs.Emoji.t()}, shard_id()}
Emitted whenever a reaction was removed from a message.
Emits the user id if the user was not cached.
Emits a tuple of channel and guild id if the channel was not cached.
For more information see Discord Docs.
message_update_event()
View Source
message_update_event() ::
{:MESSAGE_UPDATE,
Crux.Structs.Message.t()
| %{channel_id: channel_id(), id: message_id(), embeds: [term()]},
shard_id()}
message_update_event() :: {:MESSAGE_UPDATE, Crux.Structs.Message.t() | %{channel_id: channel_id(), id: message_id(), embeds: [term()]}, shard_id()}
Emitted whenever a message was updated.
Emits a partial object for "embed update"s (discord auto embedding websites/images/videos)
Or the full new message for "actual" message updates.
For more information see Discord Docs.
presence_update_event()
View Source
presence_update_event() ::
{:PRESENCE_UPDATE,
{Crux.Structs.Presence.t() | nil, Crux.Structs.Presence.t()}, shard_id()}
| {:PRESENCE_UPDATE, {Crux.Structs.User.t() | nil, Crux.Structs.User.t()},
shard_id()}
presence_update_event() :: {:PRESENCE_UPDATE, {Crux.Structs.Presence.t() | nil, Crux.Structs.Presence.t()}, shard_id()} | {:PRESENCE_UPDATE, {Crux.Structs.User.t() | nil, Crux.Structs.User.t()}, shard_id()}
Emitted whenever a user's presence or any of the user's properties updated.
Emits presences for presence updates.
Emits users for user updates.
For more information see Discord Docs.
ready_event()
View Source
ready_event() ::
{:READY,
%{
v: integer(),
user: Crux.Structs.User.t(),
private_channels: [],
guilds: [Crux.Structs.Guild.t()],
session_id: String.t()
}, shard_id()}
ready_event() :: {:READY, %{ v: integer(), user: Crux.Structs.User.t(), private_channels: [], guilds: [Crux.Structs.Guild.t()], session_id: String.t() }, shard_id()}
Emitted when a gateway connection completed the initial handshake with the gateway.
The guilds are not yet sent, those are partial unavailable guilds!
For more information see Discord Docs.
resumed_event() View Source
Emitted whenever a gateway connection resumed after unexpectedly disconnecting.
For more information see Discord Docs.
role_id()
View Source
role_id() :: snowflake()
role_id() :: snowflake()
The id of a role.
shard_id()
View Source
shard_id() :: non_neg_integer()
shard_id() :: non_neg_integer()
The id of a shard.
snowflake()
View Source
snowflake() :: Crux.Rest.snowflake()
snowflake() :: Crux.Rest.snowflake()
A discord snowflake.
See t:Crux.Rest.Snowflake/0
for more information.
typing_start_event()
View Source
typing_start_event() ::
{:TYPING_START,
{Crux.Structs.Channel.t() | {channel_id(), guild_id() | nil},
Crux.Structs.User.t() | user_id(), String.t()}, shard_id()}
typing_start_event() :: {:TYPING_START, {Crux.Structs.Channel.t() | {channel_id(), guild_id() | nil}, Crux.Structs.User.t() | user_id(), String.t()}, shard_id()}
Emitted whenever a user started typing in a channel.
Emits a tuple of channel and guild id if the channel was not cached.
Emits the user id if the user was not cached.
The third element is the unix timestamp of when the user started typing.
For more information see Discord Docs.
user_id()
View Source
user_id() :: snowflake()
user_id() :: snowflake()
The id of a user.
user_update_event()
View Source
user_update_event() ::
{:USER_UPDATE, {Crux.Structs.User.t() | nil, Crux.Structs.User.t()},
shard_id()}
user_update_event() :: {:USER_UPDATE, {Crux.Structs.User.t() | nil, Crux.Structs.User.t()}, shard_id()}
Emitted whenever properties about the current user changed.
Emits nil as the user before the update if uncached previously.
For more information see Discord Docs.
voice_server_update_event() View Source
Emitted whenever guild's voice server was updated.
> This is the raw, but atomified, payload from discord, you can directly forward it to, for example, Lavalink.
For more information see Discord Docs.
voice_state_update_event()
View Source
voice_state_update_event() ::
{:VOICE_STATE_UPDATE,
{Crux.Structs.VoiceState.t() | nil, Crux.Structs.VoiceState.t()}, shard_id()}
voice_state_update_event() :: {:VOICE_STATE_UPDATE, {Crux.Structs.VoiceState.t() | nil, Crux.Structs.VoiceState.t()}, shard_id()}
Emitted whenever the voice state of a member changed.
Emits nil as the voice state before the update if uncached previously.
For more information see Discord Docs.
webhooks_update_event()
View Source
webhooks_update_event() ::
{:WEBHOOKS_UPDATE,
{Crux.Structs.Guild.t() | guild_id(),
Crux.Structs.Channel.t() | channel_id()}, shard_id()}
webhooks_update_event() :: {:WEBHOOKS_UPDATE, {Crux.Structs.Guild.t() | guild_id(), Crux.Structs.Channel.t() | channel_id()}, shard_id()}
Emitted whenever a channel's webhook was created, updated, or deleted.
Emits the guild id if the guild was not cached.
Emits the channel id if the channel was not cached.
For more information see Discord Docs.
Link to this section Functions
process_event(guild_event, data, shard_id, cache_provider) View Source
Processes the type
(t
value of a packet) along its data
(d
portion of a packet).
This will do necessary transformation, cache lookups, and cache insertions.
Returns an event/0
or a list of them.