topgg 1.0.1 → 1.0.5

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
  SHA256:
3
- metadata.gz: ccf9bfc94f4939b8638002c04189a3ef52caf2d22403ef387b188184e7d0735c
4
- data.tar.gz: b66aecd679df93a5db506f83fddfc825872994940f79ddf22e6ab235fa4709fb
3
+ metadata.gz: f7df2047fafadab0512acb6dea7eaf26340c7287d0b6be8b4a194e2a3876b676
4
+ data.tar.gz: af78cad719c0a3a58b36800fb045ce53fd28dbfc31095ba8f7d29caccab80716
5
5
  SHA512:
6
- metadata.gz: 4913aef45f94f44a694a1b6bd1ff185c5908443dc811b16f7652d4fd5d30c1f81a2821830d1ca61ab2a6994e5307980853d094215044fffb1ca08b351a57d0da
7
- data.tar.gz: 8d82c6d6831f29322692d57120b7340ecef95d14962fe49e69946fca92b1f31337cd8a043b8f83bdb9da173de315fb8fa03a7c0e95d12ec00dc821f5247fcdf6
6
+ metadata.gz: 60061b954b40cf38adc64eda4fceb34682a62c511041bbd01090a911215c6df63316be05a7008f75231bd0f7a3f12fc4f47794142e69668e9679e1cedfd1e1f3
7
+ data.tar.gz: 36c8e67ceebae7723932f9b43972ce8647c3d0d346e0e9e8ff22185ddd7f89d1b9d2f90cd8d62a91f15cfa59086c0ab5d124726288c050ce56a06950a8c83e2b
data/lib/lib.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'faraday'
3
4
  require 'json'
4
5
  require_relative 'topgg/bot'
@@ -24,20 +25,18 @@ class Topgg
24
25
  # The method fetches bot statistics from top.gg
25
26
  # @param id [String] The id of the bot you want to fetch statistics from.
26
27
  # @return [Spreader::Bot] The Bot Object
27
- def getBot(id)
28
+ def get_bot(id)
28
29
  resp = @conn.get("bots/#{id}")
29
30
 
30
31
  Spreader::Bot.new(JSON.parse(resp.body))
31
32
  end
32
33
 
33
34
  # The method searches bots from top.gg using a keyword query.
34
- # @param query [String] the search term
35
- # @param limit [Integer] the amount of results to return
36
- # @param offset [Integer] The Amount of bots to skip
37
- # @param sort [Boolean] The fields to sort by.
35
+ # @param [Object] params The parameters that can be used to query a search
36
+ # To know what the parameters are check it out here
38
37
  # @return [Spreader::BotSearch] The BotSearch Object
39
- def searchBot(query, limit: 50, offset: 0, sort: nil, fields: nil)
40
- resp = @conn.get('bots', { search: query, limit: limit, offset: offset, sort: sort, fields: fields })
38
+ def search_bot(params)
39
+ resp = @conn.get('bots', params)
41
40
  Spreader::BotSearch.new(JSON.parse(resp.body))
42
41
  end
43
42
 
@@ -53,7 +52,7 @@ class Topgg
53
52
  # Get Bot statistics.
54
53
  # @param id [String] Id of the bot you want to get statistics of
55
54
  # @return [Spreader::Stats]
56
- def getStats(id)
55
+ def get_stats(id)
57
56
  resp = @conn.get("bots/#{id}/stats")
58
57
 
59
58
  Spreader::Stats.new(JSON.parse(resp.body))
@@ -81,35 +80,43 @@ class Topgg
81
80
  # @param server_count [Integer] The amount of servers the bot is in.
82
81
  # @param shards [Integer] The amount of servers the bot is in per shard
83
82
  # @param shard_count [Integer] The total number of shards.
