class DBio::User

Find information about users.

Attributes

data[R]

@return data in raw json form.

to_s[R]

@return data in raw json form.

Public Class Methods

new(data) click to toggle source

Initialize the user

# File lib/dbio/user.rb, line 4
def initialize(data)
  @user = data['user']['details']
  @discord = data['discord']
  @discord_connections = data['user']['discordConnections']
  @user_connections = data['user']['user_connections']
end

Public Instance Methods

banner_url() click to toggle source

@return [String, nil] the user's banner, if one is set

birthday() click to toggle source

@return [Date, nil] the birthdate of this user, if one is set

# File lib/dbio/user.rb, line 90
def birthday
  Date.parse(@user['birthday'])
end
created() click to toggle source

@return [Time] The time this user was created

# File lib/dbio/user.rb, line 58
def created
  Time.parse(@user['created_at'])
end
description() click to toggle source

@return [String, nil] the description for this user, if one is set.

# File lib/dbio/user.rb, line 63
def description
  @user['description']
end
discord_connections() click to toggle source

This is the user's Discord connections as they appear on their Discord profile @return [Array<DiscordConnection>] the user's discord connections

# File lib/dbio/user.rb, line 129
def discord_connections
  @discord_connections.map { |e| DBio::DiscordConnection.new(e) }
end
discord_profile() click to toggle source

The user's Discord profile information, not overly specific either. I instead recommend just getting it though your Discord Library with the ID @see [User#id]

# File lib/dbio/user.rb, line 142
def discord_profile
  DBio::DiscordProfile.new(@discord)
end
email() click to toggle source

@return [String, nil] the user's email, if one is set

# File lib/dbio/user.rb, line 95
def email
  @user['email']
end
flags() click to toggle source

The oauth flags for this user. Not useful on their own. @see DBio::DiscordProfile#public_flags @return [Integer] the flags for this user

# File lib/dbio/user.rb, line 48
def flags
  @user['flags']
end
gender() click to toggle source

The API returns an integer, so this is converted to a String. @return [String, nil] the gender of this user in String form.

# File lib/dbio/user.rb, line 74
def gender
  case @user['gender']
  when 0
    "Male"
  when 1
    "Female"
  when 2
    "Non-Binary"
  when nil
    "Undisclosed"
  else
    nil
  end
end
id() click to toggle source

The id of the user. @return [Integer] User ID in integer form.

# File lib/dbio/user.rb, line 31
def id
  @user['user_id'].to_i
end
likes() click to toggle source

@return [Integer] the amount of likes this user has.

# File lib/dbio/user.rb, line 36
def likes
  @user['likes']
end
Also aliased as: upvotes
location() click to toggle source

@return [String, nil] the location for this user, if one is set.

# File lib/dbio/user.rb, line 68
def location
  @user['location']
end
occupation() click to toggle source

@return [String, nil] the user's occupation, if one is set

# File lib/dbio/user.rb, line 100
def occupation
  @user['occupation']
end
premium?() click to toggle source

@return [Boolean] the user's premium status

# File lib/dbio/user.rb, line 110
def premium?
  @user['premium']
end
premium_type() click to toggle source

The premium type as found on Discord. ezpz way to see if they're Nitro. For Types, see discord.com/developers/docs/resources/user#user-object-premium-types @return [Integer] this user's premium type

# File lib/dbio/user.rb, line 123
def premium_type
  @user['premium_type']
end
profile_url() click to toggle source

The link to this user's profile @return [String] this user's profile

# File lib/dbio/user.rb, line 25
def profile_url
  "https://dsc.bio/#{slug}"
end
slug() click to toggle source

The slug of this user. Use: dsc.bio/slug @see User#profile_url @return [String] the slug

# File lib/dbio/user.rb, line 19
def slug
  @user['slug']
end
staff?() click to toggle source

@return [Boolean] the user's staff status

# File lib/dbio/user.rb, line 115
def staff?
  @user['staff']
end
upvotes()

This simply returns the likes, switch to likes. @deprecated @see [likes]

Alias for: likes
user_connections() click to toggle source

The user's Discord.Bio connections. Not as specific. @return [Array<UserConnection>] the user's discord.bio connections

# File lib/dbio/user.rb, line 135
def user_connections
  @user_connections.map { |e, f| DBio::UserConnection.new({ "type": e, "name": f }) }
end
verified?() click to toggle source

@return [boolean] if this user is verified

# File lib/dbio/user.rb, line 53
def verified?
  @user['verified']
end