enmity v0.3.0 Enmity.Gateway behaviour View Source
Connects to the Discord Gateway.
Import this module with Use and define handle_event/3 callbacks to receive events from Discord.
defmodule MyGateway do
use Enmity.Gateway
def handle_event(:READY, data, state) do
# We're connected! hooray!
{:ok, state}
end
def handle_event(:GUILD_CREATE, data, state) do
# This event will be sent after :READY, once for each guild your bot is a member of.
{:ok, state}
end
end
Link to this section Summary
Callbacks
Handle a Discord Gateway event.
Link to this section Callbacks
Handle a Discord Gateway event.
Event names are tokens in all-caps, like :READY.
For a full list of events, see Discord's docs on Gateway events.
Examples
def handle_event(:READY, data, state) do
Logger.debug("Connection successful!")
{:ok, state}
end