Alchemy.AuditLog (alchemy v0.6.8)

This module contains functions and types related to audit logs.

Link to this section Summary

Types

An enumeration of action types.

The type of an audit log change.

An entry in an audit log.

Additional information fields in an audit log based on action_type.

t()

Represents the Audit Log information of a guild.

Functions

Returns an audit log entry for a guild.

Link to this section Types

Specs

action() ::
  :guild_update
  | :channel_create
  | :channel_update
  | :channel_delete
  | :channel_overwrite_create
  | :channel_overwrite_update
  | :channel_overwrite_delete
  | :member_kick
  | :member_prune
  | :member_ban_add
  | :member_ban_remove
  | :member_update
  | :member_role_update
  | :role_create
  | :role_update
  | :role_delete
  | :invite_create
  | :invite_update
  | :invite_delete
  | :webhook_create
  | :webhook_update
  | :webhook_delete
  | :emoji_create
  | :emoji_update
  | :message_delete

An enumeration of action types.

Specs

change() :: %Alchemy.AuditLog.Change{
  key: String.t(),
  new_value: any(),
  old_value: any()
}

The type of an audit log change.

  • new_value The new value after the change.
  • old_value The value prior to the change.
  • key The type of change that occurred. This also dictates the type of new_value and old_value

more information on this relation

Specs

entry() :: %Alchemy.AuditLog.Entry{
  action_type: action(),
  changes: [change()],
  id: snowflake(),
  options: options(),
  reason: term(),
  target_id: String.t(),
  user_id: snowflake()
}

An entry in an audit log.

  • target_id The id of the affected entity.
  • changes The changes made to the target_id.
  • user_id The user who made the changes.
  • id The id of the entry
  • action_type The type of action that occurred
  • options Additional map of information for certain action types.
  • reason The reason for the change

Specs

options() :: %{
  optional(:delete_member_days) => String.t(),
  optional(:members_removed) => String.t(),
  optional(:channel_id) => snowflake(),
  optional(:count) => integer(),
  optional(:id) => snowflake(),
  optional(:type) => String.t(),
  optional(:role_name) => String.t()
}

Additional information fields in an audit log based on action_type.

:member_prune -> [:delete_member_days, :members_removed] :message_delete -> [:channel_id, :count] :channel_overwrite_create | delete | update -> [:id, :type, :role_name]

Specs

snowflake() :: String.t()

Specs

t() :: %Alchemy.AuditLog{
  audit_log_entries: [entry()],
  users: Alchemy.User.t(),
  webhooks: Alchemy.Webhook.t()
}

Represents the Audit Log information of a guild.

  • webhooks List of webhooks found in the Audit Log.
  • user List of users found in the Audit Log.
  • audit_log_entries List of entries in the Audit Log.

Link to this section Functions

Link to this function

get_guild_log(guild, options \\ [])

Specs

get_guild_log(snowflake(),
  user_id: snowflake(),
  action_type: action(),
  before: snowflake(),
  limit: integer()
) :: {:ok, t()} | {:error, term()}

Returns an audit log entry for a guild.

Requires :view_audit_log permission.

Options

  • user_id Filters the log for a user id.
  • action_type The type of audit log event
  • before Filter the log before a certain entry id.
  • limit How many entries are returned (default 50, between 1 and 100).