Class: DBio::SearchResult

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

Overview

A shorter version of a user's details

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ SearchResult

Initialize the result


4
5
6
# File 'lib/dbio/search_result.rb', line 4

def initialize(data)
  @data = data
end

Instance Method Details

#descriptionString

Returns this user's description.

Returns:

  • (String)

    this user's description


54
55
56
# File 'lib/dbio/search_result.rb', line 54

def description
  @data['user']['description']
end

#discord_avatarString

Returns this result's discord avatar hash.

Returns:

  • (String)

    this result's discord avatar hash


29
30
31
# File 'lib/dbio/search_result.rb', line 29

def discord_avatar
  @data['discord']['avatar']
end

#discord_discriminatorString

Returns this result's discord discriminator.

Returns:

  • (String)

    this result's discord discriminator


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

def discord_discriminator
  @data['discord']['discriminator']
end

#discord_idInteger

Returns this result's discord ID.

Returns:

  • (Integer)

    this result's discord ID


24
25
26
# File 'lib/dbio/search_result.rb', line 24

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

#discord_usernameString

Returns this result's discord username.

Returns:

  • (String)

    this result's discord username


14
15
16
# File 'lib/dbio/search_result.rb', line 14

def discord_username
  @data['discord']['username']
end

#premium?Boolean

Returns if this user is a premium user.

Returns:

  • (Boolean)

    if this user is a premium user


44
45
46
# File 'lib/dbio/search_result.rb', line 44

def premium?
  @data['user']['premium']
end

#slugObject

The slug of this result's user.


9
10
11
# File 'lib/dbio/search_result.rb', line 9

def slug
  @data['user']['slug']
end

#staff?Boolean

Returns if this user is a discord.bio staff member.

Returns:

  • (Boolean)

    if this user is a discord.bio staff member


39
40
41
# File 'lib/dbio/search_result.rb', line 39

def staff?
  @data['user']['staff']
end

#upvotesInteger

Returns this user's upvotes.

Returns:

  • (Integer)

    this user's upvotes


49
50
51
# File 'lib/dbio/search_result.rb', line 49

def upvotes
  @data['user']['upvotes']
end

#userUser

The user itself, for more detail

Returns:

  • (User)

    the user


60
61
62
63
64
# File 'lib/dbio/search_result.rb', line 60

def user
  user = JSON.parse(RestClient.get("https://api.discord.bio/v1/user/details/#{slug}"))

  DBio::User.new(user['payload'])
end

#verified?Boolean

Returns if this user is verified.

Returns:

  • (Boolean)

    if this user is verified


34
35
36
# File 'lib/dbio/search_result.rb', line 34

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