Presence and activity builder for Discord bots.
Allows setting bot status (online, idle, dnd, invisible) and activities (playing, streaming, listening, watching, custom, competing).
Examples
# Build a presence with status and activity
presence = EDA.Presence.new(
status: :dnd,
activities: [EDA.Presence.playing("Elixir")]
)
# Update at runtime
EDA.set_presence(presence)
# Convenience — just set an activity
EDA.set_activity("Elixir", type: :playing)
Summary
Functions
Creates a Competing activity (type 5).
Creates a Custom Status activity (type 4).
Creates a Listening activity (type 2).
Builds a %Presence{} struct from keyword options.
Creates a Playing activity (type 0).
Creates a Streaming activity (type 1) with a Twitch/YouTube URL.
Serializes a %Presence{} to the Discord gateway format.
Creates a Watching activity (type 3).
Types
@type activity() :: %{ :name => String.t(), :type => activity_type(), optional(:url) => String.t() }
@type activity_type() ::
:playing | :streaming | :listening | :watching | :custom | :competing
@type status() :: :online | :idle | :dnd | :invisible
Functions
Creates a Competing activity (type 5).
Creates a Custom Status activity (type 4).
Creates a Listening activity (type 2).
Builds a %Presence{} struct from keyword options.
Options
:status—:online|:idle|:dnd|:invisible(default:online):activities— list of activity maps from builder functions:afk— boolean (defaultfalse):since— unix timestamp in milliseconds, ornil
Creates a Playing activity (type 0).
Creates a Streaming activity (type 1) with a Twitch/YouTube URL.
Serializes a %Presence{} to the Discord gateway format.
Creates a Watching activity (type 3).