dblruby 0.4.0 → 0.5.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: d0c726f7da9d2628eb0efcb143338daf975c618c
4
- data.tar.gz: 376afe8d73203cdc7ecd957af6be10a67303d53d
3
+ metadata.gz: 74234c3df2d4ba601ee219351cf3c9a0ec6a5a06
4
+ data.tar.gz: 64b71fea55fc450f5d35ed5c27e0328ab781ceeb
5
5
  SHA512:
6
- metadata.gz: ff213aa5f739b3c9a318ab6b99fc6246f3e41abc5209f928af496fd901fc40764df3619e8bffd92931cfc774e7f3159d7ec38979ff36116de17b80d1342567ed
7
- data.tar.gz: e4557ab0ee62b5e7464febc20480629030b537940f51480ffa0a1e535b95e05633207b9413debc5ae914ecaaf08a9cbcb8d5929f9c43445f9bba4084f5f12890
6
+ metadata.gz: efbcc7c1a244954e38460aca78455867ed9d8d8a54846eed6e0831a6349ea18943acf116dfcc67d13ca0573a5cbacc12341ba1b13ceea0a2ddecaa770c6a5be3
7
+ data.tar.gz: 5ff26982b39589e881e9f79be510a14c757103fe842c979bd713ceed4bc4a7a4d914fb23f16f62d63a29fc5ea3d95f9ac8071785864052aae95b410a0ca1adb8
@@ -5,6 +5,8 @@ require 'rest-client'
5
5
  # All DBLRuby functionality, whether extended or just here.
6
6
  class DBLRuby
7
7
  # Initialize a new DBL API, via a key.
8
+ # @param apikey [String] API Key of the bot, taken from the DBL.
9
+ # @param id [Integer, String] Integer/String of the bot's id.
8
10
  def initialize(apikey, id)
9
11
  @api = apikey
10
12
  @id = id
@@ -16,14 +18,26 @@ class DBLRuby
16
18
  @stats = Stats.new(@api, @id)
17
19
  end
18
20
 
21
+ # Load a bot.
22
+ # @param id [Integer, String] Integer/String ID of the bot you're requesting.
19
23
  def loadbot(id)
20
24
  @bot = Bot.new(id)
21
25
  end
22
26
 
27
+ # Load a user
28
+ # @param id [Integer, String] Integer/String ID of the user you're requesting.
23
29
  def loaduser(id)
24
30
  @user = User.new(id)
25
31
  end
26
32
 
33
+ # Get the ID from instantiation
34
+ attr_reader :id
35
+
36
+ # Get the API Key from instantiation
37
+ attr_reader :api
38
+
39
+ alias apikey api
40
+
27
41
  attr_reader :bot
28
42
  attr_reader :user
29
43
  attr_reader :stats
@@ -11,102 +11,121 @@ class DBLRuby::Bot
11
11
  attr_reader :data
12
12
 
13
13
  # Get the bot's invite link.
14
+ # @return [String] the bot's invite link.
14
15
  def invite
15
16
  @data['invite']
16
17
  end
17
18
 
18
19
  # Get the bot's GitHub Repo link.
20
+ # @return [String] the bot's GitHub Repo link.
19
21
  def github
20
22
  @data['github']
21
23
  end
22
24
 
23
25
  # Get the bot's website link.
26
+ # @return [String] the bot's website link.
24
27
  def website
25
28
  @data['website']
26
29
  end
27
30
 
28
31
  # Get the bot's Long Description.
32
+ # @return [String] the bot's Long Description.
29
33
  def longdesc
30
34
  @data['longdesc']
31
35
  end
32
36
 
33
37
  # Get the bot's Short Description.
38
+ # @return [String] the bot's Short Description.
34
39
  def shortdesc
35
40
  @data['shortdesc']
36
41
  end
37
42
 
38
43
  # Get the bot's prefix.
44
+ # @return [String] the bot's prefix.
39
45
  def prefix
40
46
  @data['prefix']
41
47
  end
42
48
 
43
49
  # Get the bot's library.
50
+ # @return [String] the bot's library.
44
51
  def lib
45
52
  @data['lib']
46
53
  end
47
54
 
48
55
  # Get the bot's Client ID.
56
+ # @return [Integer] the bot's client id.
49
57
  def clientid
50
- @data['clientid']
58
+ @data['clientid'].to_i
51
59
  end
52
60
 
53
61
  # Get the bot's avatar.
62
+ # @return [String] the bot's avatar.
54
63
  def avatar
55
64
  @data['avatar']
56
65
  end
57
66
 
58
67
  # Get's the bot's avatar as an img, ready to be used in image linking.
68
+ # @return [String] the bot's avatar image url.
59
69
  def avatar_img
60
70
  "https://cdn.discordapp.com/avatars/#{id}/#{avatar}.webp?size=1024"
61
71
  end
62
72
 
63
73
  # Get the bot's ID.
74
+ # @return [Integer] the bot's id.
64
75
  def id
65
- @data['id']
76
+ @data['id'].to_i
66
77
  end
67
78
 
68
79
  # Get the bot's discriminator.
