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