class Discordrb::AuditLogs::Change

A change in a audit log entry.

Attributes

key[R]

@return [String] the key that was changed. @note You should check with the Discord API Documentation on what key gives out what value.

new[R]

@return [String, Integer, true, false, Permissions, Overwrite, nil] the value that was changed to.

new_value[R]

@return [String, Integer, true, false, Permissions, Overwrite, nil] the value that was changed to.

old[R]

@return [String, Integer, true, false, Permissions, Overwrite, nil] the value that was changed from.

old_value[R]

@return [String, Integer, true, false, Permissions, Overwrite, nil] the value that was changed from.

Public Class Methods

new(data, server, bot, logs) click to toggle source

@!visibility private

# File lib/discordrb/data/audit_logs.rb, line 211
def initialize(data, server, bot, logs)
  @key = data['key']
  @old = data['old_value']
  @new = data['new_value']
  @server = server
  @bot = bot
  @logs = logs

  @old = Permissions.new(@old) if @old && @key == 'permissions'
  @new = Permissions.new(@new) if @new && @key == 'permissions'

  @old = @old.map { |o| Overwrite.new(o['id'], type: o['type'], allow: o['allow'], deny: o['deny']) } if @old && @key == 'permission_overwrites'
  @new = @new.map { |o| Overwrite.new(o['id'], type: o['type'], allow: o['allow'], deny: o['deny']) } if @new && @key == 'permission_overwrites'
end

Public Instance Methods

new_afk_channel() click to toggle source

@return [Channel, nil] the channel that is used in the server as an AFK channel prior to this change. Only present if the key for this change is ‘afk_channel_id`.

# File lib/discordrb/data/audit_logs.rb, line 242
def new_afk_channel
  @bot.channel(@new, @server) if @new && @key == 'afk_channel_id'
end
new_owner() click to toggle source

@return [Member, User, nil] the member that is now the owner of the server prior to this change. Only present if the key for this change is ‘owner_id`.

# File lib/discordrb/data/audit_logs.rb, line 252
def new_owner
  @server.member(@new) || @bot.user(@new) || @logs.user(@new) if @new && @key == 'owner_id'
end
new_widget_channel() click to toggle source

@return [Channel, nil] the channel that is used in the server widget prior to this change. Only present if the key for this change is ‘widget_channel_id`.

# File lib/discordrb/data/audit_logs.rb, line 232
def new_widget_channel
  @bot.channel(@new, @server) if @new && @key == 'widget_channel_id'
end
old_afk_channel() click to toggle source

@return [Channel, nil] the channel that was previously used in the server as an AFK channel. Only present if the key for this change is ‘afk_channel_id`.

# File lib/discordrb/data/audit_logs.rb, line 237
def old_afk_channel
  @bot.channel(@old, @server) if @old && @key == 'afk_channel_id'
end
old_owner() click to toggle source

@return [Member, User, nil] the member that used to be the owner of the server. Only present if the for key for this change is ‘owner_id`.

# File lib/discordrb/data/audit_logs.rb, line 247
def old_owner
  @server.member(@old) || @bot.user(@old) || @logs.user(@old) if @old && @key == 'owner_id'
end
old_widget_channel() click to toggle source

@return [Channel, nil] the channel that was previously used in the server widget. Only present if the key for this change is ‘widget_channel_id`.

# File lib/discordrb/data/audit_logs.rb, line 227
def old_widget_channel
  @bot.channel(@old, @server) if @old && @key == 'widget_channel_id'
end