80
+ # @return [Integer] the bot's discriminator without the #.
69
81
  def discriminator
70
- @data['discriminator']
82
+ @data['discriminator'].delete('#').to_i
71
83
  end
72
84
 
73
85
  alias discrim discriminator
74
86
  alias tag discriminator
75
87
 
76
88
  # Get the bot's username.
89
+ # @return [String] the bot's username.
77
90
  def username
78
91
  @data['username']
79
92
  end
80
93
 
81
94
  # Returns the bot's distinct, which is the Username and Discriminator.
95
+ # @return [String] the bot's distinct.
82
96
  def distinct
83
- "#{username}#{tag}"
97
+ "#{username}\##{tag}"
84
98
  end
85
99
 
86
100
  # Get the bot's creation date (on the list).
101
+ # @return [String] the bot's date.
87
102
  def date
88
103
  @data['date']
89
104
  end
90
105
 
91
106
  # Get the bot's support server invite code.
107
+ # @return [String] the bot's support server code.
92
108
  def support
93
109
  @data['support']
94
110
  end
95
111
 
96
112
  # Get the bot's support server link, ready for clicking.
113
+ # @return [String] the bot's support server link.
97
114
  def support_link
98
115
  "https://discord.gg/#{support}"
99
116
  end
100
117
 
101
118
  # Get the bot's server count
119
+ # @return [Integer] the bot's server count.
102
120
  def server_count
103
- @data['server_count']
121
+ @data['server_count'].to_i
104
122
  end
105
123
 
106
124
  alias guild_count server_count
107
125
  alias server server_count
108
126
 
109
127
  # Get the bot's "This Bot Powers the following Servers"
128
+ # @return [Array<String>] the bot's guilds.
110
129
  def guilds
111
130
  @data['guilds']
112
131
  end
@@ -114,25 +133,29 @@ class DBLRuby::Bot
114
133
  alias servers guilds
115
134
 
116
135
  # Get the bot's shards.
136
+ # @return [Array<String>] the bot's shards.
117
137
  def shards
118
138
  @data['shards']
119
139
  end
120
140
 
121
141
  # Get the bot's monthly votes.
142
+ # @return [Integer] the bot's monthly points/votes.
122
143
  def monthlypoints
123
- @data['monthlyPoints']
144
+ @data['monthlyPoints'].to_i
124
145
  end
125
146
 
126
147
  alias monthlyvotes monthlypoints
127
148
 
128
149
  # Get the bot's total votes.
150
+ # @return [Integer] the bot's total points/votes.
129
151
  def points
130
- @data['points']
152
+ @data['points'].to_i
131
153
  end
132
154
 
133
155
  alias votes points
134
156
 
135
157
  # Get the bot's certified status.
158
+ # @return [true, false] the bot's certified status.
136
159
  def certifiedbot
137
160
  @data['certifiedBot']
138
161
  end
@@ -142,16 +165,19 @@ class DBLRuby::Bot
142
165
  alias certifiedbot? certifiedbot
143
166
 
144
167
  # Get the bot's owners.
168
+ # @return [Array<String>] the bot's owners in an array.
145
169
  def owners
146
170
  @data['owners']
147
171
  end
148
172
 
149
173
  # Get the bot's sorting tags.
174
+ # @return [Array<String>] the bot's tags in an array.
150
175
  def tags
151
176
  @data['tags']
152
177
  end
153
178
 
154
179
  # Get the bot's legacy status.
180
+ # @return [true, false] the bot's legacy status.
155
181
  def legacy
156
182
  @data['legacy']
157
183
  end
@@ -7,17 +7,31 @@ class DBLRuby::Stats
7
7
  @id = id
8
8
  end
9
9
 
10
- # Get the server count, returns an int.
10
+ # Get the bot's server count, returns an int.
11
+ # @return [Integer] amount of servers the bot is on.
11
12
  def servercount
12
13
  url = "https://discordbots.org/api/bots/#{@id}"
13
14
  JSON.parse(RestClient.get(url))['server_count'].to_i
14
15
  end
15
16
 
16
17
  # Update the bot's server count.
18
+ # @param id [Integer, String] Integer/String ID of bot server count.
17
19
  def updateservercount(count)
18
20
  url = "https://discordbots.org/api/bots/#{@id}/stats"
19
21
  json = '{"server_count":' + count.to_s + '}'
20
22
  RestClient.post(url, json, :Authorization => @api, :'Content-Type' => :json)
21
23
  "Successfully set the server count to #{count}"
22
24
  end
25
+
26
+ # Check to see if a user really voted, via an ID.
27
+ # @param id [Integer, String] Integer/String ID of user you're requesting.
28
+ # @return [true, false] if the user voted or not.
29
+ def verifyvote(id)
30
+ r = RestClient.get('https://discordbots.org/api/bots/check',
31
+ params: { userId: id },
32
+ :Authorization => @api,
33
+ :'Content-Type' => :json)
34
+ o = JSON.parse(r)['voted'].to_i
35
+ !o.zero?
36
+ end
23
37
  end
@@ -13,80 +13,94 @@ class DBLRuby::User
13
13
  alias to_s data
14
14
 
