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?, #inspect

Instance Attribute Details

#application_id -> Discorb::Snowflake (readonly)

Returns The application id of the activity.

Returns:



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

def application_id
  @application_id
end

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

Returns:



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

def assets
  @assets
end

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

Returns:



85
86
87
# File 'lib/discorb/presence.rb', line 85

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.



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

def created_at
  @created_at
end

#details -> String (readonly)

Returns The details of the activity.

Returns:

  • (String)

    The details of the activity.



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

def details
  @details
end

#emoji -> Discorb::Emoji (readonly)

Returns The emoji of the activity.

Returns:



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

def emoji
  @emoji
end

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

Returns The flags of the activity.

Returns:



87
88
89
# File 'lib/discorb/presence.rb', line 87

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.



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

def instance
  @instance
end

#name -> String (readonly)

Returns The name of the activity.

Returns:

  • (String)

    The name of the activity.



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

def name
  @name
end

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

Returns:



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

def party
  @party
end

#state -> String (readonly)

Returns The state of party.

Returns:

  • (String)

    The state of party.



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

def state
  @state
end

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

Returns The timestamps of the activity.

Returns:



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

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.



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

def type
  @type
end

#url -> String (readonly)

Returns The url of the activity.

Returns:

  • (String)

    The url of the activity.



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

def url
  @url
end

Instance Method Details

#to_s -> String

Convert the activity to a string.

Returns:

  • (String)

    The string representation of the activity.



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/discorb/presence.rb', line 130

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