Class: Rubycord::Events::PlayingEvent
- Defined in:
- lib/rubycord/events/presence.rb
Overview
Event raised when a user starts or stops playing a game
Instance Attribute Summary collapse
-
#activity ⇒ Rubycord::Activity
readonly
The new activity.
-
#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
). -
#details ⇒ String
readonly
What the player is currently doing (ex. game being streamed).
-
#server ⇒ Server
readonly
The server on which the presence update happened.
-
#type ⇒ Integer
readonly
The type of play.
-
#url ⇒ String
readonly
The URL to the stream.
-
#user ⇒ User
readonly
The user whose status got updated.
Attributes inherited from Event
Instance Method Summary collapse
-
#game ⇒ String
The name of the new game the user is playing.
-
#initialize(data, activity, bot) ⇒ PlayingEvent
constructor
A new instance of PlayingEvent.
Constructor Details
#initialize(data, activity, bot) ⇒ PlayingEvent
Returns a new instance of PlayingEvent.
83 84 85 86 87 88 89 90 |
# File 'lib/rubycord/events/presence.rb', line 83 def initialize(data, activity, bot) @bot = bot @activity = activity @server = bot.server(data["guild_id"].to_i) @user = bot.user(data["user"]["id"].to_i) @client_status = @user.client_status end |
Instance Attribute Details
#activity ⇒ Rubycord::Activity (readonly)
Returns The new activity.
67 68 69 |
# File 'lib/rubycord/events/presence.rb', line 67 def activity @activity end |
#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.
81 82 83 |
# File 'lib/rubycord/events/presence.rb', line 81 def client_status @client_status end |
#details ⇒ String (readonly)
Returns what the player is currently doing (ex. game being streamed).
|
# File 'lib/rubycord/events/presence.rb', line 72
|
#server ⇒ Server (readonly)
Returns the server on which the presence update happened.
61 62 63 |
# File 'lib/rubycord/events/presence.rb', line 61 def server @server end |
#type ⇒ Integer (readonly)
Returns the type of play. See Activity.
77 |
# File 'lib/rubycord/events/presence.rb', line 77 delegate :url, :details, :type, to: :activity |
#url ⇒ String (readonly)
Returns the URL to the stream.
|
# File 'lib/rubycord/events/presence.rb', line 69
|
#user ⇒ User (readonly)
Returns the user whose status got updated.
64 65 66 |
# File 'lib/rubycord/events/presence.rb', line 64 def user @user end |
Instance Method Details
#game ⇒ String
Returns the name of the new game the user is playing.
93 94 95 |
# File 'lib/rubycord/events/presence.rb', line 93 def game @activity.name end |