dsu3 1.1.0 → 1.1.1
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 +4 -4
- data/lib/dsu3/api/message.rb +1 -1
- data/lib/dsu3/api/user.rb +1 -1
- data/lib/dsu3/api.rb +7 -11
- data/lib/dsu3/data/channel.rb +1 -1
- data/lib/dsu3/data/guild.rb +1 -1
- data/lib/dsu3/data/invite.rb +1 -1
- data/lib/dsu3/data/message.rb +1 -1
- data/lib/dsu3/data.rb +3 -1
- data/lib/dsu3/dobject.rb +1 -1
- data/lib/dsu3/errors.rb +1 -1
- data/lib/dsu3/net.rb +2 -2
- data/lib/dsu3/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 926cbe8acc038109fc2b0cda6f10af35f204f2c78e91fe6a31c87d9bd1ea81c3
|
4
|
+
data.tar.gz: a4e823799e5a47bcf068650364dd29d94154708c7db601275eb0f768bbb81e16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6eda735ef22ec9762a781d228fcc217f6dade60fbbdc2d65ba0c4efbfe2ceb6fc969698ff3f0311ac035fdf1b952e2e90560f0547e2f79ad07d6f3227836c4c9
|
7
|
+
data.tar.gz: a712aa467a11baeebd5549e88905d570d5e6df41446ef500e6e97785f026ec22b2d7a29ef2bc1f307ec9b20e7a21d14b8ebd89929045bf01b0d2ca2104e67a58
|
data/lib/dsu3/api/message.rb
CHANGED
data/lib/dsu3/api/user.rb
CHANGED
data/lib/dsu3/api.rb
CHANGED
@@ -15,8 +15,6 @@ module DSU3
|
|
15
15
|
module API
|
16
16
|
API_BASE = 'https://discord.com/api/v9/'
|
17
17
|
|
18
|
-
@ratelimits = []
|
19
|
-
|
20
18
|
module_function
|
21
19
|
|
22
20
|
# Makes an API request without any error handling
|
@@ -40,16 +38,14 @@ module DSU3
|
|
40
38
|
# @param (see #raw_request)
|
41
39
|
# @return (see #raw_request)
|
42
40
|
def request(...)
|
41
|
+
raw_request(...)
|
42
|
+
rescue RestClient::ExceptionWithResponse => e
|
43
43
|
begin
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
raise DSU3::CodeError.new("#{data['code']}: #{data['message']}")
|
50
|
-
rescue JSON::ParserError
|
51
|
-
raise e
|
52
|
-
end
|
44
|
+
data = JSON.parse(e.response.body)
|
45
|
+
raise DSU3::RateLimitError('ratelimit exceeded', data['retry_after']) if e.is_a?(RestClient::TooManyRequests)
|
46
|
+
raise DSU3::CodeError, "#{data['code']}: #{data['message']}"
|
47
|
+
rescue JSON::ParserError
|
48
|
+
raise e
|
53
49
|
end
|
54
50
|
end
|
55
51
|
end
|
data/lib/dsu3/data/channel.rb
CHANGED
data/lib/dsu3/data/guild.rb
CHANGED
data/lib/dsu3/data/invite.rb
CHANGED
data/lib/dsu3/data/message.rb
CHANGED
data/lib/dsu3/data.rb
CHANGED
data/lib/dsu3/dobject.rb
CHANGED
data/lib/dsu3/errors.rb
CHANGED
data/lib/dsu3/net.rb
CHANGED
@@ -18,7 +18,7 @@ module DSU3
|
|
18
18
|
# An auxiliary method that can be used to make an Discord API call from multiple tokens with ratelimit and thread support
|
19
19
|
# @param [Hash] opts Options
|
20
20
|
def request(opts = {})
|
21
|
-
opts = {cooldown: 0, loop: false}.merge(opts)
|
21
|
+
opts = { cooldown: 0, loop: false }.merge(opts)
|
22
22
|
|
23
23
|
@tokens.each do |token|
|
24
24
|
Thread.new do
|
@@ -35,7 +35,7 @@ module DSU3
|
|
35
35
|
end
|
36
36
|
|
37
37
|
# I'm too lazy to try to document it
|
38
|
-
%w
|
38
|
+
%w[channel guild invite].each do |s|
|
39
39
|
define_method s do |id|
|
40
40
|
DSU3.const_get(s.capitalize).new(self, id)
|
41
41
|
end
|
data/lib/dsu3/version.rb
CHANGED