listcordrb 0.1.0 → 0.2.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: 7c67bd0088cbce432e081fa04e9d9f36ad10c5b5
4
- data.tar.gz: 8de5b47ffeb7daa617cea8081a81d81a1e23ec5b
3
+ metadata.gz: 86bf85b55bb49caa4c48f709d92d3654bb9988ea
4
+ data.tar.gz: d96bccafef48cd42b29f58561eb0c381947cbf06
5
5
  SHA512:
6
- metadata.gz: f288d6241675eb8ee26808b7005e39f16bbfc66f7f6a615a013a45fef73ff6471c06bc3ece60e8dda97ca1c0cb225b99d896a8c5178dcfa131992d12591ec366
7
- data.tar.gz: 3ff1be51bcb9db4fab9fa1c8d1faf2c6f916521e3b2e59a90f5549ad0b19da455f3b4e5bade36ba431cc7e1630874a46005c90eff1cdb7a4c610fb018441218a
6
+ metadata.gz: '0680f6c88b8d3076fc0a0dea9534c6189e9a15aa1711462e561dcb565075ffa544dd395e368f01ea1e739e5758850b1a6fe260d401b556d2575b15fdbc31e9f2'
7
+ data.tar.gz: fdd911a3239e07775aa2970f30591df4ed30e4974778e6cc65d2c8a433095832e2a55ab12a092143544ef4d88cc5dff7fd81751526e03cb8409e41220dacc476
@@ -18,8 +18,16 @@ class ListCordRB
18
18
  @stats = Stats.new(@api, @id)
19
19
  end
20
20
 
21
+ # Load a bot.
22
+ # @param id [Integer, String] Integer/String ID of the bot you're requesting.
23
+ def loadbot(id)
24
+ @bot = Bot.new(id)
25
+ end
26
+
21
27
  attr_reader :stats
28
+ attr_reader :bot
22
29
  end
23
30
 
24
31
  # Require files
25
32
  require 'listcordrb/stats'
33
+ require 'listcordrb/bot'
@@ -0,0 +1,127 @@
1
+ # Find information about bots.
2
+ class ListCordRB::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://listcord.com/api/bot/#{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
+ # Return the error message if there is one, nil otherwise.
16
+ # @return [String, nil] the error message.
17
+ def error
18
+ @data['message']
19
+ end
20
+
21
+ # Return true if there is an error, false otherwise.
22
+ # @return [true, false] if there is an error.
23
+ def error?
24
+ !@data['message'].nil?
25
+ end
26
+
27
+ # The custom bot invite url of the bot.
28
+ # @return [String] the bot's invite link.
29
+ def invite
30
+ @data['invite']
31
+ end
32
+
33
+ # The website url of the bot.
34
+ # @return [String] the bot's website link.
35
+ def website
36
+ @data['website']
37
+ end
38
+
39
+ # The description of the bot.
40
+ # @return [String] the bot's Description.
41
+ def description
42
+ @data['description']
43
+ end
44
+
45
+ # Get the bot's ID.
46
+ # @return [Integer] the bot's id.
47
+ def id
48
+ @data['id'].to_i
49
+ end
50
+
51
+ alias clientid id
52
+
53
+ # The avatar hash of the bot's avatar.
54
+ # @return [String] the bot's avatar.
55
+ def avatar
56
+ @data['avatar']
57
+ end
58
+
59
+ # Get's the bot's avatar as an img, ready to be used in image linking.
60
+ # @return [String] the bot's avatar image url.
61
+ def avatar_img
62
+ "https://cdn.discordapp.com/avatars/#{id}/#{avatar}.webp?size=1024"
63
+ end
64
+
65
+ # The discriminator of the bot.
66
+ # @return [Integer] the bot's discriminator without the #.
67
+ def discriminator
68
+ @data['discriminator'].to_i
69
+ end
70
+
71
+ alias discrim discriminator
72
+ alias tag discriminator
73
+
74
+ # The username of the bot.
75
+ # @return [String] the bot's username.
76
+ def username
77
+ @data['username']
78
+ end
79
+
80
+ # Returns the bot's distinct, which is the Username and Discriminator.
81
+ # @return [String] the bot's distinct.
82
+ def distinct
83
+ "#{username}\##{tag}"
84
+ end
85
+
86
+ # The support server invite code of the bot.
87
+ # @return [String] the bot's support server code.
88
+ def support
89
+ @data['support']
90
+ end
91
+
92
+ # The bot's support server link, ready for clicking.
93
+ # @return [String] the bot's support server link.
94
+ def support_link
95
+ "https://discord.gg/#{support}"
96
+ end
97
+
98
+ # Get the bot's server count
99
+ # @return [Integer] the bot's server count.
100
+ def servers
101
+ @data['servers'].to_i
102
+ end
103
+
104
+ alias guilds servers
105
+ alias guild servers
106
+ alias server servers
107
+
108
+ # The amount of upvotes the bot has.
109
+ # @return [Integer] the bot's total votes.
110
+ def votes
111
+ @data['votes'].to_i
112
+ end
113
+
114
+ # The certified status of the bot.
115
+ # @return [true, false] the bot's certified status.
116
+ def premium?
117
+ @data['premium']
118
+ end
119
+
120
+ alias premium premium?
121
+
122
+ # The owners of the bot. First one in the array is the main owner.
123
+ # @return [Array<String>] the bot's owners in an array.
124
+ def owners
125
+ @data['owners']
126
+ end
127
+ end
@@ -15,9 +15,10 @@ class ListCordRB::Stats
15
15
 
16
16
  alias servercount servers
17
17
 
18
+ # Update the bot's server count.
18
19
  def servers=(count)
19
20
  url = "http://listcord.com/api/bot/#{@id}/guilds"
20
- json = '{"guilds":' + count.to_i + '}'
21
+ json = '{"guilds":' + count.to_s + '}'
21
22
  RestClient.post(url, json, :Authorization => @api, :'Content-Type' => :json)
22
23
  end
23
24
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: listcordrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chewsterchew
@@ -31,6 +31,7 @@ extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
33
  - lib/listcordrb.rb
34
+ - lib/listcordrb/bot.rb
34
35
  - lib/listcordrb/stats.rb
35
36
  homepage: http://github.com/Chewsterchew/ListCordRB
36
37
  licenses: