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.


71
72
73
74
75
76
77
78
79
# File 'lib/discordrb/events/presence.rb', line 71

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)
  @url = data['game'] ? data['game']['url'] : nil
  @type = data['game'] ? data['game']['type'].to_i : nil
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

#typeInteger (readonly)

Returns the type of play. 0 = game, 1 = Twitch.

Returns:

  • (Integer)

    the type of play. 0 = game, 1 = Twitch


69
70
71
# File 'lib/discordrb/events/presence.rb', line 69

def type
  @type
end

#urlString (readonly)

Returns the URL to the stream.

Returns:

  • (String)

    the URL to the stream


66
67
68
# File 'lib/discordrb/events/presence.rb', line 66

def url
  @url
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