84
- def postStats(server_count, shards: nil, shard_count: nil)
85
- jsonPost = {
83
+ def post_stats(server_count, shards: nil, shard_count: nil)
84
+ json_post = {
86
85
  server_count: server_count,
87
86
  shards: shards,
88
87
  shard_count: shard_count
89
88
  }.to_json
90
- @conn.post("bots/#{@id}/stats", jsonPost, { 'Content-Type' => 'application/json' })
89
+ @conn.post("bots/#{@id}/stats", json_post, { 'Content-Type' => 'application/json' })
91
90
  end
92
91
 
93
- # Autopost stats on to the top.gg website
92
+ # Auto-posts stats on to the top.gg website
94
93
  # @param client [Discordrb::Bot] instanceof discordrb client.
95
- def autoPostStats(client)
96
- serverLen = client.servers.length
97
- interval 1800 do
98
- postStats(serverLen)
94
+ def auto_post_stats(client)
95
+ semaphore = Mutex.new
96
+ Thread.new do
97
+ semaphore.synchronize do
98
+ interval 1800 do
99
+ server_len = client.servers.length
100
+ post_stats(server_len)
101
+ print("[TOPGG] : \033[31;1;4m Bot statistics has been successfully posted!\033[0m")
102
+ end
103
+ end
99
104
  end
100
105
  end
106
+
101
107
  # Mini-method to get statistics on self
102
- # @return [getBot]
108
+ # @return [get_bot]
103
109
  def self
104
- getBot(@id)
110
+ get_bot(@id)
105
111
  end
106
112
 
107
113
  def interval(seconds)
108
114
  loop do
109
115
  yield
110
- sleep seconds
116
+ sleep seconds
111
117
  end
112
118
  end
113
119
  end
114
120
 
115
121
 
122
+
data/lib/topgg/bot.rb CHANGED
@@ -10,28 +10,29 @@ module Spreader
10
10
  # @return [Hash]
11
11
  attr_reader :obj
12
12
 
13
+ alias :raw :obj
13
14
  # Returns error message, if there's an error
14
15
  # @return [String]
15
16
  def error
16
- @obj['error']
17
+ @obj['error'].to_str
17
18
  end
18
19
 
19
20
  # Returns the default Avatar of the client
20
21
  # @return [String]
21
22
  def defAvatar
22
- @obj['defAvatar']
23
+ @obj['defAvatar'].to_str
23
24
  end
24
25
 
25
26
  # Returns the invite link of the bot
26
27
  # @return [String]
27
28
  def invite
28
- @obj['invite']
29
+ @obj['invite'].to_str
29
30
  end
30
31
 
31
32
  # Returns the bot website, if configured
32
33
  # @return [String]
33
34
  def website
34
- @obj['website']
35
+ @obj['website'].to_str
35
36
  end
36
37
 
37
38
  # Returns support server link
@@ -43,37 +44,37 @@ module Spreader
43
44
  # Returns github repository link, if any
44
45
  # @return [String]
45
46
  def github
46
- @obj['github']
47
+ @obj['github'].to_str
47
48
  end
48
49
 
49
50
  # Returns the long Description of the bot
50
51
  # @return [String]
51
52
  def longdesc
52
- @obj['longdesc']
53
+ @obj['longdesc'].to_str
53
54
  end
54
55
 
55
56
  # Returns the short description of the bot
56
57
  # @return [String]
57
58
  def shortdesc
58
- @obj['shortdesc']
59
+ @obj['shortdesc'].to_str
59
60
  end
60
61
 
61
62
  # Returns the default prefix of the bot
62
63
  # @return [String]
63
64
  def prefix
64
- @obj['prefix']
65
+ @obj['prefix'].to_str
65
66
  end
66
67
 
67
68
  # Returns the bot library
68
69
  # @return [String]
69
70
  def lib
70
- @obj['lib']
71
+ @obj['lib'].to_str
71
72
  end
72
73
 
73
74
  # Returns the bot client id
74
75
  # @return [String]
75
76
  def clientid
76
- @obj['clientid']
77
+ @obj['clientid'].to_str
77
78
  end
78
79
 
79
80
  # Returns the avatar link of the bot
@@ -85,19 +86,19 @@ module Spreader
85
86
  # Returns the bot id
86
87
  # @return [String]
87
88
  def id
88
- @obj['id']
89
+ @obj['id'].to_str
89
90
  end
90
91
 
91
92
  # Returns the bot descriminator
92
93
  # @return [String]
93
94
  def descriminator
94
- @obj['descriminator']
95
+ @obj['descriminator'].to_str
95
96
  end
96
97
 
97
98
  # Returns the bot username
98
99
  # @return [String]
99
100
  def username
100
- @obj['username']
101
+ @obj['username'].to_str
101
102
  end
102
103
 
103
104
  # Returns the date on which the bot was submitted
@@ -115,61 +116,61 @@ module Spreader
115
116
  # Returns the amount of shards
116
117
  # @return [String]
117
118
  def shard_count
118
- @obj['shard_count']
119
+ @obj['shard_count'].to_str
119
120
  end
120
121
 
121
122
  # Returns configured guilds in which the bot is in
122
123
  # @return [String]
123
124
  def guilds
124
- @obj['guilds']
125
+ @obj['guilds'].to_str
125
126
  end
126
127
 
127
128
  # Returns the amount of guilds per shard of the bot
128
129
  # @return [String]
129
130
  def shards
130
- @obj['shards']
131
+ @obj['shards'].to_str
131
132
  end
132
133
 
133
134
  # Returns the monthyPoints of the bot
134
135
  # @return [String]
135
136
  def monthlyPoints
136
- @obj['monthlyPoints']
137
+ @obj['monthlyPoints'].to_str
137
138
  end
138
139
 
139
140
  # Returns the total points of the bot
140
141
  # @return [String]
141
142
  def points
142
- @obj['points']
143
+ @obj['points'].to_str
143
144
  end
144
145
 
145
146
  # Returns true/false depending on if the bot is certified or not
146
147
  # @return [Boolean]
147
148
  def certifiedBot
148
- @obj['certifiedBot']
149
+ @obj['certifiedBot'].to_str
149
150
  end
150
151
 
151
152
  # Returns the owner ids
152
153
  # @return [Array<String>]
153
154
  def owners
154
- @obj['owners']
155
+ @obj['owners'].to_str
155
156
  end
156
157
 
157
158
  # Return the bot tags
158
159
  # @return [Array<String>]
159
160
  def tags
160
- @obj['tags']
161
+ @obj['tags'].to_str
161
162
  end
162
163
 
163
164
  # Returns the bot banner url
164
165
  # @return [String]
165
166
  def bannerUrl
166
- @obj['bannerUrl']
167
+ @obj['bannerUrl'].to_str
167
168
  end
168
169
 
169
170
  # Returns the donate bot guild ID
170
171
  # @return [String]
171
172
  def donatebotguildid
172
- @obj['donatebotguildid']
173
+ @obj['donatebotguildid'].to_str
173
174
  end
174
175
  end
175
176
  end
@@ -14,7 +14,7 @@ module Spreader
14
14
  # The Total number of results
15
15
  # @return [Integer]
16
16
  def total
17
- @obj['total']
17
+ @obj['total'].to_i
18
18
  end
19
19
 
20
20
  # The first result
@@ -26,7 +26,7 @@ module Spreader
26
26
  # The number of bots shown in the first page
27
27
  # @return [Integer]
28
28
  def count
29
- @obj['count']
29
+ @obj['count'].to_i
30
30
  end
31
31
 
32
32
  # Iterates through the results
data/pkg/topgg-1.0.1.gem CHANGED
Binary file
Binary file
data/topgg.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'topgg'
5
- spec.version = '1.0.1'
5
+ spec.version = '1.0.5'
6
6
  spec.authors = ['Adonis Tremblay']
7
7
  spec.email = ['rhydderchc@gmail.com']
8
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: topgg
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adonis Tremblay
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-28 00:00:00.000000000 Z
11
+ date: 2021-08-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This is a ruby library of the top.gg API.
14
14
  email:
@@ -30,6 +30,7 @@ files:
30
30
  - lib/topgg/user.rb
31
31
  - lib/topgg/votes.rb
32
32
  - pkg/topgg-1.0.1.gem
33
+ - pkg/topgg-1.0.2.gem
33
34
  - topgg.gemspec
34
35
  homepage: https://github.com/rhydderchc/topgg-ruby
35
36
  licenses: