discorb 0.0.2 → 0.0.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: 0a32a002d33210039aacb1a4802bb42be46e0fb7f9c6319d264084f8f1d0c1be
4
- data.tar.gz: 71b155ead20f62222ee16476b3cb67158e99552a9ca03217d9490635b872a0d1
3
+ metadata.gz: ee2a3c4a3aa6c3f41d7138a4d50b51a38b6f5c92a4a3e569b6ec4c035b7109d0
4
+ data.tar.gz: 810df7edee99dbfc2db097f43f37c5654f0e1c72554e3eeb667983b89171cdf9
5
5
  SHA512:
6
- metadata.gz: 6ee838569580649c919d85870323f3012a262ab6c3b44898a1210eb1a2d01b9535e04145e41ebd68a7c3c80bfa3c4ad1271faa583ace11523b5d9de1f0b82300
7
- data.tar.gz: 85456ebe7cf6d02850791c69898dbfb868a19291b0abb7a6a86a8786221ac64af0d403021cf096c06e4cf4a94b60c4e7063e2503209c81cc549af5da9427ed6c
6
+ metadata.gz: d41a9a758f24e643b45de341d27944c901550190053b313df830a2894c22c2a5841fe4d5c5b2115250e208bec2fbdc4cf629220d47e3049a4d498ea4ef91af68
7
+ data.tar.gz: 453ee62c4492bf692e86f5040292c0e89be91906556d94c8752888a90ab028ef9c94100c273ecbb15dcc7db33ebc6d18f3ce56938d91e66a66e18b3b46667632
data/Changelog.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
- ## v0.0.1 - Initial release
3
+ ## v0.0.1
4
4
 
5
- - Initial release
5
+ - Initial release
6
+
7
+ ## v0.0.2
8
+
9
+ - Fix: Fix rubygems description
10
+
11
+ ## v0.0.3
12
+
13
+ - Fix: Fix no dependencies
14
+
15
+ ## v0.0.4
16
+
17
+ - Fix: Fix NoMethodError by webhook message
data/Gemfile.lock CHANGED
@@ -1,7 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- discorb (0.0.2)
4
+ discorb (0.0.6)
5
+ async
6
+ async-http
7
+ async-websocket
8
+ mime-types (~> 3.3)
5
9
 
6
10
  GEM
