Class: DList::User::Client

Inherits:
Object
  • Object
show all
Includes:
Actions, Boosting, Information, Notifications, Rating, Verification, Voting
Defined in:
lib/dblista/user/client.rb

Overview

DList user client

Examples:

Server voting

client = DList::User::Client.new "USER_TOKEN"
client.vote(123456789012345678, :server)

Bot rating

client = DList::User::Client.new "USER_TOKEN"
client.rate(123456789012345678, 5, 'Nice bot')

Constant Summary collapse

ALLOWED_TYPES =

Allowed entity types to use

%i[bot server].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Information

#bots, #servers

Methods included from Verification

#approve, #reject, #set_pending

Methods included from Notifications

#clear_notifications, #notifications, #send_group_notification, #send_notification

Methods included from Rating

#delete_rate, #delete_report, #rate, #report_rate, #reports

Methods included from Boosting

#boost, #delete_boost

Methods included from Actions

#add, #delete, #edit, #generate_token, #manage_user, #reset_token

Methods included from Voting

#vote

Constructor Details

#initialize(token) ⇒ Client

Returns a new instance of Client.

Raises:



38
39
40
41
42
43
44
45
# File 'lib/dblista/user/client.rb', line 38

def initialize(token)
  raise DList::Error, DList::Errors::TOKEN_NOT_PROVIDED unless token

  @token = token
  @cache = Zache.new

  me
end

Instance Attribute Details

#tokenObject

Returns the value of attribute token.



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

def token
  @token
end

Instance Method Details

#joined_guildsHash

Fetches current user guilds

Returns:

  • (Hash)

    raw data from DList



59
60
61
62
63
# File 'lib/dblista/user/client.rb', line 59

def joined_guilds
  @cache.get(:guilds, lifetime: DList::CACHE_LIFETIME) do
    DList._get('/users/me/guilds', @token)
  end
end

#meHash

Fetches information about current user

Returns:

  • (Hash)

    raw data from DList



50
51
52
53
54
# File 'lib/dblista/user/client.rb', line 50

def me
  @cache.get(:guilds, lifetime: DList::CACHE_LIFETIME) do
    DList._get('/users/me', @token)
  end
end