Class: Discordrb::Events::GuildMemberUpdateEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/discordrb/events/guild-member-update.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, bot) ⇒ GuildMemberUpdateEvent

Returns a new instance of GuildMemberUpdateEvent.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/discordrb/events/guild-member-update.rb', line 10

def initialize(data, bot)
  @server = bot.server(data['guild_id'].to_i)
  return if !@server
  
  user_id = data['user']['id'].to_i
  @user = @server.members.find {|u| u.id == user_id}
  @roles = []
  data['roles'].each do |element|
    role_id = element.to_i
    @roles << @server.roles.find {|r| r.id == role_id}
  end
end

Instance Attribute Details

#rolesObject (readonly)

Returns the value of attribute roles.



7
8
9
# File 'lib/discordrb/events/guild-member-update.rb', line 7

def roles
  @roles
end

#serverObject (readonly)

Returns the value of attribute server.



8
9
10
# File 'lib/discordrb/events/guild-member-update.rb', line 8

def server
  @server
end

#userObject (readonly)

Returns the value of attribute user.



6
7
8
# File 'lib/discordrb/events/guild-member-update.rb', line 6

def user
  @user
end