Class: Discordrb::Events::PlayingEvent

Inherits:
Event
  • Object
show all
Defined in:
lib/discordrb/events/presence.rb

Overview

Event raised when a user starts or stops playing a game

Instance Attribute Summary collapse

Attributes inherited from Event

#bot

Instance Method Summary collapse

Constructor Details

#initialize(data, bot) ⇒ PlayingEvent

Returns a new instance of PlayingEvent.



63
64
65
66
67
68
69
# File 'lib/discordrb/events/presence.rb', line 63

def initialize(data, bot)
  @user = bot.user(data['user']['id'].to_i)

  @game = data['game'] ? data['game']['name'] : nil

  @server = bot.server(data['guild_id'].to_i)
end

Instance Attribute Details

#gameString (readonly)

Returns the new game the user is playing.

Returns:

  • (String)

    the new game the user is playing.



61
62
63
# File 'lib/discordrb/events/presence.rb', line 61

def game
  @game
end

#serverServer (readonly)

Returns the server on which the presence update happened.

Returns:

  • (Server)

    the server on which the presence update happened.



55
56
57
# File 'lib/discordrb/events/presence.rb', line 55

def server
  @server
end

#userUser (readonly)

Returns the user whose status got updated.

Returns:

  • (User)

    the user whose status got updated.



58
59
60
# File 'lib/discordrb/events/presence.rb', line 58

def user
  @user
end