Class: Discordrb::Events::ServerRoleCreateEvent

Inherits:
Event
  • Object
show all
Defined in:
lib/discordrb/events/roles.rb

Overview

Raised when a role is created on a server

Direct Known Subclasses

ServerRoleUpdateEvent

Instance Attribute Summary collapse

Attributes inherited from Event

#bot

Instance Method Summary collapse

Constructor Details

#initialize(data, bot) ⇒ ServerRoleCreateEvent


15
16
17
18
19
20
21
22
23
# File 'lib/discordrb/events/roles.rb', line 15

def initialize(data, bot)
  @bot = bot

  @server = bot.server(data['guild_id'].to_i)
  return unless @server

  role_id = data['role']['id'].to_i
  @role = @server.roles.find { |r| r.id == role_id }
end

Instance Attribute Details

#roleRole (readonly)


10
11
12
# File 'lib/discordrb/events/roles.rb', line 10

def role
  @role
end

#serverServer (readonly)


13
14
15
# File 'lib/discordrb/events/roles.rb', line 13

def server
  @server
end