discorb 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +7 -1
- data/Gemfile.lock +1 -1
- data/lib/discorb/client.rb +2 -2
- data/lib/discorb/common.rb +1 -1
- data/lib/discorb/emoji.rb +7 -0
- data/lib/discorb/gateway.rb +10 -3
- 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: 8484feb78582222a91d4fee1225fe649edc6a24a4c6c77eb83fa6c3094b3935d
|
4
|
+
data.tar.gz: 7597101823bd4f3f6900636af7f06320d9c296659069ff69bc829b7528171372
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6a690ccd8d95f66db74cafd22a430472841183d3048b10529009a0a64a1ba4c21f553fe83746c7356b3069c87badd3768c88834a34cecb0194ccf818a128947
|
7
|
+
data.tar.gz: cd46b4dd261aea5d4f9b2257e1cb81f07b377922364080863cce61551293dbb08ded110d15bac44812307d7846edb7a77787ef2e3f003bcb1ae977f8c35545b6
|
data/Changelog.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/discorb/client.rb
CHANGED
@@ -460,7 +460,7 @@ module Discorb
|
|
460
460
|
}
|
461
461
|
@token = token.to_s
|
462
462
|
@close_condition = Async::Condition.new
|
463
|
-
main_task = Async do
|
463
|
+
@main_task = Async do
|
464
464
|
@status = :running
|
465
465
|
connect_gateway(true).wait
|
466
466
|
rescue
|
@@ -469,7 +469,7 @@ module Discorb
|
|
469
469
|
raise
|
470
470
|
end
|
471
471
|
@close_condition.wait
|
472
|
-
main_task.stop
|
472
|
+
@main_task.stop
|
473
473
|
end
|
474
474
|
end
|
475
475
|
end
|
data/lib/discorb/common.rb
CHANGED
@@ -4,7 +4,7 @@ module Discorb
|
|
4
4
|
# @return [String] The API base URL.
|
5
5
|
API_BASE_URL = "https://discord.com/api/v9"
|
6
6
|
# @return [String] The version of discorb.
|
7
|
-
VERSION = "0.5.
|
7
|
+
VERSION = "0.5.6"
|
8
8
|
# @return [String] The user agent for the bot.
|
9
9
|
USER_AGENT = "DiscordBot (https://github.com/discorb-lib/discorb #{VERSION}) Ruby/#{RUBY_VERSION}"
|
10
10
|
|
data/lib/discorb/emoji.rb
CHANGED
data/lib/discorb/gateway.rb
CHANGED
@@ -513,7 +513,6 @@ module Discorb
|
|
513
513
|
case payload[:op]
|
514
514
|
when 10
|
515
515
|
@heartbeat_interval = data[:heartbeat_interval]
|
516
|
-
@tasks << handle_heartbeat(@heartbeat_interval)
|
517
516
|
if @first
|
518
517
|
payload = {
|
519
518
|
token: @token,
|
@@ -523,6 +522,13 @@ module Discorb
|
|
523
522
|
}
|
524
523
|
payload[:presence] = @identify_presence if @identify_presence
|
525
524
|
send_gateway(2, **payload)
|
525
|
+
Async do
|
526
|
+
sleep 2
|
527
|
+
next unless @uncached_guilds.nil?
|
528
|
+
|
529
|
+
raise ClientError, "Failed to connect to gateway.\nHint: This usually means that your intents are invalid."
|
530
|
+
exit 1
|
531
|
+
end
|
526
532
|
else
|
527
533
|
payload = {
|
528
534
|
token: @token,
|
@@ -540,7 +546,7 @@ module Discorb
|
|
540
546
|
connect_gateway(false)
|
541
547
|
else
|
542
548
|
@log.info "Connection is not resumable, reconnecting with opcode 2"
|
543
|
-
|
549
|
+
sleep(2)
|
544
550
|
@connection.close
|
545
551
|
connect_gateway(true)
|
546
552
|
end
|
@@ -555,7 +561,7 @@ module Discorb
|
|
555
561
|
|
556
562
|
def handle_heartbeat(interval)
|
557
563
|
Async do |task|
|
558
|
-
|
564
|
+
sleep((interval / 1000.0 - 1) * rand)
|
559
565
|
loop do
|
560
566
|
@heartbeat_before = Time.now.to_f
|
561
567
|
@connection.write({ op: 1, d: @last_s }.to_json)
|
@@ -578,6 +584,7 @@ module Discorb
|
|
578
584
|
@session_id = data[:session_id]
|
579
585
|
@user = ClientUser.new(self, data[:user])
|
580
586
|
@uncached_guilds = data[:guilds].map { |g| g[:id] }
|
587
|
+
@tasks << handle_heartbeat(@heartbeat_interval)
|
581
588
|
when "GUILD_CREATE"
|
582
589
|
if @uncached_guilds.include?(data[:id])
|
583
590
|
Guild.new(self, data, true)
|