discorb 0.5.2 → 0.5.3

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: 3d17006d6ca103247dcf304581c61104054722b1af32bc8b3ec3d23b7f5e8680
4
- data.tar.gz: 92c481e5532d3e990ca73b891c71a87f5a4a2e6217ff7d7c5677519dbeaf4259
3
+ metadata.gz: 5ec867460217dad0b51aff3a636a564a2f2bfc881300861551b18c6bb249c4d9
4
+ data.tar.gz: 823fbab066d668f642e76c526c432fef93d3906e6f9934eaededd3b759cb299b
5
5
  SHA512:
6
- metadata.gz: b305d2f608c0506b7c84f53d16e4384710d454d5deacc69d51a55dbf81fe25d80ab7226717cb12480e07ba25f069a59a49a50608826d711c2a84edb4ec67258c
7
- data.tar.gz: c40281fb460527163504b8fe999f02a57db3190532a47c78ee25d71871372ff4c720a7ec0e17c70853083ad7327ae574e418b080d7379c98d683fcc1ccb0169e
6
+ metadata.gz: 75a6ba486bb056d1ae2fc526ac24934b53b81b05bc10f7c435d87db74479490b342b9f4a38fd7e36cd78a3e89931637960702fd728835f30660b732c3645c5ca
7
+ data.tar.gz: 39233f9f24c1753f33a4a7ff866c3e64370809e1d40e228112286cbe1c3d19a7bd6915503206f4b5eca18935f8c1a4ebeff20991d62321243ae5a6b79c9a9b57
data/Changelog.md CHANGED
@@ -117,3 +117,10 @@
117
117
 
118
118
  - Fix: Fix bug of registering commands
119
119
  - Add: Add way to register commands in Extension
120
+
121
+ ## 0.5.3
122
+
123
+ - Add: Add way to handle raw events with `event_xxx`
124
+ - Add: Add `Client#session_id`
125
+ - Add: Add `Connectable`
126
+ - Fix: Fix error by sending DM
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- discorb (0.5.2)
4
+ discorb (0.5.3)
5
5
  async (~> 1.30.1)
6
6
  async-http (~> 0.56.5)
7
7
  async-websocket (~> 0.19.0)
@@ -636,7 +636,6 @@ module Discorb
636
636
 
637
637
  #
638
638
  # Represents a voice channel.
639
- # @todo Implement connecting to voice channel.
640
639
  #
641
640
  class VoiceChannel < GuildChannel
642
641
  # @return [Integer] The bitrate of the voice channel.
@@ -645,6 +644,8 @@ module Discorb
645
644
  # @return [nil] If the user limit is not set.
646
645
  attr_reader :user_limit
647
646
 
647
+ include Connectable
648
+
648
649
  @channel_type = 2
649
650
  #
650
651
  # Edit the voice channel.
@@ -699,6 +700,8 @@ module Discorb
699
700
  # @!visibility private
700
701
  attr_reader :stage_instances
701
702
 
703
+ include Connectable
704
+
702
705
  # @!attribute [r] stage_instance
703
706
  # @return [Discorb::StageInstance] The stage instance of the channel.
704
707
 
@@ -49,6 +49,8 @@ module Discorb
49
49
  attr_reader :ping
50
50
  # @return [:initialized, :running, :closed] The status of the client.
51
51
  attr_reader :status
52
+ # @return [Integer] The session ID of connection.
53
+ attr_reader :session_id
52
54
  # @private
53
55
  attr_reader :bottom_commands
54
56
 
@@ -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.2"
7
+ VERSION = "0.5.3"
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
 
@@ -977,7 +977,11 @@ module Discorb
977
977
  @log.info("Successfully resumed connection")
978
978
  dispatch(:resumed)
979
979
  else
980
- @log.warn "Unknown event: #{event_name}\n#{data.inspect}"
980
+ if respond_to?("event_" + event_name.downcase)
981
+ __send__("event_" + event_name.downcase, data)
982
+ else
983
+ @log.debug "Received unknown event: #{event_name}\n#{data.inspect}"
984
+ end
981
985
  end
982
986
  end
983
987
  end
@@ -208,4 +208,14 @@ module Discorb
208
208
  end
209
209
  end
210
210
  end
211
+
212
+ #
213
+ # Module for connecting to a voice channel.
214
+ # This will be discord-voice gem.
215
+ #
216
+ module Connectable
217
+ def connect
218
+ raise NotImplementedError, "This method is implemented by discord-voice gem."
219
+ end
220
+ end
211
221
  end
data/lib/discorb/user.rb CHANGED
@@ -78,7 +78,7 @@ module Discorb
78
78
  Async do
79
79
  next @dm_channel_id if @dm_channel_id
80
80
 
81
- dm_channel = @client.http.post("/users/#{@id}/channels", { recipient_id: @client.user.id }).wait
81
+ _resp, dm_channel = @client.http.post("/users/@me/channels", { recipient_id: @id }).wait
82
82
  @dm_channel_id = dm_channel[:id]
83
83
  @dm_channel_id
84
84
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discorb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - sevenc-nanashi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-10 00:00:00.000000000 Z
11
+ date: 2021-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async