Crux v2020-03-17 17:55:51Z Crux.Base.TaskConsumer behaviour View Source

Provides a __using__ macro to inject two functions to simplify consuming of gateway events.

A somewhat example of this:

A Supervisor, like Crux.Base.ConsumerSupervisor, and

defmodule Bot.Consumer do
  use Crux.Base.TaskConsumer

  def handle_event({:MESSAGE_CREATE, message, _shard_id}) do

  def handle_event(_event), do: nil

Link to this section Summary


All available element types.


Will handle events.

Link to this section Types

All available element types.

Link to this section Callbacks

Link to this callback

handle_event(event) View Source
handle_event(event :: event()) :: any()

Will handle events.

Be sure to have one "catch all" clause to not crash your consumer when you receive an event you didn't handle.