Module: Vox::HTTP::Routes::AuditLog

Defined in:
lib/vox/http/routes/audit_log.rb

Overview

HTTP methods for accessing information about a Guild‘s AuditLog

Constant Summary collapse

EVENTS =

TODO: Is this the best place for these?

{
  GUILD_UPDATE: 1,
  CHANNEL_CREATE: 10,
  CHANNEL_UPDATE: 11,
  CHANNEL_DELETE: 12,
  CHANNEL_OVERWRITE_CREATE: 13,
  CHANNEL_OVERWRITE_UPDATE: 14,
  CHANNEL_OVERWRITE_DELETE: 15,
  MEMBER_KICK: 20,
  MEMBER_PRUNE: 21,
  MEMBER_BAN_ADD: 22,
  MEMBER_BAN_REMOVE: 23,
  MEMBER_UPDATE: 24,
  MEMBER_ROLE_UPDATE: 25,
  MEMBER_MOVE: 26,
  MEMBER_DISCONNECT: 27,
  BOT_ADD: 28,
  ROLE_CREATE: 30,
  ROLE_UPDATE: 31,
  ROLE_DELETE: 32,
  INVITE_CREATE: 40,
  INVITE_UPDATE: 41,
  INVITE_DELETE: 42,
  WEBHOOK_CREATE: 50,
  WEBHOOK_UPDATE: 51,
  WEBHOOK_DELETE: 52,
  EMOJI_CREATE: 60,
  EMOJI_UPDATE: 61,
  EMOJI_DELETE: 62,
  MESSAGE_DELETE: 72,
  MESSAGE_BULK_DELETE: 73,
  MESSAGE_PIN: 74,
  MESSAGE_UNPIN: 75,
  INTEGRATION_CREATE: 80,
  INTEGRATION_UPDATE: 81,
  INTEGRATION_DELETE: 82
}.freeze

Instance Method Summary collapse

Instance Method Details

#get_guild_audit_log(guild_id, user_id: :undef, action_type: :undef, before: :undef, limit: :undef) ⇒ Hash<:audit_log_entries, Array<Object>>

Fetch a guild’s audit log. [View on Discord’s docs](discord.com/developers/docs/resources/audit-log#get-guild-audit-log)

Parameters:

  • guild_id (String, Integer)

    The ID of the guild to fetch audit log entries from.

  • user_id (String, Integer) (defaults to: :undef)

    The ID of the user to filter events for.

  • action_type (Symbol, Integer) (defaults to: :undef)

    The name of the audit log event to filter for. Either a key from EVENTS or the corresponding integer value.

  • before (String, Integer) (defaults to: :undef)

    The ID of the audit log entry to fetch before chronologically.

  • limit (Integer) (defaults to: :undef)

    The maximum amount of entries to return. Defaults to 50 if no value is supplied. Maximum of 100, minimum of 1.

Returns:

  • (Hash<:audit_log_entries, Array<Object>>)

Required Permissions:

  • VIEW_AUDIT_LOG

View On Discord's Docs:



63
64
65
66
67
# File 'lib/vox/http/routes/audit_log.rb', line 63

def get_guild_audit_log(guild_id, user_id: :undef, action_type: :undef, before: :undef, limit: :undef)
  route = HTTP::Route.new(:GET, '/guilds/%{guild_id}/audit-logs', guild_id: guild_id)
  query_params = filter_undef({ user_id: user_id, action_type: action_type, before: before, limit: limit })
  request(route, query: query_params)
end