Class: ListCordRB::Stats

Inherits:
Object
  • Object
show all
Defined in:
lib/listcordrb/stats.rb

Overview

Stats and stuff, ya know.

Instance Method Summary collapse

Constructor Details

#initialize(apikey, id) ⇒ Stats

Initialize the stats Program does this automatically when running ListCordRB.new.



5
6
7
8
# File 'lib/listcordrb/stats.rb', line 5

def initialize(apikey, id)
  @api = apikey
  @id = id
end

Instance Method Details

#serversObject Also known as: servercount

Get the server count, returns an int.



11
12
13
14
# File 'lib/listcordrb/stats.rb', line 11

def servers
  url = "https://listcord.com/api/bot/#{@id}"
  JSON.parse(RestClient.get(url))['servers'].to_i
end

#servers=(count, shard = nil) ⇒ Object Also known as: updateservers

Update the bot’s server count.



19
20
21
22
23
24
25
26
# File 'lib/listcordrb/stats.rb', line 19

def servers=(count, shard = nil)
  url = "https://listcord.com/api/bot/#{@id}/guilds"
  json = {
    'guilds' => count.to_s,
    'shard' => shard.to_s
  }
  RestClient.post(url, json, :Authorization => @api, :'Content-Type' => :json)
end