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

Returns a new instance of ServerRoleCreateEvent.



20
21
22
23
24
25
26
27
28
# File 'lib/discordrb/events/roles.rb', line 20

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

#nameString (readonly)

Returns this role’s name.

Returns:

  • (String)

    this role’s name

See Also:



18
# File 'lib/discordrb/events/roles.rb', line 18

delegate :name, to: :role

#roleRole (readonly)

Returns the role that got created.

Returns:

  • (Role)

    the role that got created



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

def role
  @role
end

#serverServer (readonly)

Returns the server on which a role got created.

Returns:

  • (Server)

    the server on which a role got created



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

def server
  @server
end