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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d6919eceb7431839769fc4bca402df56fef34e50d12f47f6cc8824e210bef95b
4
- data.tar.gz: 8e50f4f53b5a1b52d3c4e29f9856cac2469a067c7d6005542a520081622d8da2
3
+ metadata.gz: 8484feb78582222a91d4fee1225fe649edc6a24a4c6c77eb83fa6c3094b3935d
4
+ data.tar.gz: 7597101823bd4f3f6900636af7f06320d9c296659069ff69bc829b7528171372
5
5
  SHA512:
6
- metadata.gz: 45a3649f783094e691921a041428df1a7a1d368705a116240385b94e9d2b30983a232b47a5d702c50ae61a7a4b36ef3252f6b7f48992832c6f4073cadab08d26
7
- data.tar.gz: 1a89fba62ef9b03db524eb6b57e409280c1888709e248df33cd1c42266c12ae534535a39c2765046a56eebd66adb5b8472f202115cf0e16cfcbbefee04e17e1a
6
+ metadata.gz: e6a690ccd8d95f66db74cafd22a430472841183d3048b10529009a0a64a1ba4c21f553fe83746c7356b3069c87badd3768c88834a34cecb0194ccf818a128947
7
+ data.tar.gz: cd46b4dd261aea5d4f9b2257e1cb81f07b377922364080863cce61551293dbb08ded110d15bac44812307d7846edb7a77787ef2e3f003bcb1ae977f8c35545b6
data/Changelog.md CHANGED
@@ -131,4 +131,10 @@
131
131
 
132
132
  ## 0.5.5
133
133
 
134
- - Fix: Fix some bugs
134
+ - Fix: Fix some bugs
135
+
136
+ ## 0.5.6
137
+
138
+ - Add: Raise error when intents are invalid
139
+ - Fix: Fix Emoji#==
140
+
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- discorb (0.5.5)
4
+ discorb (0.5.6)
5
5
  async (~> 1.30.1)
6
6
  async-http (~> 0.56.5)
7
7
  async-websocket (~> 0.19.0)
@@ -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
@@ -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.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
@@ -6,6 +6,13 @@ module Discorb
6
6
  # Represents a Discord emoji.
7
7
  # @abstract
8
8
  class Emoji
9
+ def eql?(other)
10
+ other.is_a?(self.class) && other.to_uri == to_uri
11
+ end
12
+
13
+ def ==(other)
14
+ eql?(other)
15
+ end
9
16
  end
10
17
 
11
18
  # Represents a custom emoji in discord.
@@ -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
- task.sleep(2)
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
- task.sleep((interval / 1000.0 - 1) * rand)
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discorb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - sevenc-nanashi