Class: Discordrb::Activity

Inherits:
Object
  • Object
show all
Defined in:
lib/discordrb/data/activity.rb

Overview

Contains information about user activities such as the game they are playing, music they are listening to, or their live stream.

Defined Under Namespace

Classes: Assets, Party, Secrets, Timestamps

Constant Summary collapse

FLAGS =

Values corresponding to the flags bitmask

{
  instance: 1 << 0, # this activity is an instanced game session
  join: 1 << 1, # this activity is joinable
  spectate: 1 << 2, # this activity can be spectated
  join_request: 1 << 3, # this activity allows asking to join
  sync: 1 << 4, # this activity is a spotify track
  play: 1 << 5 # this game can be played or opened from discord
}.freeze
GAME =

Type indicating the activity is for a game

0
STREAMING =

Type indicating the activity is a stream

1
LISTENING =

Type indicating the activity is for music

2
WATCHING =

This type is currently unused in the client but can be reported by bots

3
CUSTOM =

Type indicating the activity is a custom status

4
COMPETING =

Type indicating the activity is for a competitive game

5

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#application_id ⇒ String? (readonly)

Returns the application ID for the game.

Returns:

  • (String, nil) —

    the application ID for the game



27
28
29
# File 'lib/discordrb/data/activity.rb', line 27

def application_id
  @application_id
end

#assets ⇒ Assets? (readonly)

Returns images for the presence and their texts.

Returns:

  • (Assets, nil) —

    images for the presence and their texts



49
50
51
# File 'lib/discordrb/data/activity.rb', line 49

def assets
  @assets
end

#created_at ⇒ Time (readonly)

Returns the time when the activity was added to the user's session.

Returns:

  • (Time) —

    the time when the activity was added to the user's session



58
59
60
# File 'lib/discordrb/data/activity.rb', line 58

def created_at
  @created_at
end

#details ⇒ String? (readonly)

Returns details about what the player is currently doing.

Returns:

  • (String, nil) —

    details about what the player is currently doing



30
31
32
# File 'lib/discordrb/data/activity.rb', line 30

def details
  @details
end

#emoji ⇒ Emoji? (readonly)

Returns emoji data for custom statuses.

Returns:

  • (Emoji, nil) —

    emoji data for custom statuses



55
56
57
# File 'lib/discordrb/data/activity.rb', line 55

def emoji
  @emoji
end

#flags ⇒ Integer (readonly)

Returns a bitmask of activity flags.

Returns:

  • (Integer) —

    a bitmask of activity flags

See Also:



40
41
42
# File 'lib/discordrb/data/activity.rb', line 40

def flags
  @flags
end

#instance ⇒ true, false (readonly)

Returns whether or not the activity is an instanced game session.

Returns:

  • (true, false) —

    whether or not the activity is an instanced game session



36
37
38
# File 'lib/discordrb/data/activity.rb', line 36

def instance
  @instance
end

#name ⇒ String (readonly)

Returns the activity's name.

Returns:

  • (String) —

    the activity's name



18
19
20
# File 'lib/discordrb/data/activity.rb', line 18

def name
  @name
end

#party ⇒ Party? (readonly)

Returns information about the player's current party.

Returns:

  • (Party, nil) —

    information about the player's current party



52
53
54
# File 'lib/discordrb/data/activity.rb', line 52

def party
  @party
end

#secrets ⇒ Secrets? (readonly)

Returns secrets for rich presence, joining, and spectating.

Returns:

  • (Secrets, nil) —

    secrets for rich presence, joining, and spectating



46
47
48
# File 'lib/discordrb/data/activity.rb', line 46

def secrets
  @secrets
end

#state ⇒ String? (readonly)

Returns the user's current party status.

Returns:

  • (String, nil) —

    the user's current party status



33
34
35
# File 'lib/discordrb/data/activity.rb', line 33

def state
  @state
end

#timestamps ⇒ Timestamps? (readonly)

Returns times for the start and/or end of the activity.

Returns:

  • (Timestamps, nil) —

    times for the start and/or end of the activity



43
44
45
# File 'lib/discordrb/data/activity.rb', line 43

def timestamps
  @timestamps
end

#type ⇒ Integer? (readonly)

Returns activity type. Can be GAME, STREAMING, LISTENING, CUSTOM, or COMPETING.

Returns:



21
22
23
# File 'lib/discordrb/data/activity.rb', line 21

def type
  @type
end

#url ⇒ String? (readonly)

Returns stream URL, when the activity type is STREAMING.

Returns:



24
25
26
# File 'lib/discordrb/data/activity.rb', line 24

def url
  @url
end

Instance Method Details

#instance? ⇒ true, false

Returns Whether or not the instance flag is set for this activity.

Returns:

  • (true, false) —

    Whether or not the instance flag is set for this activity



118
119
120
# File 'lib/discordrb/data/activity.rb', line 118

def instance?
  @instance || flag_set?(:instance)
end

#join? ⇒ true, false

Returns Whether or not the join flag is set for this activity.

Returns:

  • (true, false) —

    Whether or not the join flag is set for this activity



93
94
95
# File 'lib/discordrb/data/activity.rb', line 93

def join?
  flag_set? :join
end

#join_request? ⇒ true, false

Returns Whether or not the join_request flag is set for this activity.

Returns:

  • (true, false) —

    Whether or not the join_request flag is set for this activity



103
104
105
# File 'lib/discordrb/data/activity.rb', line 103

def join_request?
  flag_set? :join_request
end

#play? ⇒ true, false

Returns Whether or not the play flag is set for this activity.

Returns:

  • (true, false) —

    Whether or not the play flag is set for this activity



113
114
115
# File 'lib/discordrb/data/activity.rb', line 113

def play?
  flag_set? :play
end

#spectate? ⇒ true, false

Returns Whether or not the spectate flag is set for this activity.

Returns:

  • (true, false) —

    Whether or not the spectate flag is set for this activity



98
99
100
# File 'lib/discordrb/data/activity.rb', line 98

def spectate?
  flag_set? :spectate
end

#sync? ⇒ true, false

Returns Whether or not the sync flag is set for this activity.

Returns:

  • (true, false) —

    Whether or not the sync flag is set for this activity



108
109
110
# File 'lib/discordrb/data/activity.rb', line 108

def sync?
  flag_set? :sync
end