dblruby 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b9103881719519a19041d666e8d5331f22fe533
4
- data.tar.gz: f6bef8afcee08ab9b43d4cef642bf733f7d73058
3
+ metadata.gz: d0c726f7da9d2628eb0efcb143338daf975c618c
4
+ data.tar.gz: 376afe8d73203cdc7ecd957af6be10a67303d53d
5
5
  SHA512:
6
- metadata.gz: 830532b284bd3779a1ed8fb4b3f56ef9f3765a644ef8747505504ca4f34ca2c96e4cd987a6f025a0f471b347089c702cd48f8486dc6e13b3d1ac8151f2f9445e
7
- data.tar.gz: 772436ae4995bb95f9969f81c6ce9e5b4dea8bd1626d8775e4a251a4d38019c9acf1c20d0014ef8d9f8471cbda77f61afe138dbadbbe59864a41796729f005ef
6
+ metadata.gz: ff213aa5f739b3c9a318ab6b99fc6246f3e41abc5209f928af496fd901fc40764df3619e8bffd92931cfc774e7f3159d7ec38979ff36116de17b80d1342567ed
7
+ data.tar.gz: e4557ab0ee62b5e7464febc20480629030b537940f51480ffa0a1e535b95e05633207b9413debc5ae914ecaaf08a9cbcb8d5929f9c43445f9bba4084f5f12890
@@ -20,11 +20,17 @@ class DBLRuby
20
20
  @bot = Bot.new(id)
21
21
  end
22
22
 
23
+ def loaduser(id)
24
+ @user = User.new(id)
25
+ end
26
+
23
27
  attr_reader :bot
28
+ attr_reader :user
24
29
  attr_reader :stats
25
30
  end
26
31
 
27
32
  # Require files.
28
33
  require 'dblruby/bot'
29
34
  require 'dblruby/errors'
35
+ require 'dblruby/user'
30
36
  require 'dblruby/stats'
@@ -20,42 +20,52 @@ class DBLRuby::Bot
20
20
  @data['github']
21
21
  end
22
22
 
23
+ # Get the bot's website link.
23
24
  def website
24
25
  @data['website']
25
26
  end
26
27
 
28
+ # Get the bot's Long Description.
27
29
  def longdesc
28
30
  @data['longdesc']
29
31
  end
30
32
 
33
+ # Get the bot's Short Description.
31
34
  def shortdesc
32
35
  @data['shortdesc']
33
36
  end
34
37
 
38
+ # Get the bot's prefix.
35
39
  def prefix
36
40
  @data['prefix']
37
41
  end
38
42
 
43
+ # Get the bot's library.
39
44
  def lib
40
45
  @data['lib']
41
46
  end
42
47
 
48
+ # Get the bot's Client ID.
43
49
  def clientid
44
50
  @data['clientid']
45
51
  end
46
52
 
53
+ # Get the bot's avatar.
47
54
  def avatar
48
55
  @data['avatar']
49
56
  end
50
57
 
58
+ # Get's the bot's avatar as an img, ready to be used in image linking.
51
59
  def avatar_img
52
60
  "https://cdn.discordapp.com/avatars/#{id}/#{avatar}.webp?size=1024"
53
61
  end
54
62
 
63
+ # Get the bot's ID.
55
64
  def id
56
65
  @data['id']
57
66
  end
58
67
 
68
+ # Get the bot's discriminator.
59
69
  def discriminator
60
70
  @data['discriminator']
61
71
  end
@@ -63,18 +73,27 @@ class DBLRuby::Bot
63
73
  alias discrim discriminator
64
74
  alias tag discriminator
65
75
 
76
+ # Get the bot's username.
66
77
  def username
67
78
  @data['username']
68
79
  end
69
80
 
81
+ # Returns the bot's distinct, which is the Username and Discriminator.
82
+ def distinct
83
+ "#{username}#{tag}"
84
+ end
85
+
86
+ # Get the bot's creation date (on the list).
70
87
  def date
71
88
  @data['date']
72
89
  end
73
90
 
91
+ # Get the bot's support server invite code.
74
92
  def support
75
93
  @data['support']
76
94
  end
77
95
 
96
+ # Get the bot's support server link, ready for clicking.
78
97
  def support_link
79
98
  "https://discord.gg/#{support}"
80
99
  end
@@ -87,28 +106,33 @@ class DBLRuby::Bot
87
106
  alias guild_count server_count
88
107
  alias server server_count
89
108
 
109
+ # Get the bot's "This Bot Powers the following Servers"
90
110
  def guilds
91
111
  @data['guilds']
92
112
  end
93
113
 
94
114
  alias servers guilds
95
115
 
116
+ # Get the bot's shards.
96
117
  def shards
97
118
  @data['shards']
98
119
  end
99
120
 
121
+ # Get the bot's monthly votes.
100
122
  def monthlypoints
101
123
  @data['monthlyPoints']
102
124
  end
103
125
 
104
126
  alias monthlyvotes monthlypoints
105
127
 
128
+ # Get the bot's total votes.
106
129
  def points
107
130
  @data['points']
108
131
  end
109
132
 
110
133
  alias votes points
111
134
 
135
+ # Get the bot's certified status.
112
136
  def certifiedbot
113
137
  @data['certifiedBot']
