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_idDiscorb::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

#assetsDiscorb::Presence::Activity::Asset? (readonly)

Returns:



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

def assets
  @assets
end

#buttonsArray<Discorb::Presence::Activity::Button>? (readonly)

Returns:



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

def buttons
  @buttons
end

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

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

#emojiDiscorb::Emoji (readonly)

Returns The emoji of the activity.

Returns:



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

def emoji
  @emoji
end

#flagsDiscorb::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

#instanceDiscorb::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

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

#partyDiscorb::Presence::Activity::Party? (readonly)

Returns:



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

def party
  @party
end

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

#timestampsDiscorb::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

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

Convert the activity to a string.

Returns:

  • (String)

    The string representation of the activity.



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/discorb/presence.rb', line 136

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}"
  else
    raise "Unknown activity type: #{@type}"
  end
end