Class: Discordrb::Events::PlayingEvent
- Defined in:
- lib/discordrb/events/presence.rb
Overview
Event raised when a user starts or stops playing a game
Instance Attribute Summary collapse
-
#details ⇒ String
readonly
What the player is currently doing (ex. game being streamed).
-
#game ⇒ String
readonly
The new game the user is playing.
-
#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
-
#initialize(data, bot) ⇒ PlayingEvent
constructor
A new instance of PlayingEvent.
Constructor Details
#initialize(data, bot) ⇒ PlayingEvent
Returns a new instance of PlayingEvent.
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/discordrb/events/presence.rb', line 80 def initialize(data, bot) @bot = bot @server = bot.server(data['guild_id'].to_i) @user = bot.user(data['user']['id'].to_i) @game = data['game'] ? data['game']['name'] : nil @type = data['game'] ? data['game']['type'].to_i : nil # Handle optional 'game' fields safely @url = data['game'] && data['game']['url'] ? data['game']['url'] : nil @details = data['game'] && data['game']['details'] ? data['game']['details'] : nil end |
Instance Attribute Details
#details ⇒ String (readonly)
Returns what the player is currently doing (ex. game being streamed).
75 76 77 |
# File 'lib/discordrb/events/presence.rb', line 75 def details @details end |
#game ⇒ String (readonly)
Returns the new game the user is playing.
69 70 71 |
# File 'lib/discordrb/events/presence.rb', line 69 def game @game end |
#server ⇒ Server (readonly)
Returns the server on which the presence update happened.
63 64 65 |
# File 'lib/discordrb/events/presence.rb', line 63 def server @server end |
#type ⇒ Integer (readonly)
Returns the type of play. 0 = game, 1 = Twitch.
78 79 80 |
# File 'lib/discordrb/events/presence.rb', line 78 def type @type end |
#url ⇒ String (readonly)
Returns the URL to the stream.
72 73 74 |
# File 'lib/discordrb/events/presence.rb', line 72 def url @url end |
#user ⇒ User (readonly)
Returns the user whose status got updated.
66 67 68 |
# File 'lib/discordrb/events/presence.rb', line 66 def user @user end |