114
138
  end
@@ -117,20 +141,24 @@ class DBLRuby::Bot
117
141
  alias certified certifiedbot
118
142
  alias certifiedbot? certifiedbot
119
143
 
144
+ # Get the bot's owners.
120
145
  def owners
121
146
  @data['owners']
122
147
  end
123
148
 
149
+ # Get the bot's sorting tags.
124
150
  def tags
125
151
  @data['tags']
126
152
  end
127
153
 
154
+ # Get the bot's legacy status.
128
155
  def legacy
129
156
  @data['legacy']
130
157
  end
131
158
 
132
159
  alias legacy? legacy
133
160
 
161
+ # Debug method to force a bot error.
134
162
  def fail
135
163
  raise DBLRuby::Errors::NoData, 'The API didn\'t return anything!'
136
164
  end
@@ -0,0 +1,137 @@
1
+ # Find information about users.
2
+ class DBLRuby::User
3
+ # Initialize the user
4
+ # @param id [Integer, String] Integer/String ID of user you're requesting.
5
+ def initialize(id)
6
+ url = "https://discordbots.org/api/users/#{id}"
7
+ @data = JSON.parse(RestClient.get(url))
8
+ end
9
+
10
+ # @return data in raw json form.
11
+ attr_reader :data
12
+
13
+ alias to_s data
14
+
15
+ # Get the user's ID.
16
+ # @return User ID in integer form.
17
+ def id
18
+ @data['id'].to_i
19
+ end
20
+
21
+ # Get the user's username.
22
+ def username
23
+ @data['username']
24
+ end
25
+
26
+ # Get the user's discriminator.
27
+ def discriminator
28
+ @data['discriminator']
29
+ end
30
+
31
+ alias discrim discriminator
32
+ alias tag discriminator
33
+
34
+ # Returns the user's distinct, which is the Username and Discriminator.
35
+ def distinct
36
+ "#{username}#{tag}"
37
+ end
38
+
39
+ # Get the user's avatar.
40
+ def avatar
41
+ @data['avatar']
42
+ end
43
+
44
+ # Get's the user's avatar as an img, ready to be used in image linking.
45
+ def avatar_img
46
+ "https://cdn.discordapp.com/avatars/#{id}/#{avatar}.webp?size=1024"
47
+ end
48
+
49
+ # Get the user's bio.
50
+ def bio
51
+ @data['bio']
52
+ end
53
+
54
+ # Get a list of social links for the user
55
+ def social
56
+ @data['social']
57
+ end
58
+
59
+ # Does the user have any social links? True if so, false if not.
60
+ def social?
61
+ !@data['social'].nil?
62
+ end
63
+
64
+ # Get the user's YouTube channel link.
65
+ def youtube
66
+ @data['social']['youtube']
67
+ end
68
+
69
+ # Get the user's Reddit link.
70
+ def reddit
71
+ @data['social']['reddit']
72
+ end
73
+
74
+ # Get the user's Twitter link.
75
+ def twitter
76
+ @data['social']['twitter']
77
+ end
78
+
79
+ # Get the user's Instagram link.
80
+ def instagram
81
+ @data['social']['instagram']
82
+ end
83
+
84
+ # Get the user's Github link.
85
+ def github
86
+ @data['social']['github']
87
+ end
88
+
89
+ # Get the user's Hex Colour.
90
+ def color
91
+ @data['color']
92
+ end
93
+
94
+ alias colour color
95
+
96
+ # Get the user's supporter status.
97
+ def supporter
98
+ @data['supporter']
99
+ end
100
+
101
+ alias supporter? supporter
102
+
103
+ # Get the user's certified developer status.
104
+ def certified
105
+ @data['lib']
106
+ end
107
+
108
+ alias certified? certified
109
+ alias certifieddev certified
110
+ alias certifieddev? certified
111
+
112
+ # Get the user's mod status.
113
+ def mod
114
+ @data['mod']
115
+ end
116
+
117
+ alias mod? mod
118
+
119
+ # Get the user's website moderator status.
120
+ def webmod
121
+ @data['webMod']
122
+ end
123
+
124
+ alias webmod? webmod
125
+
126
+ # Get the user's admin status.
127
+ def admin
128
+ @data['admin']
129
+ end
130
+
131
+ alias admin? admin
132
+
133
+ # Debug method to force a bot error.
134
+ def fail
135
+ raise DBLRuby::Errors::NoData, 'The API didn\'t return anything!'
136
+ end
137
+ end
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.3.0
4
+ version: 0.4.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-21 00:00:00.000000000 Z
11
+ date: 2018-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -34,6 +34,7 @@ files:
34
34
  - lib/dblruby/bot.rb
35
35
  - lib/dblruby/errors.rb
36
36
  - lib/dblruby/stats.rb
37
+ - lib/dblruby/user.rb
37
38
  homepage: http://github.com/Chewsterchew/DBLRuby
38
39
  licenses:
39
40
  - MIT
@@ -54,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
55
  version: '0'
55
56
  requirements: []
56
57
  rubyforge_project:
57
- rubygems_version: 2.6.8
58
+ rubygems_version: 2.6.13
58
59
  signing_key:
59
60
  specification_version: 4
60
61
  summary: A gem made for DBL in ruby.