Class: Discorb::Presence::Activity

Inherits:
DiscordModel show all
Defined in:
lib/discorb/presence.rb

Overview

Represents an activity of a user.

Defined Under Namespace

Classes: Asset, Button, Flag, Party, Secrets, Timestamps

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DiscordModel

#==, #eql?

Instance Attribute Details

#application_id -> Discorb::Snowflake (readonly)

Returns The application id of the activity.

Returns:



61
62
63
# File 'lib/discorb/presence.rb', line 61

def application_id
  @application_id
end

#assets -> Discorb::Presence::Activity::Asset? (readonly)

Returns:



73
74
75
# File 'lib/discorb/presence.rb', line 73

def assets
  @assets
end

#buttons -> Array<Discorb::Presence::Activity::Button>? (readonly)

Returns:



79
80
81
# File 'lib/discorb/presence.rb', line 79

def buttons
  @buttons
end

#created_at -> Time (readonly) Also known as: started_at

Returns The time the activity was created.

Returns:

  • (Time)

    The time the activity was created.



56
57
58
# File 'lib/discorb/presence.rb', line 56

def created_at
  @created_at
end

#details -> String (readonly)

Returns The details of the activity.

Returns:

  • (String)

    The details of the activity.



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

def details
  @details
end

#emoji -> Discorb::Emoji (readonly)

Returns The emoji of the activity.

Returns:



67
68
69
# File 'lib/discorb/presence.rb', line 67

def emoji
  @emoji
end

#flags -> Discorb::Presence::Activity::Flag (readonly)

Returns The flags of the activity.

Returns:



81
82
83
# File 'lib/discorb/presence.rb', line 81

def flags
  @flags
end

#instance -> Discorb::StageInstance? (readonly)

Returns:

  • (Discorb::StageInstance)

    The instance of the activity.

  • (nil)

    If the activity is not a stage activity.



76
77
78
# File 'lib/discorb/presence.rb', line 76

def instance
  @instance
end

#name -> String (readonly)

Returns The name of the activity.

Returns:

  • (String)

    The name of the activity.



50
51
52
# File 'lib/discorb/presence.rb', line 50

def name
  @name
end

#party -> Discorb::Presence::Activity::Party? (readonly)

Returns:



70
71
72
# File 'lib/discorb/presence.rb', line 70

def party
  @party
end

#state -> String (readonly)

Returns The state of party.

Returns:

  • (String)

    The state of party.



65
66
67
# File 'lib/discorb/presence.rb', line 65

def state
  @state
end

#timestamps -> Discorb::Presence::Activity::Timestamps (readonly)

Returns The timestamps of the activity.

Returns:



59
60
61
# File 'lib/discorb/presence.rb', line 59

def timestamps
  @timestamps
end

#type -> :game, ... (readonly)

Returns The type of the activity.

Returns:

  • (:game, :streaming, :listening, :watching, :custom, :competing)

    The type of the activity.



52
53
54
# File 'lib/discorb/presence.rb', line 52

def type
  @type
end

#url -> String (readonly)

Returns The url of the activity.

Returns:

  • (String)

    The url of the activity.



54
55
56
# File 'lib/discorb/presence.rb', line 54

def url
  @url
end

Instance Method Details

#to_s -> String

Convert the activity to a string.

Returns:

  • (String)

    The string representation of the activity.



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/discorb/presence.rb', line 117

def to_s
  case @type
  when :game
    "Playing #{@name}"
  when :streaming
    "Streaming #{@details}"
  when :listening
    "Listening to #{@name}"
  when :watching
    "Watching #{@name}"
  when :custom
    "#{@emoji} #{@state}"
  when :competing
    "Competing in #{@name}"
  end
end