defmodule ExampleSupervisor do use Supervisor def start_link(args) do Supervisor.start_link(__MODULE__, args, name: __MODULE__) end @impl true def init(_init_arg) do children = [ExampleConsumer] Supervisor.init(children, strategy: :one_for_one) end end defmodule ExampleConsumer do use Nostrum.Consumer alias Nostrum.Api.Message def handle_event({:MESSAGE_CREATE, msg, _ws_state}) do case msg.content do "!sleep" -> Message.create(msg.channel_id, "Going to sleep...") # This won't stop other events from being handled. Process.sleep(3000) "!ping" -> Message.create(msg.channel_id, "pyongyang!") "!raise" -> # This won't crash the entire Consumer. raise "No problems here!" _ -> :ignore end end end