Class: DBio::User

Inherits:
Object
  • Object
show all
Defined in:
lib/dbio/user.rb

Overview

Find information about users.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ User

Initialize the user


4
5
6
7
8
9
# 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

Instance Attribute Details

#dataObject (readonly) Also known as: to_s

Returns data in raw json form.

Returns:

  • data in raw json form.


12
13
14
# File 'lib/dbio/user.rb', line 12

def data
  @data
end

Instance Method Details

Returns the user's banner, if one is set.

Returns:

  • (String, nil)

    the user's banner, if one is set


93
94
95
# File 'lib/dbio/user.rb', line 93

def banner_url
  @user['banner']
end

#birthdayDate?

Returns the birthdate of this user, if one is set.

Returns:

  • (Date, nil)

    the birthdate of this user, if one is set


78
79
80
# File 'lib/dbio/user.rb', line 78

def birthday
  Date.parse(@user['birthday'])
end

#createdTime

Returns The time this user was created.

Returns:

  • (Time)

    The time this user was created


46
47
48
# File 'lib/dbio/user.rb', line 46

def created
  Time.parse(@user['created_at'])
end

#descriptionString?

Returns the description for this user, if one is set.

Returns:

  • (String, nil)

    the description for this user, if one is set.


51
52
53
# File 'lib/dbio/user.rb', line 51

def description
  @user['description']
end

#discord_connectionsArray<DiscordConnection>

This is the user's Discord connections as they appear on their Discord profile

Returns:


109
110
111
# File 'lib/dbio/user.rb', line 109

def discord_connections
  @discord_connections.map{ |e| DBio::DiscordConnection.new(e) }
end

#discord_profileObject

The user's Discord profile information, not overly specific either. I instead recommend just getting it though your Discord Library with the ID

See Also:

  • DBio::User.[User[User#id]

122
123
124
# File 'lib/dbio/user.rb', line 122

def discord_profile
  DBio::DiscordProfile.new(@discord)
end

#emailString?

Returns the user's email, if one is set.

Returns:

  • (String, nil)

    the user's email, if one is set


83
84
85
# File 'lib/dbio/user.rb', line 83

def email
  @user['email']
end

#flagsInteger

The flags for this user. Not entirely sure what they mean, but they're there.

Returns:

  • (Integer)

    the flags for this user


36
37
38
# File 'lib/dbio/user.rb', line 36

def flags
  @user['flags']
end

#genderString?

The API returns an integer, so this is converted to a String.

Returns:

  • (String, nil)

    the gender of this user in String form.


62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/dbio/user.rb', line 62

def gender
  case @user['gender']
  when 0
    "Male"
  when 1
    "Female"
  when 2
    "Non-Binary"
  when nil
    "Undisclosed"
  else
    nil
  end
end

#idInteger

The id of the user.

Returns:

  • (Integer)

    User ID in integer form.


25
26
27
# File 'lib/dbio/user.rb', line 25

def id
  @user['user_id'].to_i
end

#locationString?

Returns the location for this user, if one is set.

Returns:

  • (String, nil)

    the location for this user, if one is set.


56
57
58
# File 'lib/dbio/user.rb', line 56

def location
  @user['location']
end

#occupationString?

Returns the user's occupation, if one is set.

Returns:

  • (String, nil)

    the user's occupation, if one is set


88
89
90
# File 'lib/dbio/user.rb', line 88

def occupation
  @user['occupation']
end

#premium?Boolean

Returns the user's premium status.

Returns:

  • (Boolean)

    the user's premium status


98
99
100
# File 'lib/dbio/user.rb', line 98

def premium?
  @user['premium']
end

#slugString

The slug of this user. Use: dsc.bio/slug

Returns:

  • (String)

    the slug

See Also:

  • DBio::User.[User[User#profile_url]

19
20
21
# File 'lib/dbio/user.rb', line 19

def slug
  @user['slug']
end

#staff?Boolean

Returns the user's staff status.

Returns:

  • (Boolean)

    the user's staff status


103
104
105
# File 'lib/dbio/user.rb', line 103

def staff?
  @user['staff']
end

#upvotesInteger

Returns the amount of upvotes this user has.

Returns:

  • (Integer)

    the amount of upvotes this user has.


30
31
32
# File 'lib/dbio/user.rb', line 30

def upvotes
  @user['upvotes']
end

#user_connectionsArray<UserConnection>

The user's Discord.Bio connections. Not as specific.

Returns:


115
116
117
# File 'lib/dbio/user.rb', line 115

def user_connections
  @user_connections.map { |e, f| DBio::UserConnection.new({ "type": e, "name": f }) }
end

#verified?boolean

Returns if this user is verified.

Returns:

  • (boolean)

    if this user is verified


41
42
43
# File 'lib/dbio/user.rb', line 41

def verified?
  @user['verified'] == 1
end