Class: Rubycord::Events::PresenceEvent
- Defined in:
- lib/rubycord/events/presence.rb
Overview
Event raised when a user's presence state updates (idle or online)
Instance Attribute Summary collapse
-
#client_status ⇒ Hash<Symbol, Symbol>
readonly
The current online status (
:online
,:idle
or:dnd
) of the user on various device types (:desktop
,:mobile
, or:web
). -
#server ⇒ Server
readonly
The server on which the presence update happened.
-
#status ⇒ Symbol
readonly
The new status.
-
#user ⇒ User
readonly
The user whose status got updated.
Attributes inherited from Event
Instance Method Summary collapse
-
#initialize(data, bot) ⇒ PresenceEvent
constructor
A new instance of PresenceEvent.
Constructor Details
#initialize(data, bot) ⇒ PresenceEvent
Returns a new instance of PresenceEvent.
20 21 22 23 24 25 26 27 |
# File 'lib/rubycord/events/presence.rb', line 20 def initialize(data, bot) @bot = bot @user = bot.user(data["user"]["id"].to_i) @status = data["status"].to_sym @client_status = user.client_status @server = bot.server(data["guild_id"].to_i) end |
Instance Attribute Details
#client_status ⇒ Hash<Symbol, Symbol> (readonly)
Returns the current online status (:online
, :idle
or :dnd
) of the user
on various device types (:desktop
, :mobile
, or :web
). The value will be nil
if the user is offline or invisible.
18 19 20 |
# File 'lib/rubycord/events/presence.rb', line 18 def client_status @client_status end |
#server ⇒ Server (readonly)
Returns the server on which the presence update happened.
8 9 10 |
# File 'lib/rubycord/events/presence.rb', line 8 def server @server end |
#status ⇒ Symbol (readonly)
Returns the new status.
14 15 16 |
# File 'lib/rubycord/events/presence.rb', line 14 def status @status end |
#user ⇒ User (readonly)
Returns the user whose status got updated.
11 12 13 |
# File 'lib/rubycord/events/presence.rb', line 11 def user @user end |