EDA.AuditLog (EDA v0.3.0)

Copy Markdown View Source

Audit log types, action type mappings, and pagination helpers.

Summary

Functions

Converts an integer action type to an atom. Returns :unknown for unrecognized types.

Converts an atom action type to its integer value. Returns nil if not found.

Returns all known action types as a map of integer => atom.

Returns a lazy Stream that paginates through audit log entries. Uses snowflake-based before pagination via Stream.resource/3. Stops when a page returns fewer entries than per_page.

Functions

action_name(type)

@spec action_name(integer()) :: atom()

Converts an integer action type to an atom. Returns :unknown for unrecognized types.

action_type(name)

@spec action_type(atom()) :: integer() | nil

Converts an atom action type to its integer value. Returns nil if not found.

action_types()

@spec action_types() :: %{required(integer()) => atom()}

Returns all known action types as a map of integer => atom.

stream(guild_id, opts \\ [])

@spec stream(
  String.t() | integer(),
  keyword()
) :: Enumerable.t()

Returns a lazy Stream that paginates through audit log entries. Uses snowflake-based before pagination via Stream.resource/3. Stops when a page returns fewer entries than per_page.

Options

Same as EDA.API.Guild.audit_log/2 plus:

  • :per_page — entries per page (default 50, max 100)

Example

EDA.AuditLog.stream("guild_id", action_type: EDA.AuditLog.action_type(:member_ban_add))
|> Stream.take(200)
|> Enum.to_list()