15
15
  # Get the user's ID.
16
- # @return User ID in integer form.
16
+ # @return [Integer] User ID in integer form.
17
17
  def id
18
18
  @data['id'].to_i
19
19
  end
20
20
 
21
21
  # Get the user's username.
22
+ # @return [String] the user's username.
22
23
  def username
23
24
  @data['username']
24
25
  end
25
26
 
26
27
  # Get the user's discriminator.
28
+ # @return [Integer] the user's discriminator without the #.
27
29
  def discriminator
28
- @data['discriminator']
30
+ @data['discriminator'].delete('#').to_i
29
31
  end
30
32
 
31
33
  alias discrim discriminator
32
34
  alias tag discriminator
33
35
 
34
36
  # Returns the user's distinct, which is the Username and Discriminator.
37
+ # @return [String] the user's username + discrim.
35
38
  def distinct
36
- "#{username}#{tag}"
39
+ "#{username}\##{tag}"
37
40
  end
38
41
 
39
42
  # Get the user's avatar.
43
+ # @return [String] the user's avatar hash.
40
44
  def avatar
41
45
  @data['avatar']
42
46
  end
43
47
 
44
48
  # Get's the user's avatar as an img, ready to be used in image linking.
49
+ # @return [String] the user's avatar link.
45
50
  def avatar_img
46
51
  "https://cdn.discordapp.com/avatars/#{id}/#{avatar}.webp?size=1024"
47
52
  end
48
53
 
49
54
  # Get the user's bio.
55
+ # @return [String] the user's bio.
50
56
  def bio
51
57
  @data['bio']
52
58
  end
53
59
 
54
60
  # Get a list of social links for the user
61
+ # @return [Array<String>] the user's social links.
55
62
  def social
56
63
  @data['social']
57
64
  end
58
65
 
59
66
  # Does the user have any social links? True if so, false if not.
67
+ # @return [true, false] if the user has any social links.
60
68
  def social?
61
69
  !@data['social'].nil?
62
70
  end
63
71
 
64
72
  # Get the user's YouTube channel link.
73
+ # @return [String] the user's youtube channel link.
65
74
  def youtube
66
75
  @data['social']['youtube']
67
76
  end
68
77
 
69
78
  # Get the user's Reddit link.
79
+ # @return [String] the user's reddit link.
70
80
  def reddit
71
81
  @data['social']['reddit']
72
82
  end
73
83
 
74
84
  # Get the user's Twitter link.
85
+ # @return [String] the user's twitter link.
75
86
  def twitter
76
87
  @data['social']['twitter']
77
88
  end
78
89
 
79
90
  # Get the user's Instagram link.
91
+ # @return [String] the user's instagram link.
80
92
  def instagram
81
93
  @data['social']['instagram']
82
94
  end
83
95
 
84
96
  # Get the user's Github link.
97
+ # @return [String] the user's github link.
85
98
  def github
86
99
  @data['social']['github']
87
100
  end
88
101
 
89
102
  # Get the user's Hex Colour.
103
+ # @return [String] the user's hex code for their page.
90
104
  def color
91
105
  @data['color']
92
106
  end
@@ -94,41 +108,46 @@ class DBLRuby::User
94
108
  alias colour color
95
109
 
96
110
  # Get the user's supporter status.
97
- def supporter
111
+ # @return [true, false] the user's supporter status.
112
+ def supporter?
98
113
  @data['supporter']
99
114
  end
100
115
 
101
- alias supporter? supporter
116
+ alias supporter supporter?
102
117
 
103
118
  # Get the user's certified developer status.
104
- def certified
119
+ # @return [true, false] the user's certified status.
120
+ def certified?
105
121
  @data['lib']
106
122
  end
107
123
 
108
- alias certified? certified
124
+ alias certified certified?
109
125
  alias certifieddev certified
110
126
  alias certifieddev? certified
111
127
 
112
128
  # Get the user's mod status.
113
- def mod
129
+ # @return [true, false] the user's mod status.
130
+ def mod?
114
131
  @data['mod']
115
132
  end
116
133
 
117
- alias mod? mod
134
+ alias mod mod?
118
135
 
119
136
  # Get the user's website moderator status.
120
- def webmod
137
+ # @return [true, false] the user's website mod status.
138
+ def webmod?
121
139
  @data['webMod']
122
140
  end
123
141
 
124
- alias webmod? webmod
142
+ alias webmod webmod?
125
143
 
126
144
  # Get the user's admin status.
127
- def admin
145
+ # @return [true, false] the user's admin status.
146
+ def admin?
128
147
  @data['admin']
129
148
  end
130
149
 
131
- alias admin? admin
150
+ alias admin admin?
132
151
 
133
152
  # Debug method to force a bot error.
134
153
  def fail
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dblruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chewsterchew
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-22 00:00:00.000000000 Z
11
+ date: 2018-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -55,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
55
  version: '0'
56
56
  requirements: []
57
57
  rubyforge_project:
58
- rubygems_version: 2.6.13
58
+ rubygems_version: 2.6.8
59
59
  signing_key:
60
60
  specification_version: 4
61
61
  summary: A gem made for DBL in ruby.