Crux vdev Crux.Base.Consumer View Source

Handles consuming and processing of events received from the gateway.
To consume those processed events subscribe with a consumer to a producer.
You can fetch said producers via Crux.Base.producers/0

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

Link to this section Types

Link to this type

channel_create_event() View Source
channel_create_event() ::
  {:CHANNEL_CREATE, Crux.Structs.Channel.t(), shard_id()}

Emitted whenever a channel was created.

For more information see Discord Docs.

Link to this type

channel_delete_event() View Source
channel_delete_event() ::
  {:CHANNEL_DELETE, Crux.Structs.Channel.t(), shard_id()}

Emitted whenever a channel was deleted.

For more information see Discord Docs.

Link to this type

channel_id() View Source
channel_id() :: snowflake()

The id of a channel.

Link to this type

channel_pins_update_event() View Source
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.

Link to this type

channel_update_event() View Source
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.

Union type of all available events.

Link to this type

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()}

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.

Link to this type

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()}

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.

Link to this type

guild_create_event() View Source
guild_create_event() :: {:GUILD_CREATE, Crux.Structs.Guild.t(), shard_id()}

Emitted whenever the client joined a guild.

For more information see Discord Docs.

Link to this type

guild_delete_event() View Source
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.

Link to this type

guild_emojis_update_event() View Source
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.

The id of a guild.

Link to this type

guild_integrations_update_event() View Source
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.

Link to this type

guild_member_add_event() View Source
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.

Link to this type

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()}

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.

Link to this type

guild_member_update_event() View Source
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.

Link to this type

guild_members_chunk_event() View Source
guild_members_chunk_event() ::
  {:GUILD_MEMBERS_CHUNK, [Crux.Structs.Member.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.

Link to this type

guild_role_create_event() View Source
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.

Link to this type

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()}

Emitted whenever a role was deleted.

Emits a tuple of role and guild or guild id if uncached.

For more information see Discord Docs.

Link to this type

guild_role_update_event() View Source
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.

Link to this type

guild_update_event() View Source
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.

Link to this type

message_create_event() View Source
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.

Link to this type

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()}

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.

Link to this type

message_delete_event() View Source
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.

Link to this type

message_id() View Source
message_id() :: snowflake()

The id of a message.

Link to this type

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()}

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.

Link to this type

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()}}}

Emitted whenever a user explicitly removed all reactions from a message.

For more information see Discord Docs.

Link to this type

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()}

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.

Link to this type

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()}

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.

Link to this type

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()}

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.

Link to this type

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(),
     _trace: [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.

Link to this type

resumed_event() View Source
resumed_event() :: {:RESUMED, %{_trace: [String.t()]}, shard_id()}

Emitted whenever a gateway connection resumed after unexpectedly disconnecting.

For more information see Discord Docs.

The id of a role.

The id of a shard.

A discord snowflake.
See t:Crux.Rest.Snowflake/0 for more information.

Link to this type

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()}

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.

The id of a user.

Link to this type

user_update_event() View Source
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.

Link to this type

voice_server_update_event() View Source
voice_server_update_event() ::
  {:VOICE_SERVER_UPDATE,
   %{token: String.t(), guild_id: String.t(), endpoint: String.t()}, shard_id()}

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.

Link to this type

voice_state_update_event() View Source
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.

Link to this type

webhooks_update_event() View Source
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.