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.



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

def initialize(data, bot)
  @bot = 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.



63
64
65
# File 'lib/discordrb/events/presence.rb', line 63

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.



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

def server
  @server
end

#userUser (readonly)

Returns the user whose status got updated.

Returns:

  • (User)

    the user whose status got updated.



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

def user
  @user
end