Class: Discordrb::Events::ServerEvent
- Defined in:
- lib/discordrb/events/guilds.rb
Overview
Generic subclass for server events (create/update/delete)
Direct Known Subclasses
ServerCreateEvent, ServerDeleteEvent, ServerEmojiCDEvent, ServerEmojiChangeEvent, ServerEmojiUpdateEvent, ServerUpdateEvent
Instance Attribute Summary collapse
-
#server ⇒ Server
readonly
The server in question.
Attributes inherited from Event
Instance Method Summary collapse
-
#init_server(data, bot) ⇒ Object
Initializes this event with server data.
-
#initialize(data, bot) ⇒ ServerEvent
constructor
A new instance of ServerEvent.
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
#server ⇒ Server (readonly)
Returns 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 |