Class: Rubycord::Events::ServerEvent

Inherits:
Event
  • Object
show all
Defined in:
lib/rubycord/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.



10
11
12
13
14
# File 'lib/rubycord/events/guilds.rb', line 10

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.



8
9
10
# File 'lib/rubycord/events/guilds.rb', line 8

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. Rubycord::Events::ServerDeleteEvent)



18
19
20
# File 'lib/rubycord/events/guilds.rb', line 18

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