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.



64
65
66
# File 'lib/discordrb/data/audit_logs.rb', line 64

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)



67
68
69
# File 'lib/discordrb/data/audit_logs.rb', line 67

def action_type
  @action_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.



86
87
88
# File 'lib/discordrb/data/audit_logs.rb', line 86

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.



73
74
75
# File 'lib/discordrb/data/audit_logs.rb', line 73

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.



77
78
79
# File 'lib/discordrb/data/audit_logs.rb', line 77

def days
  @days
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.



80
81
82
# File 'lib/discordrb/data/audit_logs.rb', line 80

def members_removed
  @members_removed
end

#reasonString? (readonly)

Returns the reason for this action occuring.

Returns:

  • (String, nil)

    the reason for this action occuring.



83
84
85
# File 'lib/discordrb/data/audit_logs.rb', line 83

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)



70
71
72
# File 'lib/discordrb/data/audit_logs.rb', line 70

def target_type
  @target_type
end

Instance Method Details

#channelChannel?

Returns the amount of messages deleted. Won't be nil if the action is :message_delete.

Returns:

  • (Channel, nil)

    the amount of messages deleted. Won't be nil if the action is :message_delete.



128
129
130
131
132
# File 'lib/discordrb/data/audit_logs.rb', line 128

def channel
  return nil unless @channel_id

  @channel ||= @bot.channel(@channel_id, @server, bot, self)
end

#inspectObject

The inspect method is overwritten to give more useful output



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

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

#targetServer, ...

Returns the target being performed on.

Returns:



117
118
119
# File 'lib/discordrb/data/audit_logs.rb', line 117

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.



122
123
124
# File 'lib/discordrb/data/audit_logs.rb', line 122

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