Class: DBLRuby::User

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

Overview

Find information about users.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ User

Initialize the user

Parameters:

  • data (JSON)

    User object in JSON form.


5
6
7
# File 'lib/dblruby/user.rb', line 5

def initialize(data)
  @data = data
end

Instance Attribute Details

#dataObject (readonly) Also known as: to_s

Returns data in raw json form.

Returns:

  • data in raw json form.


10
11
12
# File 'lib/dblruby/user.rb', line 10

def data
  @data
end

Instance Method Details

#admin?true, false Also known as: admin

The admin status of the user.

Returns:

  • (true, false)

    the user's admin status.


169
170
171
# File 'lib/dblruby/user.rb', line 169

def admin?
  @data['admin']
end

#avatarString

The avatar hash of the user's avatar.

Returns:

  • (String)

    the user's avatar hash.


61
62
63
# File 'lib/dblruby/user.rb', line 61

def avatar
  @data['avatar']
end

#avatar_imgString

Get's the user's avatar as an img, ready to be used in image linking.

Returns:

  • (String)

    the user's avatar link.


67
68
69
# File 'lib/dblruby/user.rb', line 67

def avatar_img
  "https://cdn.discordapp.com/avatars/#{id}/#{avatar}.webp?size=1024"
end

The banner image url of the user

Returns:

  • (String)

    the banner image url.


79
80
81
# File 'lib/dblruby/user.rb', line 79

def banner
  @data['banner']
end

#bioString

The bio of the user.

Returns:

  • (String)

    the user's bio.


73
74
75
# File 'lib/dblruby/user.rb', line 73

def bio
  @data['bio']
end

#certified?true, false Also known as: certified

The certified status of the user.

Returns:

  • (true, false)

    the user's certified status.


143
144
145
# File 'lib/dblruby/user.rb', line 143

def certified?
  @data['certifiedDev']
end

#colorString Also known as: colour

The custom hex color of the user.

Returns:

  • (String)

    the user's hex code for their page.


127
128
129
# File 'lib/dblruby/user.rb', line 127

def color
  @data['color']
end

#defavatarString

The cdn hash of the user's avatar if the user has none.

Returns:

  • (String)

    the user's defAvatar.


55
56
57
# File 'lib/dblruby/user.rb', line 55

def defavatar
  @data['defAvatar']
end

#discriminatorInteger Also known as: discrim, tag

The discriminator of the user.

Returns:

  • (Integer)

    the user's discriminator without the #.


40
41
42
# File 'lib/dblruby/user.rb', line 40

def discriminator
  @data['discriminator'].delete('#')
end

#distinctString

Returns the user's distinct, which is the Username and Discriminator.

Returns:

  • (String)

    the user's username + discrim.


49
50
51
# File 'lib/dblruby/user.rb', line 49

def distinct
  "#{username}\##{tag}"
end

#errorString?

Return the error if there is one, nil otherwise.

Returns:

  • (String, nil)

    the error.


16
17
18
# File 'lib/dblruby/user.rb', line 16

def error
  @data['error']
end

#error?true, false

Return true if there is an error, false otherwise.

Returns:

  • (true, false)

    if there is an error.


22
23
24
# File 'lib/dblruby/user.rb', line 22

def error?
  !@data['error'].nil?
end

#githubString

The github username of the user.

Returns:

  • (String)

    the user's github link.


121
122
123
# File 'lib/dblruby/user.rb', line 121

def github
  @data['social']['github']
end

#idInteger

The id of the user.

Returns:

  • (Integer)

    User ID in integer form.


28
29
30
# File 'lib/dblruby/user.rb', line 28

def id
  @data['id'].to_i
end

#instagramString

The instagram username of the user.

Returns:

  • (String)

    the user's instagram link.


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

def instagram
  @data['social']['instagram']
end

#mod?true, false Also known as: mod

The mod status of the user.

Returns:

  • (true, false)

    the user's mod status.


153
154
155
# File 'lib/dblruby/user.rb', line 153

def mod?
  @data['mod']
end

#redditString

The reddit username of the user.

Returns:

  • (String)

    the user's reddit link.


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

def reddit
  @data['social']['reddit']
end

#socialHash<String, String>

The social usernames of the user.

Returns:

  • (Hash<String, String>)

    the user's social links.


85
86
87
# File 'lib/dblruby/user.rb', line 85

def social
  @data['social']
end

#social?true, false

Does the user have any social links? True if so, false if not.

Returns:

  • (true, false)

    if the user has any social links.


91
92
93
# File 'lib/dblruby/user.rb', line 91

def social?
  @data['social'] != {}
end

#supporter?true, false Also known as: supporter

The supporter status of the user.

Returns:

  • (true, false)

    the user's supporter status.


135
136
137
# File 'lib/dblruby/user.rb', line 135

def supporter?
  @data['supporter']
end

#twitterString

The twitter username of the user.

Returns:

  • (String)

    the user's twitter link.


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

def twitter
  @data['social']['twitter']
end

#usernameString

The username of the user.

Returns:

  • (String)

    the user's username.


34
35
36
# File 'lib/dblruby/user.rb', line 34

def username
  @data['username']
end

#webmod?true, false Also known as: webmod

The website moderator status of the user.

Returns:

  • (true, false)

    the user's website mod status.


161
162
163
# File 'lib/dblruby/user.rb', line 161

def webmod?
  @data['webMod']
end

#youtubeString

The youtube channel id of the user.

Returns:

  • (String)

    the user's youtube channel link.


97
98
99
# File 'lib/dblruby/user.rb', line 97

def youtube
  @data['social']['youtube']
end