EDA.Cache.Presence (EDA v0.3.0)

Copy Markdown View Source

ETS-based cache for Discord presences.

Tracks user status (online/idle/dnd/offline) and activities per guild. Keyed by {guild_id, user_id}.

Requires the guild_presences privileged intent. Automatically populated from GUILD_CREATE and PRESENCE_UPDATE events.

Summary

Functions

Returns a specification to start this module under a supervisor.

Returns the total number of cached presences.

Removes all presences for a guild.

Gets all presences for a guild.

Gets a user's presence in a guild.

Creates or updates a presence.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

count()

@spec count() :: non_neg_integer()

Returns the total number of cached presences.

delete_guild(guild_id)

@spec delete_guild(String.t() | integer()) :: :ok

Removes all presences for a guild.

for_guild(guild_id)

@spec for_guild(String.t() | integer()) :: [map()]

Gets all presences for a guild.

get(guild_id, user_id)

@spec get(String.t() | integer(), String.t() | integer()) :: map() | nil

Gets a user's presence in a guild.

start_link(opts)

upsert(guild_id, data)

@spec upsert(String.t(), map()) :: :ok

Creates or updates a presence.