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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#application_idString? (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

#assetsAssets? (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_atTime (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

#detailsString? (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

#emojiEmoji? (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

#flagsInteger (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

#instancetrue, 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

#nameString (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

#partyParty? (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

#secretsSecrets? (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

#stateString? (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

#timestampsTimestamps? (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

#typeInteger? (readonly)

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

Returns:


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

def type
  @type
end

#urlString? (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


116
117
118
# File 'lib/discordrb/data/activity.rb', line 116

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


91
92
93
# File 'lib/discordrb/data/activity.rb', line 91

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


101
102
103
# File 'lib/discordrb/data/activity.rb', line 101

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


111
112
113
# File 'lib/discordrb/data/activity.rb', line 111

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


96
97
98
# File 'lib/discordrb/data/activity.rb', line 96

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


106
107
108
# File 'lib/discordrb/data/activity.rb', line 106

def sync?
  flag_set? :sync
end