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
@return [String, nil] the application ID for the game
@return [Assets, nil] images for the presence and their texts
@return [Time] the time when the activity was added to the user’s session
@return [String, nil] details about what the player is currently doing
@return [Emoji, nil] emoji data for custom statuses
@return [Integer] a bitmask of activity flags @see FLAGS
@return [true, false] whether or not the activity is an instanced game session
@return [String] the activity’s name
@return [Party, nil] information about the player’s current party
@return [Secrets, nil] secrets for rich presence, joining, and spectating
@return [String, nil] the user’s current party status
@return [Timestamps, nil] times for the start and/or end of the activity
@return [Integer, nil] activity type. Can be {GAME}, {STREAMING}, {LISTENING}, {CUSTOM}, or {COMPETING}
@return [String, nil] stream URL, when the activity type is {STREAMING}
Public Class Methods
@!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
@!visibility private
# File lib/discordrb/data/activity.rb, line 123 def flag_set?(sym) !(@flags & FLAGS[sym]).zero? end
@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
@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
@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
@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
@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
@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