class Discorb::Activity

Represents an activity for Gateway Command.

Attributes

types[R]

@!visibility private

Public Class Methods

new(name, type = :playing, url = nil) click to toggle source

Initializes a new Activity.

@param [String] name The name of the activity. @param [:playing, :streaming, :listening, :watching, :competing] type The type of activity. @param [String] url The URL of the activity.

# File lib/discorb/gateway_requests.rb, line 23
def initialize(name, type = :playing, url = nil)
  @name = name
  @type = self.class.types[type]
  @url = url
end

Public Instance Methods

to_hash() click to toggle source

Converts the activity to a hash.

@return [Hash] A hash representation of the activity.

# File lib/discorb/gateway_requests.rb, line 34
def to_hash
  {
    name: @name,
    type: @type,
    url: @url,
  }
end