Class: Discordrb::Events::ServerRoleCreateEvent
- Defined in:
- lib/discordrb/events/roles.rb
Overview
Raised when a role is created on a server
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
This role's name.
-
#role ⇒ Role
readonly
The role that got created.
-
#server ⇒ Server
readonly
The server on which a role got created.
Attributes inherited from Event
Instance Method Summary collapse
-
#initialize(data, bot) ⇒ ServerRoleCreateEvent
constructor
A new instance of ServerRoleCreateEvent.
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
#name ⇒ String (readonly)
Returns this role's name.
18 |
# File 'lib/discordrb/events/roles.rb', line 18 delegate :name, to: :role |
#role ⇒ Role (readonly)
Returns the role that got created.
10 11 12 |
# File 'lib/discordrb/events/roles.rb', line 10 def role @role end |
#server ⇒ Server (readonly)
Returns the server on which a role got created.
13 14 15 |
# File 'lib/discordrb/events/roles.rb', line 13 def server @server end |