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, activity, bot) ⇒ PlayingEvent



85
86
87
88
89
90
91
92
# File 'lib/discordrb/events/presence.rb', line 85

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

#activityDiscordrb::Activity (readonly)



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

def activity
  @activity
end

#client_statusHash<Symbol, Symbol> (readonly)



83
84
85
# File 'lib/discordrb/events/presence.rb', line 83

def client_status
  @client_status
end

#detailsString (readonly)



# File 'lib/discordrb/events/presence.rb', line 74

#serverServer (readonly)



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

def server
  @server
end

#typeInteger (readonly)



79
# File 'lib/discordrb/events/presence.rb', line 79

delegate :url, :details, :type, to: :activity

#urlString (readonly)



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

#userUser (readonly)



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

def user
  @user
end

Instance Method Details

#gameString



95
96
97
# File 'lib/discordrb/events/presence.rb', line 95

def game
  @activity.name
end