dblruby 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63fce355427db5e0ccc5261f36ace592372f7562
4
- data.tar.gz: 4bfd62fa6caa062ec8df81d955fbdbe085db0404
3
+ metadata.gz: 7b9103881719519a19041d666e8d5331f22fe533
4
+ data.tar.gz: f6bef8afcee08ab9b43d4cef642bf733f7d73058
5
5
  SHA512:
6
- metadata.gz: d73ffedc5fec86dbacf51449904ad02470d3d4950a8b36bf49f249db6900022c4c04b084d4d0f21b0aa0720c256a80b918144b9cae35b3f232a421a82cabea45
7
- data.tar.gz: fa724a53740a95390fa632fb6fd0807dc38e6200d8d67dfa245b5cc2ee3c836ebd52e69045d0462cbca016db1d97e89614c1a40e2b21e58dc0c89767169dc120
6
+ metadata.gz: 830532b284bd3779a1ed8fb4b3f56ef9f3765a644ef8747505504ca4f34ca2c96e4cd987a6f025a0f471b347089c702cd48f8486dc6e13b3d1ac8151f2f9445e
7
+ data.tar.gz: 772436ae4995bb95f9969f81c6ce9e5b4dea8bd1626d8775e4a251a4d38019c9acf1c20d0014ef8d9f8471cbda77f61afe138dbadbbe59864a41796729f005ef
@@ -1,3 +1,4 @@
1
+ # Require external gems
1
2
  require 'json'
2
3
  require 'rest-client'
3
4
 
@@ -15,7 +16,15 @@ class DBLRuby
15
16
  @stats = Stats.new(@api, @id)
16
17
  end
17
18
 
19
+ def loadbot(id)
20
+ @bot = Bot.new(id)
21
+ end
22
+
23
+ attr_reader :bot
18
24
  attr_reader :stats
19
25
  end
20
26
 
27
+ # Require files.
28
+ require 'dblruby/bot'
29
+ require 'dblruby/errors'
21
30
  require 'dblruby/stats'
@@ -0,0 +1,137 @@
1
+ # Find information about bots.
2
+ class DBLRuby::Bot
3
+ # Initialize the bot
4
+ # @param id [Integer, String] Integer/String ID of bot you're requesting.
5
+ def initialize(id)
6
+ url = "https://discordbots.org/api/bots/#{id}"
7
+ @data = JSON.parse(RestClient.get(url))
8
+ end
9
+
10
+ # @return data in raw json form.
11
+ attr_reader :data
12
+
13
+ # Get the bot's invite link.
14
+ def invite
15
+ @data['invite']
16
+ end
17
+
18
+ # Get the bot's GitHub Repo link.
19
+ def github
20
+ @data['github']
21
+ end
22
+
23
+ def website
24
+ @data['website']
25
+ end
26
+
27
+ def longdesc
28
+ @data['longdesc']
29
+ end
30
+
31
+ def shortdesc
32
+ @data['shortdesc']
33
+ end
34
+
35
+ def prefix
36
+ @data['prefix']
37
+ end
38
+
39
+ def lib
40
+ @data['lib']
41
+ end
42
+
43
+ def clientid
44
+ @data['clientid']
45
+ end
46
+
47
+ def avatar
48
+ @data['avatar']
49
+ end
50
+
51
+ def avatar_img
52
+ "https://cdn.discordapp.com/avatars/#{id}/#{avatar}.webp?size=1024"
53
+ end
54
+
55
+ def id
56
+ @data['id']
57
+ end
58
+
59
+ def discriminator
60
+ @data['discriminator']
61
+ end
62
+
63
+ alias discrim discriminator
64
+ alias tag discriminator
65
+
66
+ def username
67
+ @data['username']
68
+ end
69
+
70
+ def date
71
+ @data['date']
72
+ end
73
+
74
+ def support
75
+ @data['support']
76
+ end
77
+
78
+ def support_link
79
+ "https://discord.gg/#{support}"
80
+ end
81
+
82
+ # Get the bot's server count
83
+ def server_count
84
+ @data['server_count']
85
+ end
86
+
87
+ alias guild_count server_count
88
+ alias server server_count
89
+
90
+ def guilds
91
+ @data['guilds']
92
+ end
93
+
94
+ alias servers guilds
95
+
96
+ def shards
97
+ @data['shards']
98
+ end
99
+
100
+ def monthlypoints
101
+ @data['monthlyPoints']
102
+ end
103
+
104
+ alias monthlyvotes monthlypoints
105
+
106
+ def points
107
+ @data['points']
108
+ end
109
+
110
+ alias votes points
111
+
112
+ def certifiedbot
113
+ @data['certifiedBot']
114
+ end
115
+
116
+ alias certified? certifiedbot
117
+ alias certified certifiedbot
118
+ alias certifiedbot? certifiedbot
119
+
120
+ def owners
121
+ @data['owners']
122
+ end
123
+
124
+ def tags
125
+ @data['tags']
126
+ end
127
+
128
+ def legacy
129
+ @data['legacy']
130
+ end
131
+
132
+ alias legacy? legacy
133
+
134
+ def fail
135
+ raise DBLRuby::Errors::NoData, 'The API didn\'t return anything!'
136
+ end
137
+ end
@@ -0,0 +1,5 @@
1
+ # Errors are cool.
2
+ module DBLRuby::Errors
3
+ # Ran if No Data is returned.
4
+ class NoData < RuntimeError; end
5
+ end
@@ -13,6 +13,7 @@ class DBLRuby::Stats
13
13
  JSON.parse(RestClient.get(url))['server_count'].to_i
14
14
  end
15
15
 
16
+ # Update the bot's server count.
16
17
  def updateservercount(count)
17
18
  url = "https://discordbots.org/api/bots/#{@id}/stats"
18
19
  json = '{"server_count":' + count.to_s + '}'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dblruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chewsterchew
@@ -31,8 +31,10 @@ extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
33
  - lib/dblruby.rb
34
+ - lib/dblruby/bot.rb
35
+ - lib/dblruby/errors.rb
34
36
  - lib/dblruby/stats.rb
35
- homepage: http://rubygems.org/gems/dblruby
37
+ homepage: http://github.com/Chewsterchew/DBLRuby
36
38
  licenses:
37
39
  - MIT
38
40
  metadata: {}
@@ -52,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
54
  version: '0'
53
55
  requirements: []
54
56
  rubyforge_project:
55
- rubygems_version: 2.6.13
57
+ rubygems_version: 2.6.8
56
58
  signing_key:
57
59
  specification_version: 4
58
60
  summary: A gem made for DBL in ruby.