7
11
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # discorb
2
2
  [![rubydoc](https://img.shields.io/badge/Document-rubydoc.info-blue.svg)](https://rubydoc.info/gems/discorb)
3
3
  [![Gem](https://img.shields.io/gem/dt/discorb?logo=rubygems&logoColor=fff)](https://rubygems.org/gems/discorb)
4
- [![Gem](https://img.shields.io/gem/v/discorb?logo=rubygems&logoColor=fff)](https://rubygems.org/gems/discorb)
4
+ [![Gem](https://img.shields.io/gem/v/discorb?logo=rubygems&logoColor=fff)](https://rubygems.org/gems/discorb)
5
+ [![Discord](https://img.shields.io/discord/863581274916913193?logo=discord&logoColor=fff&color=5865f2&label=Discord)](https://discord.gg/hCP6zq8Vpj)
5
6
 
6
7
  discorb is a Discord API wrapper for Ruby.
7
8
 
@@ -46,7 +47,7 @@ client.run(ENV["DISCORD_BOT_TOKEN"])
46
47
 
47
48
  ## Contributing
48
49
 
49
- Bug reports and pull requests are welcome on GitHub at https://github.com/sevenc-nanashi/discorb.
50
+ Bug reports and pull requests are welcome on GitHub at https://github.com/discorb-lib/discorb.
50
51
 
51
52
  ## License
52
53
 
data/discorb.gemspec CHANGED
@@ -9,15 +9,15 @@ Gem::Specification.new do |spec|
9
9
  spec.email = ["sevenc-nanashi@sevenbot.jp"]
10
10
 
11
11
  spec.summary = "discorb is a Discord API wrapper for Ruby."
12
- spec.homepage = "https://github.com/sevenc-nanashi/discorb"
12
+ spec.homepage = "https://github.com/discorb-lib/discorb"
13
13
  spec.license = "MIT"
14
14
  spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
15
15
 
16
16
  spec.metadata["allowed_push_host"] = "https://rubygems.org"
17
17
 
18
18
  spec.metadata["homepage_uri"] = spec.homepage
19
- spec.metadata["source_code_uri"] = "https://github.com/sevenc-nanashi/discorb"
20
- spec.metadata["changelog_uri"] = "https://github.com/sevenc-nanashi/discorb/blob/main/Changelog.md"
19
+ spec.metadata["source_code_uri"] = "https://github.com/discorb-lib/discorb"
20
+ spec.metadata["changelog_uri"] = "https://github.com/discorb-lib/discorb/blob/main/Changelog.md"
21
21
 
22
22
  # Specify which files should be added to the gem when it is released.
23
23
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -29,8 +29,11 @@ Gem::Specification.new do |spec|
29
29
  spec.require_paths = ["lib"]
30
30
 
31
31
  # Uncomment to register a new dependency of your gem
32
- # spec.add_dependency "example-gem", "~> 1.0"
32
+ spec.add_dependency "async"
33
+ spec.add_dependency "async-http"
34
+ spec.add_dependency "async-websocket"
33
35
 
36
+ spec.add_dependency "mime-types", "~> 3.3"
34
37
  # For more information and examples about making a new gem, checkout our
35
38
  # guide at: https://bundler.io/guides/creating_gem.html
36
39
  end
@@ -175,7 +175,7 @@ module Discorb
175
175
  #
176
176
  def delete!(reason: nil)
177
177
  Async do
178
- @client.internet.delete(base_url.wait.to_s, audit_log_reason: reason).wait
178
+ @client.http.delete(base_url.wait.to_s, audit_log_reason: reason).wait
179
179
  @deleted = true
180
180
  self
181
181
  end
@@ -203,7 +203,7 @@ module Discorb
203
203
  }
204
204
  payload[:lock_permissions] = lock_permissions
205
205
  payload[:parent_id] = parent&.id if parent != :unset
206
- @client.internet.patch("/guilds/#{@guild_id}/channels", payload, audit_log_reason: reason).wait
206
+ @client.http.patch("/guilds/#{@guild_id}/channels", payload, audit_log_reason: reason).wait
207
207
  end
208
208
  end
209
209
 
@@ -295,7 +295,7 @@ module Discorb
295
295
  default_auto_archive_duration ||= archive_in
296
296
  payload[:default_auto_archive_duration] = default_auto_archive_duration if default_auto_archive_duration != :unset
297
297
 
298
- @client.internet.patch("/channels/#{@id}", payload, audit_log_reason: reason).wait
298
+ @client.http.patch("/channels/#{@id}", payload, audit_log_reason: reason).wait
299
299
  self
300
300
  end
301
301
  end
@@ -317,7 +317,7 @@ module Discorb
317
317
  payload = {}
318
318
  payload[:name] = name
319
319
  payload[:avatar] = avatar.to_s if avatar
320
- _resp, data = @client.internet.post("/channels/#{@id}/webhooks", payload).wait
320
+ _resp, data = @client.http.post("/channels/#{@id}/webhooks", payload).wait
321
321
  Webhook.new([@client, data])
322
322
  end
323
323
  end
@@ -331,7 +331,7 @@ module Discorb
331
331
  #
332
332
  def fetch_webhooks
333
333
  Async do
334
- _resp, data = @client.internet.get("/channels/#{@id}/webhooks").wait
334
+ _resp, data = @client.http.get("/channels/#{@id}/webhooks").wait
335
335
  data.map { |webhook| Webhook.new([@client, webhook]) }
336
336
  end
337
337
  end
@@ -358,7 +358,7 @@ module Discorb
358
358
 
359
359
  message_ids = messages.map { |m| Discorb::Utils.try(m, :id).to_s }
360
360
 
361
- @client.internet.post("/channels/#{@id}/messages/bulk-delete", { messages: message_ids }).wait
361
+ @client.http.post("/channels/#{@id}/messages/bulk-delete", { messages: message_ids }).wait
362
362
  end
363
363
  end
364
364
 
@@ -387,7 +387,7 @@ module Discorb
387
387
  deny: deny_value,
388
388
  type: target.is_a?(Member) ? 1 : 0,
389
389
  }
390
- @client.internet.put("/channels/#{@id}/permissions/#{target.id}", payload, audit_log_reason: reason).wait
390
+ @client.http.put("/channels/#{@id}/permissions/#{target.id}", payload, audit_log_reason: reason).wait
391
391
  end
392
392
  end
393
393
 
@@ -406,7 +406,7 @@ module Discorb
406
406
  #
407
407
  def delete_permissions(target, reason: nil)
408
408
  Async do
409
- @client.internet.delete("/channels/#{@id}/permissions/#{target.id}", audit_log_reason: reason).wait
409
+ @client.http.delete("/channels/#{@id}/permissions/#{target.id}", audit_log_reason: reason).wait
410
410
  end
411
411
  end
412
412
 
@@ -423,7 +423,7 @@ module Discorb
423
423
  #
424
424
  def fetch_invites
425
425
  Async do
426
- _resp, data = @client.internet.get("/channels/#{@id}/invites").wait
426
+ _resp, data = @client.http.get("/channels/#{@id}/invites").wait
427
427
  data.map { |invite| Invite.new(@client, invite) }
428
428
  end
429
429
  end
@@ -444,7 +444,7 @@ module Discorb
444
444
  #
445
445
  def create_invite(max_age: nil, max_uses: nil, temporary: false, unique: false, reason: nil)
446
446
  Async do
447
- _resp, data = @client.internet.post("/channels/#{@id}/invites", {
447
+ _resp, data = @client.http.post("/channels/#{@id}/invites", {
448
448
  max_age: max_age,
449
449
  max_uses: max_uses,
450
450
  temporary: temporary,
@@ -464,7 +464,7 @@ module Discorb
464
464
  #
465
465
  def follow_from(target, reason: nil)
466
466
  Async do
467
- @client.internet.post("/channels/#{target.id}/followers", { webhook_channel_id: @id }, audit_log_reason: reason).wait
467
+ @client.http.post("/channels/#{target.id}/followers", { webhook_channel_id: @id }, audit_log_reason: reason).wait
468
468
  end
469
469
  end
470
470
 
@@ -478,7 +478,7 @@ module Discorb
478
478
  #
479
479
  def follow_to(target, reason: nil)
480
480
  Async do
481
- @client.internet.post("/channels/#{@id}/followers", { webhook_channel_id: target.id }, audit_log_reason: reason).wait
481
+ @client.http.post("/channels/#{@id}/followers", { webhook_channel_id: target.id }, audit_log_reason: reason).wait
482
482
  end
483
483
  end
484
484
 
@@ -491,7 +491,7 @@ module Discorb
491
491
  #
492
492
  def fetch_pins
493
493
  Async do
494
- _resp, data = @client.internet.get("/channels/#{@id}/pins").wait
494
+ _resp, data = @client.http.get("/channels/#{@id}/pins").wait
495
495
  data.map { |pin| Message.new(@client, pin) }
496
496
  end
497
497
  end
@@ -506,7 +506,7 @@ module Discorb
506
506
  #
507
507
  def pin_message(message, reason: nil)
508
508
  Async do
509
- @client.internet.put("/channels/#{@id}/pins/#{message.id}", {}, audit_log_reason: reason).wait
509
+ @client.http.put("/channels/#{@id}/pins/#{message.id}", {}, audit_log_reason: reason).wait
510
510
  end
511
511
  end
512
512
 
@@ -520,7 +520,7 @@ module Discorb
520
520
  #
521
521
  def unpin_message(message, reason: nil)
522
522
  Async do
523
- @client.internet.delete("/channels/#{@id}/pins/#{message.id}", {}, audit_log_reason: reason).wait
523
+ @client.http.delete("/channels/#{@id}/pins/#{message.id}", {}, audit_log_reason: reason).wait
524
524
  end
525
525
  end
526
526
 
@@ -540,12 +540,12 @@ module Discorb
540
540
  def start_thread(name, message: nil, auto_archive_duration: 1440, public: true, reason: nil)
541
541
  Async do
542
542
  _resp, data = if message.nil?
543
- @client.internet.post("/channels/#{@id}/threads", {
543
+ @client.http.post("/channels/#{@id}/threads", {
544
544
  name: name, auto_archive_duration: auto_archive_duration, type: public ? 11 : 10,
545
545
  },
546
- audit_log_reason: reason).wait
546
+ audit_log_reason: reason).wait
547
547
  else
548
- @client.internet.post("/channels/#{@id}/messages/#{Utils.try(message, :id)}/threads", {
548
+ @client.http.post("/channels/#{@id}/messages/#{Utils.try(message, :id)}/threads", {
549
549
  name: name, auto_archive_duration: auto_archive_duration,
550
550
  }, audit_log_reason: reason).wait
551
551
  end
@@ -564,7 +564,7 @@ module Discorb
564
564
  #
565
565
  def fetch_archived_public_threads
566
566
  Async do
567
- _resp, data = @client.internet.get("/channels/#{@id}/threads/archived/public").wait
567
+ _resp, data = @client.http.get("/channels/#{@id}/threads/archived/public").wait
568
568
  data.map { |thread| Channel.make_channel(@client, thread) }
569
569
  end
570
570
  end
@@ -578,7 +578,7 @@ module Discorb
578
578
  #
579
579
  def fetch_archived_private_threads
580
580
  Async do
581
- _resp, data = @client.internet.get("/channels/#{@id}/threads/archived/private").wait
581
+ _resp, data = @client.http.get("/channels/#{@id}/threads/archived/private").wait
582
582
  data.map { |thread| Channel.make_channel(@client, thread) }
583
583
  end
584
584
  end
@@ -599,7 +599,7 @@ module Discorb
599
599
  before = 0
600
600
  threads = []
601
601
  loop do
602
- _resp, data = @client.internet.get("/channels/#{@id}/users/@me/threads/archived/private?before=#{before}").wait
602
+ _resp, data = @client.http.get("/channels/#{@id}/users/@me/threads/archived/private?before=#{before}").wait
603
603
  threads += data[:threads].map { |thread| Channel.make_channel(@client, thread) }
604
604
  before = data[:threads][-1][:id]
605
605
 
@@ -607,7 +607,7 @@ module Discorb
607
607
  end
608
608
  threads
609
609
  else
610
- _resp, data = @client.internet.get("/channels/#{@id}/users/@me/threads/archived/private?limit=#{limit}&before=#{before}").wait
610
+ _resp, data = @client.http.get("/channels/#{@id}/users/@me/threads/archived/private?limit=#{limit}&before=#{before}").wait
611
611
  data.map { |thread| Channel.make_channel(@client, thread) }
612
612
  end
613
613
  end
@@ -670,7 +670,7 @@ module Discorb
670
670
  payload[:user_limit] = user_limit if user_limit != :unset
671
671
  payload[:rtc_region] = rtc_region if rtc_region != :unset
672
672
 
673
- @client.internet.patch("/channels/#{@id}", payload, audit_log_reason: reason).wait
673
+ @client.http.patch("/channels/#{@id}", payload, audit_log_reason: reason).wait
674
674
  self
675
675
  end
676
676
  end
@@ -734,7 +734,7 @@ module Discorb
734
734
  payload[:position] = position if position != :unset
735
735
  payload[:bitrate] = bitrate if bitrate != :unset
736
736
  payload[:rtc_region] = rtc_region if rtc_region != :unset
737
- @client.internet.patch("/channels/#{@id}", payload, audit_log_reason: reason).wait
737
+ @client.http.patch("/channels/#{@id}", payload, audit_log_reason: reason).wait
738
738
  self
739
739
  end
740
740
  end
@@ -754,7 +754,7 @@ module Discorb
754
754
  #
755
755
  def start(topic, public: false, reason: nil)
756
756
  Async do
757
- _resp, data = @client.internet.post("/stage-instances", { channel_id: @id, topic: topic, public: public ? 2 : 1 }, audit_log_reason: reason).wait
757
+ _resp, data = @client.http.post("/stage-instances", { channel_id: @id, topic: topic, public: public ? 2 : 1 }, audit_log_reason: reason).wait
758
758
  StageInstance.new(@client, data)
759
759
  end
760
760
  end
@@ -769,7 +769,7 @@ module Discorb
769
769
  #
770
770
  def fetch_stage_instance
771
771
  Async do
772
- _resp, data = @client.internet.get("/stage-instances/#{@id}").wait
772
+ _resp, data = @client.http.get("/stage-instances/#{@id}").wait
773
773
  rescue Discorb::NotFoundError
774
774
  nil
775
775
  else
@@ -865,7 +865,7 @@ module Discorb
865
865
  auto_archive_duration ||= archive_in
866
866
  payload[:auto_archive_duration] = auto_archive_duration if auto_archive_duration != :unset
867
867
  payload[:locked] = locked if locked != :unset
868
- @client.internet.patch("/channels/#{@id}", payload, audit_log_reason: reason).wait
868
+ @client.http.patch("/channels/#{@id}", payload, audit_log_reason: reason).wait
869
869
  self
870
870
  end
871
871
  end
@@ -947,9 +947,9 @@ module Discorb
947
947
  def add_member(member = :me)
948
948
  Async do
949
949
  if member == :me
950
- @client.internet.post("/channels/#{@id}/thread-members/@me").wait
950
+ @client.http.post("/channels/#{@id}/thread-members/@me").wait
951
951
  else
952
- @client.internet.post("/channels/#{@id}/thread-members/#{Utils.try(member, :id)}").wait
952
+ @client.http.post("/channels/#{@id}/thread-members/#{Utils.try(member, :id)}").wait
953
953
  end
954
954
  end
955
955
  end
@@ -959,9 +959,9 @@ module Discorb
959
959
  def remove_member(member = :me)
960
960
  Async do
961
961
  if member == :me
962
- @client.internet.delete("/channels/#{@id}/thread-members/@me").wait
962
+ @client.http.delete("/channels/#{@id}/thread-members/@me").wait
963
963
  else
964
- @client.internet.delete("/channels/#{@id}/thread-members/#{Utils.try(member, :id)}").wait
964
+ @client.http.delete("/channels/#{@id}/thread-members/#{Utils.try(member, :id)}").wait
965
965
  end
966
966
  end
967
967
  end
@@ -970,11 +970,15 @@ module Discorb
970
970
 
971
971
  def fetch_members
972
972
  Async do
973
- _resp, data = @client.internet.get("/channels/#{@id}/thread-members").wait
973
+ _resp, data = @client.http.get("/channels/#{@id}/thread-members").wait
974
974
  data.map { |d| @members[d[:id]] = Member.new(@client, d) }
975
975
  end
976
976
  end
977
977
 
978
+ class News < ThreadChannel
979
+ @channel_type = 10
980
+ end
981
+
978
982
  class Public < ThreadChannel
979
983
  @channel_type = 11
980
984
  end
@@ -16,8 +16,8 @@ module Discorb
16
16
  # @return [Discorb::Application] The application that the client is using.
17
17
  # @return [nil] If never fetched application by {#fetch_application}.
18
18
  attr_reader :application
19
- # @return [Discorb::Internet] The internet client.
20
- attr_reader :internet
19
+ # @return [Discorb::HTTP] The http client.
20
+ attr_reader :http
21
21
  # @return [Integer] The heartbeat interval.
22
22
  attr_reader :heartbeat_interval
23
23
  # @return [Integer] The API version of the Discord gateway.
@@ -187,7 +187,7 @@ module Discorb
187
187
  #
188
188
  def fetch_user(id)
189
189
  Async do
190
- _resp, data = internet.get("/users/#{id}").wait
190
+ _resp, data = http.get("/users/#{id}").wait
191
191
  User.new(self, data)
192
192
  end
193
193
  end
@@ -205,7 +205,7 @@ module Discorb
205
205
  #
206
206
  def fetch_channel(id)
207
207
  Async do
208
- _resp, data = internet.get("/channels/#{id}").wait
208
+ _resp, data = http.get("/channels/#{id}").wait
209
209
  Channel.make_channel(self, data)
210
210
  end
211
211
  end
@@ -223,7 +223,7 @@ module Discorb
223
223
  #
224
224
  def fetch_guild(id)
225
225
  Async do
226
- _resp, data = internet.get("/guilds/#{id}").wait
226
+ _resp, data = http.get("/guilds/#{id}").wait
227
227
  Guild.new(self, data, false)
228
228
  end
229
229
  end
@@ -241,7 +241,7 @@ module Discorb
241
241
  #
242
242
  def fetch_invite(code, with_count: false, with_expiration: false)
243
243
  Async do
244
- _resp, data = internet.get("/invites/#{code}?with_count=#{with_count}&with_expiration=#{with_expiration}").wait
244
+ _resp, data = http.get("/invites/#{code}?with_count=#{with_count}&with_expiration=#{with_expiration}").wait
245
245
  Invite.new(self, data, false)
246
246
  end
247
247
  end
@@ -260,7 +260,7 @@ module Discorb
260
260
  Async do
261
261
  next @application if @application && !force
262
262
 
263
- _resp, data = internet.get("/oauth2/applications/@me").wait
263
+ _resp, data = http.get("/oauth2/applications/@me").wait
264
264
  @application = Application.new(self, data)
265
265
  @application
266
266
  end
@@ -275,7 +275,7 @@ module Discorb
275
275
  #
276
276
  def fetch_nitro_sticker_packs
277
277
  Async do
278
- _resp, data = internet.get("/stickers-packs").wait
278
+ _resp, data = http.get("/stickers-packs").wait
279
279
  data.map { |pack| Sticker::Pack.new(self, pack) }
280
280
  end
281
281
  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.0.2"
7
+ VERSION = "0.0.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
@@ -86,7 +86,7 @@ module Discorb
86
86
  payload = {}
87
87
  payload[:name] = name if name != :unset
88
88
  payload[:roles] = roles.map { |r| Discorb::Utils.try(r, :id) } if roles != :unset
89
- @client.internet.patch("/guilds/#{@guild.id}/emojis/#{@id}", payload, audit_log_reason: reason)
89
+ @client.http.patch("/guilds/#{@guild.id}/emojis/#{@id}", payload, audit_log_reason: reason)
90
90
  self
91
91
  end
92
92
  end
@@ -104,7 +104,7 @@ module Discorb
104
104
  #
105
105
  def delete!(reason: nil)
106
106
  Async do
107
- @client.internet.delete("/guilds/#{@guild.id}/emojis/#{@id}", audit_log_reason: reason).wait
107
+ @client.http.delete("/guilds/#{@guild.id}/emojis/#{@id}", audit_log_reason: reason).wait
108
108
  @available = false
109
109
  self
110
110
  end