class Discorb::AuditLog::Entry
Represents an entry in an audit log.
Attributes
@return [Discorb::AuditLog::Entry::Changes] The changes in this entry.
@return [Discorb::Snowflake] The ID of the entry.
@return [Hash{Symbol => Object}] The optional data for this entry. @note You can use dot notation to access the data.
@return [Discorb::Channel, Discorb::Role
, Discorb::Member
, Discorb::Guild
, Discorb::Message] The target of the entry.
@return [Discorb::Snowflake] The ID of the target of the action.
@return [Symbol] The type of the entry. These symbols will be used:
-
`: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`
-
`:member_move`
-
`:member_disconnect`
-
`:bot_add`
-
`:role_create`
-
`:role_update`
-
`:role_delete`
-
`:invite_create`
-
`:invite_update`
-
`:invite_delete`
-
`:webhook_create`
-
`:webhook_update`
-
`:webhook_delete`
-
`:emoji_create`
-
`:emoji_update`
-
`:emoji_delete`
-
`:message_delete`
-
`:message_bulk_delete`
-
`:message_pin`
-
`:message_unpin`
-
`:integration_create`
-
`:integration_update`
-
`:integration_delete`
-
`:stage_instance_create`
-
`:stage_instance_update`
-
`:stage_instance_delete`
-
`:sticker_create`
-
`:sticker_update`
-
`:sticker_delete`
-
`:thread_create`
-
`:thread_update`
-
`:thread_delete`
@return [Discorb::Snowflake] The ID of the user who performed the action.
Public Class Methods
@!visibility private
# File lib/discorb/audit_logs.rb, line 167 def initialize(client, data, guild_id) @client = client @guild_id = Snowflake.new(guild_id) @id = Snowflake.new(data[:id]) @user_id = Snowflake.new(data[:user_id]) @target_id = Snowflake.new(data[:target_id]) @type = self.class.events[data[:action_type]] @target = self.class.converts[@type.to_s.split('_')[0].to_sym]&.call(client, @target_id, @gui) @target ||= Snowflake.new(data[:target_id]) @changes = data[:changes] && Changes.new(data[:changes]) @reason = data[:reason] data[:options]&.each do |option, value| define_singleton_method(option) { value } if option.end_with?('_id') define_singleton_method(option.to_s.sub('_id', '')) do self.class.converts[option.to_s.split('_')[0].to_sym]&.call(client, value, @guild_id) end end end @options = data[:options] || {} end
Public Instance Methods
Get a change with the given key.
@param [Symbol] key The key to get.
@return [Discorb::AuditLog::Entry::Change] The change with the given key. @return [nil] The change with the given key does not exist.
# File lib/discorb/audit_logs.rb, line 201 def [](key) @changes[key] end
# File lib/discorb/audit_logs.rb, line 205 def inspect "#<#{self.class} #{@changes&.data&.length || 'No'} changes>" end
# File lib/discorb/audit_logs.rb, line 189 def user @client.users[@user_id] end