Class: Discordrb::AuditLogs::Entry

Inherits:
Object
  • Object
show all
Includes:
IDObject
Defined in:
lib/discordrb/data/audit_logs.rb

Overview

An entry in a server's audit logs.

Instance Attribute Summary collapse

Attributes included from IDObject

#id

Instance Method Summary collapse

Methods included from IDObject

#==, #creation_time, synthesise

Instance Attribute Details

#actionSymbol (readonly)

Returns the action that was performed.

Returns:

  • (Symbol)

    the action that was performed.



136
137
138
# File 'lib/discordrb/data/audit_logs.rb', line 136

def action
  @action
end

#action_typeSymbol (readonly)

Returns the type action that was performed. (:create, :delete, :update, :unknown).

Returns:

  • (Symbol)

    the type action that was performed. (:create, :delete, :update, :unknown)



139
140
141
# File 'lib/discordrb/data/audit_logs.rb', line 139

def action_type
  @action_type
end

#application_idInteger? (readonly)

Returns the ID of the application whose application command permissions were updated.

Returns:

  • (Integer, nil)

    the ID of the application whose application command permissions were updated.



161
162
163
# File 'lib/discordrb/data/audit_logs.rb', line 161

def application_id
  @application_id
end

#automod_rule_nameString? (readonly)

Returns the name of the auto moderation rule that was triggered.

Returns:

  • (String, nil)

    the name of the auto moderation rule that was triggered.



164
165
166
# File 'lib/discordrb/data/audit_logs.rb', line 164

def automod_rule_name
  @automod_rule_name
end

#automod_rule_trigger_typeInteger? (readonly)

Returns the trigger type of the auto moderation rules that was triggered.

Returns:

  • (Integer, nil)

    the trigger type of the auto moderation rules that was triggered.



167
168
169
# File 'lib/discordrb/data/audit_logs.rb', line 167

def automod_rule_trigger_type
  @automod_rule_trigger_type
end

#changesHash<String => Change>, ... (readonly)

Returns the changes from this log, listing the key as the key changed. Will be a RoleChange object if the action is :member_role_update. Will be nil if the action is either :message_delete or :member_prune.

Returns:

  • (Hash<String => Change>, RoleChange, nil)

    the changes from this log, listing the key as the key changed. Will be a RoleChange object if the action is :member_role_update. Will be nil if the action is either :message_delete or :member_prune.



182
183
184
# File 'lib/discordrb/data/audit_logs.rb', line 182

def changes
  @changes
end

#countInteger? (readonly) Also known as: amount

Returns the amount of messages deleted. Only present if the action is :message_delete.

Returns:

  • (Integer, nil)

    the amount of messages deleted. Only present if the action is :message_delete.



145
146
147
# File 'lib/discordrb/data/audit_logs.rb', line 145

def count
  @count
end

#daysInteger? (readonly)

Returns the amount of days the members were inactive for. Only present if the action is :member_prune.

Returns:

  • (Integer, nil)

    the amount of days the members were inactive for. Only present if the action is :member_prune.



149
150
151
# File 'lib/discordrb/data/audit_logs.rb', line 149

def days
  @days
end

#integration_typeString? (readonly)

Returns the type of the integration that updated the member's roles, or kicked the member.

Returns:

  • (String, nil)

    the type of the integration that updated the member's roles, or kicked the member.



158
159
160
# File 'lib/discordrb/data/audit_logs.rb', line 158

def integration_type
  @integration_type
end

#members_removedInteger? (readonly)

Returns the amount of members removed. Only present if the action is :member_prune.

Returns:

  • (Integer, nil)

    the amount of members removed. Only present if the action is :member_prune.



152
153
154
# File 'lib/discordrb/data/audit_logs.rb', line 152

def members_removed
  @members_removed
end

#message_idInteger? (readonly)

Returns the ID of the message that was pinned or unpinned.

Returns:

  • (Integer, nil)

    the ID of the message that was pinned or unpinned.



155
156
157
# File 'lib/discordrb/data/audit_logs.rb', line 155

def message_id
  @message_id
end

#overwrite_idInteger? (readonly)

Returns the ID of the permission overwrite.

Returns:

  • (Integer, nil)

    the ID of the permission overwrite.



173
174
175
# File 'lib/discordrb/data/audit_logs.rb', line 173

def overwrite_id
  @overwrite_id
end

#overwrite_role_nameString? (readonly)

Returns the name of the role associated with the permission overwrite.

Returns:

  • (String, nil)

    the name of the role associated with the permission overwrite.



170
171
172
# File 'lib/discordrb/data/audit_logs.rb', line 170

def overwrite_role_name
  @overwrite_role_name
end

#overwrite_typeSymbol? (readonly)

Returns the type of the permission overwrite.

Returns:

  • (Symbol, nil)

    the type of the permission overwrite.



176
177
178
# File 'lib/discordrb/data/audit_logs.rb', line 176

def overwrite_type
  @overwrite_type
end

#reasonString? (readonly)

Returns the reason for this action occurring.

Returns:

  • (String, nil)

    the reason for this action occurring.



179
180
181
# File 'lib/discordrb/data/audit_logs.rb', line 179

def reason
  @reason
end

#target_typeSymbol (readonly)

Returns the type of target being performed on. (:server, :channel, :user, :role, :invite, :webhook, :emoji, :unknown).

Returns:

  • (Symbol)

    the type of target being performed on. (:server, :channel, :user, :role, :invite, :webhook, :emoji, :unknown)



142
143
144
# File 'lib/discordrb/data/audit_logs.rb', line 142

def target_type
  @target_type
end

Instance Method Details

#channelChannel?

Returns the channel associated with the audit log event.

Returns:

  • (Channel, nil)

    the channel associated with the audit log event.



233
234
235
236
237
# File 'lib/discordrb/data/audit_logs.rb', line 233

def channel
  return nil unless @channel_id

  @channel ||= @bot.channel(@channel_id)
end

#inspectObject

The inspect method is overwritten to give more useful output



260
261
262
# File 'lib/discordrb/data/audit_logs.rb', line 260

def inspect
  "<AuditLogs::Entry id=#{@id} key=#{@key} action=#{@action} reason=#{@reason} action_type=#{@action_type} target_type=#{@target_type} count=#{@count} days=#{@days} members_removed=#{@members_removed}>"
end

#messageMessage?

Returns the message that was pinned or un-pinned.

Returns:

  • (Message, nil)

    the message that was pinned or un-pinned.



240
241
242
# File 'lib/discordrb/data/audit_logs.rb', line 240

def message
  channel.load_message(@message_id) if @message_id
end

#targetServer, ...

Returns the target being performed on.

Returns:



221
222
223
# File 'lib/discordrb/data/audit_logs.rb', line 221

def target
  @target ||= process_target(@data['target_id'], @target_type)
end

#userMember, User Also known as: author

Returns the user that authored this action. Can be a User object if the user no longer exists in the server.

Returns:

  • (Member, User)

    the user that authored this action. Can be a User object if the user no longer exists in the server.



226
227
228
# File 'lib/discordrb/data/audit_logs.rb', line 226

def user
  @user ||= @server.member(@data['user_id'].to_i) || @bot.user(@data['user_id'].to_i) || @logs&.user(@data['user_id'].to_i)
end