discorb 0.0.1 → 0.0.5

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: ae7ec3df7c6da178e1ce924879cbda686fa17b1a3ad3858419ef2bf6f4bc9ada
4
- data.tar.gz: f23eb8f8bc6acceacb33b555f38283297ff04140051c273a2ee26cf4c0fc50d4
3
+ metadata.gz: d38df4e18e2f0c0ab604723c2cd799b506863fc99a1bf48482b538174a65f2ae
4
+ data.tar.gz: 5a861ab96babd57d7be950c5e178bece1528d70a1bf39540a947a676a01d6d59
5
5
  SHA512:
6
- metadata.gz: f43d25457a75adadc96f6d3d3304ea38956006888a03ef1159f6b1ce2e956167e283e540cf1e64dcb43c40774b6a8fcc63b0b1f76b2d2da1ebf574a16869153c
7
- data.tar.gz: a6726842c6049171b02113947d430e96364021fbdcc5057d97feecb1d2a3f7866540c8327c2ad82e425a82cb8539ed7e2aa0a54ac4c1013593d2196630761fbb
6
+ metadata.gz: d7dcd629994dd0c52c8a7af393822913498072e358f33d0ee97e1a3f6627d26c5eb30b014908012ed7c109f0ed1c8d1463a94d72f3165abd47ef4e275900999c
7
+ data.tar.gz: d04c1c1212f5bb653c6b6221b255da8ee4b1f1b6ca0602424d552d3f8a5aeb60a443db99056155490af7d3f7d9408d03108802fda4606a1645e91a169b2e6379
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.1)
4
+ discorb (0.0.5)
5
+ async
6
+ async-http
7
+ async-websocket
8
+ mime-types (~> 3.3)
5
9
 
6
10
  GEM
7
11
  remote: https://rubygems.org/
@@ -25,7 +29,6 @@ GEM
25
29
  async-http (~> 0.54)
26
30
  async-io (~> 1.23)
27
31
  protocol-websocket (~> 0.7.0)
28
- colorize (0.8.1)
29
32
  console (1.13.1)
30
33
  fiber-local
31
34
  fiber-local (1.0.0)
@@ -45,7 +48,6 @@ GEM
45
48
  protocol-http1 (~> 0.2)
46
49
  rake (13.0.6)
47
50
  redcarpet (3.5.1)
48
- ricecream (0.2.0)
49
51
  rufo (0.13.0)
50
52
  timers (4.3.3)
51
53
  yard (0.9.26)
@@ -57,12 +59,10 @@ DEPENDENCIES
57
59
  async
58
60
  async-http
59
61
  async-websocket
60
- colorize (~> 0.8.1)
61
62
  discorb!
62
63
  mime-types (~> 3.3)
63
64
  rake (~> 13.0)
64
65
  redcarpet
65
- ricecream (~> 0.2.0)
66
66
  rufo (~> 0.13.0)
67
67
  yard (~> 0.9.26)
68
68
 
data/README.md CHANGED
@@ -46,7 +46,7 @@ client.run(ENV["DISCORD_BOT_TOKEN"])
46
46
 
47
47
  ## Contributing
48
48
 
49
- Bug reports and pull requests are welcome on GitHub at https://github.com/sevenc-nanashi/discorb.
49
+ Bug reports and pull requests are welcome on GitHub at https://github.com/discorb-lib/discorb.
50
50
 
51
51
  ## License
52
52
 
data/discorb.gemspec CHANGED
@@ -9,16 +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.description = File.read(File.join(__dir__, "README.md"))
13
- spec.homepage = "https://github.com/sevenc-nanashi/discorb"
12
+ spec.homepage = "https://github.com/discorb-lib/discorb"
14
13
  spec.license = "MIT"
15
14
  spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
16
15
 
17
16
  spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
17
 
19
18
  spec.metadata["homepage_uri"] = spec.homepage
20
- spec.metadata["source_code_uri"] = "https://github.com/sevenc-nanashi/discorb"
21
- 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"
22
21
 
23
22
  # Specify which files should be added to the gem when it is released.
24
23
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -30,8 +29,11 @@ Gem::Specification.new do |spec|
30
29
  spec.require_paths = ["lib"]
31
30
 
32
31
  # Uncomment to register a new dependency of your gem
33
- # spec.add_dependency "example-gem", "~> 1.0"
32
+ spec.add_dependency "async"
33
+ spec.add_dependency "async-http"
34
+ spec.add_dependency "async-websocket"
34
35
 
36
+ spec.add_dependency "mime-types", "~> 3.3"
35
37
  # For more information and examples about making a new gem, checkout our
36
38
  # guide at: https://bundler.io/guides/creating_gem.html
37
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,7 +970,7 @@ 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
@@ -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
@@ -1,8 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Discorb
4
+ # @return [String] The API base URL.
4
5
  API_BASE_URL = "https://discord.com/api/v9"
5
- VERSION = "0.0.1"
6
+ # @return [String] The version of discorb.
7
+ VERSION = "0.0.5"
8
+ # @return [String] The user agent for the bot.
6
9
  USER_AGENT = "DiscordBot (https://github.com/discorb-lib/discorb #{VERSION}) Ruby/#{RUBY_VERSION}"
7
10
 
8
11
  #
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