Class: Discordrb::Events::ServerEvent

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

Overview

Generic subclass for server events (create/update/delete)

Instance Attribute Summary collapse

Attributes inherited from Event

#bot

Instance Method Summary collapse

Constructor Details

#initialize(data, bot) ⇒ ServerEvent

Returns a new instance of ServerEvent.



12
13
14
15
16
# File 'lib/discordrb/events/guilds.rb', line 12

def initialize(data, bot)
  @bot = bot

  init_server(data, bot)
end

Instance Attribute Details

#serverServer (readonly)

Returns the server in question.

Returns:

  • (Server)

    the server in question.



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

def server
  @server
end

Instance Method Details

#init_server(data, bot) ⇒ Object

Initializes this event with server data. Should be overwritten in case the server doesn’t exist at the time of event creation (e. g. Discordrb::Events::ServerDeleteEvent)



20
21
22
# File 'lib/discordrb/events/guilds.rb', line 20

def init_server(data, bot)
  @server = bot.server(data['id'].to_i)
end