class Discordrb::Activity

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

Constants

COMPETING

Type indicating the activity is for a competitive game

CUSTOM

Type indicating the activity is a custom status

FLAGS

Values corresponding to the flags bitmask

GAME

Type indicating the activity is for a game

LISTENING

Type indicating the activity is for music

STREAMING

Type indicating the activity is a stream

WATCHING

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

Attributes

application_id[R]

@return [String, nil] the application ID for the game

assets[R]

@return [Assets, nil] images for the presence and their texts

created_at[R]

@return [Time] the time when the activity was added to the user’s session

details[R]

@return [String, nil] details about what the player is currently doing

emoji[R]

@return [Emoji, nil] emoji data for custom statuses

flags[R]

@return [Integer] a bitmask of activity flags @see FLAGS

instance[R]

@return [true, false] whether or not the activity is an instanced game session

name[R]

@return [String] the activity’s name

party[R]

@return [Party, nil] information about the player’s current party

secrets[R]

@return [Secrets, nil] secrets for rich presence, joining, and spectating

state[R]

@return [String, nil] the user’s current party status

timestamps[R]

@return [Timestamps, nil] times for the start and/or end of the activity

type[R]

@return [Integer, nil] activity type. Can be {GAME}, {STREAMING}, {LISTENING}, {CUSTOM}, or {COMPETING}

url[R]

@return [String, nil] stream URL, when the activity type is {STREAMING}

Public Class Methods

new(data, bot) click to toggle source

@!visibility private

# File lib/discordrb/data/activity.rb, line 74
def initialize(data, bot)
  @name = data['name']
  @type = data['type']
  @url = data['url']
  @application_id = data['application_id']
  @details = data['details']
  @state = data['state']
  @instance = data['instance']
  @flags = data['flags'] || 0
  @created_at = Time.at(data['created_at'].to_i)

  @timestamps = Timestamps.new(data['timestamps']) if data['timestamps']
  @secrets = Secret.new(data['secrets']) if data['secrets']
  @assets = Assets.new(data['assets'], @application_id) if data['assets']
  @party = Party.new(data['party']) if data['party']
  @emoji = Emoji.new(data['emoji'], bot, nil) if data['emoji']
end

Public Instance Methods

flag_set?(sym) click to toggle source

@!visibility private

# File lib/discordrb/data/activity.rb, line 123
def flag_set?(sym)
  !(@flags & FLAGS[sym]).zero?
end
instance?() click to toggle source

@return [true, false] Whether or not the ‘instance` flag is set for this activity

# File lib/discordrb/data/activity.rb, line 118
def instance?
  @instance || flag_set?(:instance)
end
join?() click to toggle source

@return [true, false] Whether or not the ‘join` flag is set for this activity

# File lib/discordrb/data/activity.rb, line 93
def join?
  flag_set? :join
end
join_request?() click to toggle source

@return [true, false] Whether or not the ‘join_request` flag is set for this activity

# File lib/discordrb/data/activity.rb, line 103
def join_request?
  flag_set? :join_request
end
play?() click to toggle source

@return [true, false] Whether or not the ‘play` flag is set for this activity

# File lib/discordrb/data/activity.rb, line 113
def play?
  flag_set? :play
end
spectate?() click to toggle source

@return [true, false] Whether or not the ‘spectate` flag is set for this activity

# File lib/discordrb/data/activity.rb, line 98
def spectate?
  flag_set? :spectate
end
sync?() click to toggle source

@return [true, false] Whether or not the ‘sync` flag is set for this activity

# File lib/discordrb/data/activity.rb, line 108
def sync?
  flag_set? :sync
end