Module: DBLista::User::Actions
- Included in:
- Client
- Defined in:
- lib/dblista/user/actions.rb
Overview
User client - actions
Instance Method Summary collapse
-
#add(body, type = 'bot') ⇒ Boolean
Adds bot/server to DBLista.
-
#delete(id, type = :bot) ⇒ Boolean
Deletes bot/server from DBLista.
-
#edit(body, type = :bot) ⇒ Boolean
Edits bot/server in DBLista.
-
#generate_token(id) ⇒ Hash
Generates token for bot.
-
#manage_user(id, banned = false, premium = 0) ⇒ Boolean
Manages user (bans or adds premium) Available only for DBLista staff.
-
#reset_token(id) ⇒ Hash
Resets token for bot.
Instance Method Details
#add(body, type = 'bot') ⇒ Boolean
Adds bot/server to DBLista
13 14 15 16 17 18 19 |
# File 'lib/dblista/user/actions.rb', line 13 def add(body, type = 'bot') raise DBLista::Error, DBLista::Errors::BODY_HASH unless body.is_a?(Hash) raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type) DBLista._post("/#{type}s", body, @token) true end |
#delete(id, type = :bot) ⇒ Boolean
Deletes bot/server from DBLista
39 40 41 42 43 44 45 |
# File 'lib/dblista/user/actions.rb', line 39 def delete(id, type = :bot) DBLista._validate_id id raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type) DBLista._delete("/#{type}s/#{id}", nil, @token) true end |
#edit(body, type = :bot) ⇒ Boolean
Edits bot/server in DBLista
26 27 28 29 30 31 32 |
# File 'lib/dblista/user/actions.rb', line 26 def edit(body, type = :bot) raise DBLista::Error, DBLista::Errors::BODY_HASH unless body.is_a?(Hash) raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type) DBLista._put("/#{type}s", body, @token) true end |
#generate_token(id) ⇒ Hash
Generates token for bot
66 67 68 69 |
# File 'lib/dblista/user/actions.rb', line 66 def generate_token(id) DBLista._validate_id id DBLista._get("/bots/stats/#{id}?token=#{@token}") end |
#manage_user(id, banned = false, premium = 0) ⇒ Boolean
Manages user (bans or adds premium) Available only for DBLista staff
54 55 56 57 58 59 60 |
# File 'lib/dblista/user/actions.rb', line 54 def manage_user(id, banned = false, premium = 0) DBLista._post("/users/#{id}/manage", { premium: premium, ban: banned }, @token) true end |