discorb 0.12.2 → 0.13.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build_main.yml +1 -0
  3. data/.github/workflows/build_version.yml +1 -0
  4. data/.github/workflows/crowdin.yml +32 -0
  5. data/.gitignore +3 -1
  6. data/.yardopts +2 -0
  7. data/Changelog.md +399 -367
  8. data/Gemfile +5 -1
  9. data/README.md +1 -1
  10. data/Rakefile +139 -9
  11. data/crowdin.yml +2 -0
  12. data/discorb.gemspec +1 -1
  13. data/docs/Examples.md +2 -0
  14. data/docs/application_command.md +17 -12
  15. data/docs/cli/irb.md +2 -0
  16. data/docs/cli/new.md +2 -0
  17. data/docs/cli/run.md +3 -1
  18. data/docs/cli/setup.md +4 -2
  19. data/docs/cli.md +2 -0
  20. data/docs/events.md +59 -5
  21. data/docs/extension.md +2 -2
  22. data/docs/faq.md +4 -2
  23. data/docs/license.md +2 -0
  24. data/docs/tutorial.md +4 -3
  25. data/docs/voice_events.md +2 -0
  26. data/lib/discorb/app_command.rb +13 -7
  27. data/lib/discorb/application.rb +32 -2
  28. data/lib/discorb/audit_logs.rb +28 -16
  29. data/lib/discorb/channel.rb +112 -81
  30. data/lib/discorb/client.rb +17 -19
  31. data/lib/discorb/common.rb +28 -1
  32. data/lib/discorb/components.rb +12 -0
  33. data/lib/discorb/dictionary.rb +1 -1
  34. data/lib/discorb/embed.rb +4 -0
  35. data/lib/discorb/emoji.rb +9 -7
  36. data/lib/discorb/emoji_table.rb +3774 -3689
  37. data/lib/discorb/event.rb +266 -24
  38. data/lib/discorb/event_handler.rb +39 -0
  39. data/lib/discorb/exe/show.rb +2 -0
  40. data/lib/discorb/extension.rb +5 -5
  41. data/lib/discorb/file.rb +4 -0
  42. data/lib/discorb/flag.rb +5 -1
  43. data/lib/discorb/gateway.rb +65 -14
  44. data/lib/discorb/gateway_requests.rb +4 -0
  45. data/lib/discorb/guild.rb +169 -82
  46. data/lib/discorb/guild_template.rb +12 -9
  47. data/lib/discorb/http.rb +82 -37
  48. data/lib/discorb/image.rb +7 -5
  49. data/lib/discorb/integration.rb +4 -1
  50. data/lib/discorb/intents.rb +8 -3
  51. data/lib/discorb/interaction/autocomplete.rb +1 -1
  52. data/lib/discorb/interaction/command.rb +2 -2
  53. data/lib/discorb/interaction/response.rb +27 -25
  54. data/lib/discorb/interaction/root.rb +8 -0
  55. data/lib/discorb/invite.rb +3 -2
  56. data/lib/discorb/log.rb +4 -0
  57. data/lib/discorb/member.rb +42 -13
  58. data/lib/discorb/message.rb +32 -17
  59. data/lib/discorb/modules.rb +19 -26
  60. data/lib/discorb/permission.rb +4 -0
  61. data/lib/discorb/rate_limit.rb +6 -2
  62. data/lib/discorb/role.rb +15 -11
  63. data/lib/discorb/sticker.rb +17 -12
  64. data/lib/discorb/user.rb +8 -7
  65. data/lib/discorb/voice_state.rb +8 -5
  66. data/lib/discorb/webhook.rb +38 -47
  67. data/lib/discorb.rb +2 -2
  68. data/po/yard.pot +7775 -5157
  69. data/sig/discorb.rbs +3317 -3820
  70. data/template-replace/scripts/locale_ja.rb +62 -0
  71. data/template-replace/scripts/yard_replace.rb +6 -0
  72. metadata +7 -4
@@ -27,7 +27,8 @@ module Discorb
27
27
  # @return [Boolean] Whether the application's bot requires a code grant.
28
28
  attr_reader :bot_require_code_grant
29
29
  alias bot_require_code_grant? bot_require_code_grant
30
-
30
+ # @return [Discorb::Application::Flag] The application's flags.
31
+ attr_reader :flags
31
32
  # @private
32
33
  def initialize(client, data)
33
34
  @client = client
@@ -42,6 +43,7 @@ module Discorb
42
43
  @verify_key = data[:verify_key]
43
44
  @owner = @client.users[data[:owner][:id]] || User.new(@client, data[:owner])
44
45
  @team = data[:team] && Team.new(@client, data[:team])
46
+ @flags = Flag.new(data[:flags])
45
47
  end
46
48
 
47
49
  def inspect
@@ -52,6 +54,34 @@ module Discorb
52
54
 
53
55
  alias require_code_grant? bot_require_code_grant?
54
56
 
57
+ #
58
+ # Represents a flag for an application.
59
+ # ## Flag fields
60
+ #
61
+ # | Field|Value|
62
+ # |---|---|
63
+ # | `1 << 12` | `:gateway_presence` |
64
+ # | `1 << 13` | `:gateway_presence_limited` |
65
+ # | `1 << 14` | `:gateway_guild_members` |
66
+ # | `1 << 15` | `:gateway_guild_members_limited` |
67
+ # | `1 << 16` | `:verification_pending_guild_limit` |
68
+ # | `1 << 17` | `:embedded` |
69
+ # | `1 << 18` | `:gateway_message_content` |
70
+ # | `1 << 19` | `:gateway_message_content_limited` |
71
+ #
72
+ class Flag < Discorb::Flag
73
+ @bits = {
74
+ gateway_presence: 12,
75
+ gateway_presence_limited: 13,
76
+ gateway_guild_members: 14,
77
+ gateway_guild_members_limited: 15,
78
+ verification_pending_guild_limit: 16,
79
+ embedded: 17,
80
+ gateway_message_content: 18,
81
+ gateway_message_content_limited: 19,
82
+ }
83
+ end
84
+
55
85
  #
56
86
  # Represents a team for an application.
57
87
  #
@@ -101,7 +131,7 @@ module Discorb
101
131
  # @return [:invited, :accepted] The member's membership state.
102
132
  attr_reader :membership_state
103
133
  alias state membership_state
104
- # @return [Array<Permissions>] The permissions of the member.
134
+ # @return [Array<Symbol>] The permissions of the member.
105
135
  # @note This always return `:*`.
106
136
  attr_reader :permissions
107
137
 
@@ -90,6 +90,9 @@ module Discorb
90
90
  # * `:sticker_create`
91
91
  # * `:sticker_update`
92
92
  # * `:sticker_delete`
93
+ # * `:guild_scheduled_event_create`
94
+ # * `:guild_scheduled_event_update`
95
+ # * `:guild_scheduled_event_delete`
93
96
  # * `:thread_create`
94
97
  # * `:thread_update`
95
98
  # * `:thread_delete`
@@ -148,9 +151,12 @@ module Discorb
148
151
  90 => :sticker_create,
149
152
  91 => :sticker_update,
150
153
  92 => :sticker_delete,
154
+ 100 => :guild_scheduled_event_create,
155
+ 101 => :guild_scheduled_event_update,
156
+ 102 => :guild_scheduled_event_delete,
151
157
  110 => :thread_create,
152
158
  111 => :thread_update,
153
- 112 => :thread_delete
159
+ 112 => :thread_delete,
154
160
  }.freeze
155
161
 
156
162
  # @private
@@ -160,7 +166,7 @@ module Discorb
160
166
  role: ->(client, id, guild_id) { client.guilds[guild_id]&.roles&.[](id) },
161
167
  member: ->(client, id, guild_id) { client.guilds[guild_id]&.members&.[](id) },
162
168
  guild: ->(client, id, _guild_id) { client.guilds[id] },
163
- message: ->(client, id, _guild_id) { client.messages[id] }
169
+ message: ->(client, id, _guild_id) { client.messages[id] },
164
170
  }
165
171
 
166
172
  # @private
@@ -171,15 +177,15 @@ module Discorb
171
177
  @user_id = Snowflake.new(data[:user_id])
172
178
  @target_id = Snowflake.new(data[:target_id])
173
179
  @type = self.class.events[data[:action_type]]
174
- @target = self.class.converts[@type.to_s.split('_')[0].to_sym]&.call(client, @target_id, @gui)
180
+ @target = self.class.converts[@type.to_s.split("_")[0].to_sym]&.call(client, @target_id, @gui)
175
181
  @target ||= Snowflake.new(data[:target_id])
176
182
  @changes = data[:changes] && Changes.new(data[:changes])
177
183
  @reason = data[:reason]
178
184
  data[:options]&.each do |option, value|
179
185
  define_singleton_method(option) { value }
180
- if option.end_with?('_id')
181
- define_singleton_method(option.to_s.sub('_id', '')) do
182
- self.class.converts[option.to_s.split('_')[0].to_sym]&.call(client, value, @guild_id)
186
+ if option.end_with?("_id")
187
+ define_singleton_method(option.to_s.sub("_id", "")) do
188
+ self.class.converts[option.to_s.split("_")[0].to_sym]&.call(client, value, @guild_id)
183
189
  end
184
190
  end
185
191
  end
@@ -203,7 +209,7 @@ module Discorb
203
209
  end
204
210
 
205
211
  def inspect
206
- "#<#{self.class} #{@changes&.data&.length || 'No'} changes>"
212
+ "#<#{self.class} #{@changes&.data&.length || "No"} changes>"
207
213
  end
208
214
 
209
215
  class << self
@@ -268,15 +274,21 @@ module Discorb
268
274
  def initialize(data)
269
275
  @key = data[:key].to_sym
270
276
  method = case @key.to_s
271
- when /.*_id$/, 'id'
272
- ->(v) { Snowflake.new(v) }
273
- when 'permissions'
274
- ->(v) { Discorb::Permission.new(v.to_i) }
275
- else
276
- ->(v) { v }
277
- end
278
- @old_value = data[:old_value].then(&method)
279
- @new_value = data[:new_value].then(&method)
277
+ when /.*_id$/, "id"
278
+ ->(v) { Snowflake.new(v) }
279
+ when "permissions"
280
+ ->(v) { Discorb::Permission.new(v.to_i) }
281
+ when "status"
282
+ ->(v) { Discorb::ScheduledEvent.status[v] }
283
+ when "entity_type"
284
+ ->(v) { Discorb::ScheduledEvent.entity_type[v] }
285
+ when "privacy_level"
286
+ ->(v) { Discorb::StageInstance.privacy_level[v] || Discorb::ScheduledEvent.privacy_level[v] }
287
+ else
288
+ ->(v) { v }
289
+ end
290
+ @old_value = method.(data[:old_value])
291
+ @new_value = method.(data[:new_value])
280
292
  end
281
293
 
282
294
  #
@@ -166,8 +166,7 @@ module Discorb
166
166
 
167
167
  #
168
168
  # Deletes the channel.
169
- # @macro async
170
- # @macro http
169
+ # @async
171
170
  #
172
171
  # @param [String] reason The reason of deleting the channel.
173
172
  #
@@ -186,8 +185,7 @@ module Discorb
186
185
 
187
186
  #
188
187
  # Moves the channel to another position.
189
- # @macro async
190
- # @macro http
188
+ # @async
191
189
  #
192
190
  # @param [Integer] position The position to move the channel.
193
191
  # @param [Boolean] lock_permissions Whether to lock the permissions of the channel.
@@ -196,13 +194,13 @@ module Discorb
196
194
  #
197
195
  # @return [Async::Task<self>] The moved channel.
198
196
  #
199
- def move(position, lock_permissions: false, parent: :unset, reason: nil)
197
+ def move(position, lock_permissions: false, parent: Discorb::Unset, reason: nil)
200
198
  Async do
201
199
  payload = {
202
200
  position: position,
203
201
  }
204
202
  payload[:lock_permissions] = lock_permissions
205
- payload[:parent_id] = parent&.id if parent != :unset
203
+ payload[:parent_id] = parent&.id if parent != Discorb::Unset
206
204
  @client.http.patch("/guilds/#{@guild_id}/channels", payload, audit_log_reason: reason).wait
207
205
  end
208
206
  end
@@ -256,8 +254,7 @@ module Discorb
256
254
 
257
255
  #
258
256
  # Edits the channel.
259
- # @macro async
260
- # @macro http
257
+ # @async
261
258
  # @macro edit
262
259
  #
263
260
  # @param [String] name The name of the channel.
@@ -275,25 +272,25 @@ module Discorb
275
272
  #
276
273
  # @return [Async::Task<self>] The edited channel.
277
274
  #
278
- def edit(name: :unset, position: :unset, category: :unset, parent: :unset,
279
- topic: :unset, nsfw: :unset, announce: :unset,
280
- rate_limit_per_user: :unset, slowmode: :unset, default_auto_archive_duration: :unset,
281
- archive_in: :unset, reason: nil)
275
+ def edit(name: Discorb::Unset, position: Discorb::Unset, category: Discorb::Unset, parent: Discorb::Unset,
276
+ topic: Discorb::Unset, nsfw: Discorb::Unset, announce: Discorb::Unset,
277
+ rate_limit_per_user: Discorb::Unset, slowmode: Discorb::Unset, default_auto_archive_duration: Discorb::Unset,
278
+ archive_in: Discorb::Unset, reason: nil)
282
279
  Async do
283
280
  payload = {}
284
- payload[:name] = name if name != :unset
285
- payload[:announce] = announce ? 5 : 0 if announce != :unset
286
- payload[:position] = position if position != :unset
287
- payload[:topic] = topic || "" if topic != :unset
288
- payload[:nsfw] = nsfw if nsfw != :unset
281
+ payload[:name] = name if name != Discorb::Unset
282
+ payload[:announce] = announce ? 5 : 0 if announce != Discorb::Unset
283
+ payload[:position] = position if position != Discorb::Unset
284
+ payload[:topic] = topic || "" if topic != Discorb::Unset
285
+ payload[:nsfw] = nsfw if nsfw != Discorb::Unset
289
286
 
290
- slowmode = rate_limit_per_user if slowmode == :unset
291
- payload[:rate_limit_per_user] = slowmode || 0 if slowmode != :unset
292
- parent = category if parent == :unset
293
- payload[:parent_id] = parent&.id if parent != :unset
287
+ slowmode = rate_limit_per_user if slowmode == Discorb::Unset
288
+ payload[:rate_limit_per_user] = slowmode || 0 if slowmode != Discorb::Unset
289
+ parent = category if parent == Discorb::Unset
290
+ payload[:parent_id] = parent&.id if parent != Discorb::Unset
294
291
 
295
292
  default_auto_archive_duration ||= archive_in
296
- payload[:default_auto_archive_duration] = default_auto_archive_duration if default_auto_archive_duration != :unset
293
+ payload[:default_auto_archive_duration] = default_auto_archive_duration if default_auto_archive_duration != Discorb::Unset
297
294
 
298
295
  @client.http.patch("/channels/#{@id}", payload, audit_log_reason: reason).wait
299
296
  self
@@ -304,8 +301,7 @@ module Discorb
304
301
 
305
302
  #
306
303
  # Create webhook in the channel.
307
- # @macro async
308
- # @macro http
304
+ # @async
309
305
  #
310
306
  # @param [String] name The name of the webhook.
311
307
  # @param [Discorb::Image] avatar The avatar of the webhook.
@@ -324,8 +320,7 @@ module Discorb
324
320
 
325
321
  #
326
322
  # Fetch webhooks in the channel.
327
- # @macro async
328
- # @macro http
323
+ # @async
329
324
  #
330
325
  # @return [Async::Task<Array<Discorb::Webhook>>] The webhooks in the channel.
331
326
  #
@@ -338,12 +333,13 @@ module Discorb
338
333
 
339
334
  #
340
335
  # Bulk delete messages in the channel.
341
- # @macro async
342
- # @macro http
336
+ # @async
343
337
  #
344
338
  # @param [Discorb::Message] messages The messages to delete.
345
339
  # @param [Boolean] force Whether to ignore the validation for message (14 days limit).
346
340
  #
341
+ # @return [Async::Task<void>] The task.
342
+ #
347
343
  def delete_messages!(*messages, force: false)
348
344
  Async do
349
345
  messages = messages.first if messages.length == 1 && messages.first.is_a?(Array)
@@ -367,12 +363,13 @@ module Discorb
367
363
 
368
364
  #
369
365
  # Set the channel's permission overwrite.
370
- # @macro async
371
- # @macro http
366
+ # @async
372
367
  #
373
368
  # @param [Discorb::Role, Discorb::Member] target The target of the overwrite.
374
369
  # @param [String] reason The reason of setting the overwrite.
375
- # @param [Symbol => Boolean] perms The permission overwrites to replace.
370
+ # @param [{Symbol => Boolean}] perms The permission overwrites to replace.
371
+ #
372
+ # @return [Async::Task<void>] The task.
376
373
  #
377
374
  def set_permissions(target, reason: nil, **perms)
378
375
  Async do
@@ -398,12 +395,13 @@ module Discorb
398
395
 
399
396
  #
400
397
  # Delete the channel's permission overwrite.
401
- # @macro async
402
- # @macro http
398
+ # @async
403
399
  #
404
400
  # @param [Discorb::Role, Discorb::Member] target The target of the overwrite.
405
401
  # @param [String] reason The reason of deleting the overwrite.
406
402
  #
403
+ # @return [Async::Task<void>] The task.
404
+ #
407
405
  def delete_permissions(target, reason: nil)
408
406
  Async do
409
407
  @client.http.delete("/channels/#{@id}/permissions/#{target.id}", audit_log_reason: reason).wait
@@ -416,8 +414,7 @@ module Discorb
416
414
 
417
415
  #
418
416
  # Fetch the channel's invites.
419
- # @macro async
420
- # @macro http
417
+ # @async
421
418
  #
422
419
  # @return [Async::Task<Array<Discorb::Invite>>] The invites in the channel.
423
420
  #
@@ -430,8 +427,7 @@ module Discorb
430
427
 
431
428
  #
432
429
  # Create an invite in the channel.
433
- # @macro async
434
- # @macro http
430
+ # @async
435
431
  #
436
432
  # @param [Integer] max_age The max age of the invite.
437
433
  # @param [Integer] max_uses The max uses of the invite.
@@ -456,12 +452,13 @@ module Discorb
456
452
 
457
453
  #
458
454
  # Follow the existing announcement channel.
459
- # @macro async
460
- # @macro http
455
+ # @async
461
456
  #
462
457
  # @param [Discorb::NewsChannel] target The channel to follow.
463
458
  # @param [String] reason The reason of following the channel.
464
459
  #
460
+ # @return [Async::Task<void>] The task.
461
+ #
465
462
  def follow_from(target, reason: nil)
466
463
  Async do
467
464
  @client.http.post("/channels/#{target.id}/followers", { webhook_channel_id: @id }, audit_log_reason: reason).wait
@@ -470,12 +467,13 @@ module Discorb
470
467
 
471
468
  #
472
469
  # Follow the existing announcement channel from self.
473
- # @macro async
474
- # @macro http
470
+ # @async
475
471
  #
476
472
  # @param [Discorb::TextChannel] target The channel to follow to.
477
473
  # @param [String] reason The reason of following the channel.
478
474
  #
475
+ # @return [Async::Task<void>] The task.
476
+ #
479
477
  def follow_to(target, reason: nil)
480
478
  Async do
481
479
  @client.http.post("/channels/#{@id}/followers", { webhook_channel_id: target.id }, audit_log_reason: reason).wait
@@ -484,24 +482,30 @@ module Discorb
484
482
 
485
483
  #
486
484
  # Start thread in the channel.
487
- # @macro async
488
- # @macro http
485
+ # @async
489
486
  #
490
487
  # @param [String] name The name of the thread.
491
488
  # @param [Discorb::Message] message The message to start the thread.
492
489
  # @param [Integer] auto_archive_duration The duration of auto-archiving.
493
490
  # @param [Boolean] public Whether the thread is public.
491
+ # @param [Integer] rate_limit_per_user The rate limit per user.
492
+ # @param [Integer] slowmode Alias of `rate_limit_per_user`.
494
493
  # @param [String] reason The reason of starting the thread.
495
494
  #
496
495
  # @return [Async::Task<Discorb::ThreadChannel>] The started thread.
497
496
  #
498
- def start_thread(name, message: nil, auto_archive_duration: 1440, public: true, reason: nil)
497
+ def start_thread(name, message: nil, auto_archive_duration: 1440, public: true, rate_limit_per_user: nil, slowmode: nil, reason: nil)
499
498
  Async do
500
499
  _resp, data = if message.nil?
501
- @client.http.post("/channels/#{@id}/threads", {
502
- name: name, auto_archive_duration: auto_archive_duration, type: public ? 11 : 10,
503
- },
504
- audit_log_reason: reason).wait
500
+ @client.http.post(
501
+ "/channels/#{@id}/threads", {
502
+ name: name,
503
+ auto_archive_duration: auto_archive_duration,
504
+ type: public ? 11 : 10,
505
+ rate_limit_per_user: rate_limit_per_user || slowmode,
506
+ },
507
+ audit_log_reason: reason,
508
+ ).wait
505
509
  else
506
510
  @client.http.post("/channels/#{@id}/messages/#{Utils.try(message, :id)}/threads", {
507
511
  name: name, auto_archive_duration: auto_archive_duration,
@@ -515,8 +519,7 @@ module Discorb
515
519
 
516
520
  #
517
521
  # Fetch archived threads in the channel.
518
- # @macro async
519
- # @macro http
522
+ # @async
520
523
  #
521
524
  # @return [Async::Task<Array<Discorb::ThreadChannel>>] The archived threads in the channel.
522
525
  #
@@ -529,8 +532,7 @@ module Discorb
529
532
 
530
533
  #
531
534
  # Fetch archived private threads in the channel.
532
- # @macro async
533
- # @macro http
535
+ # @async
534
536
  #
535
537
  # @return [Async::Task<Array<Discorb::ThreadChannel>>] The archived private threads in the channel.
536
538
  #
@@ -543,8 +545,7 @@ module Discorb
543
545
 
544
546
  #
545
547
  # Fetch joined archived private threads in the channel.
546
- # @macro async
547
- # @macro http
548
+ # @async
548
549
  #
549
550
  # @param [Integer] limit The limit of threads to fetch.
550
551
  # @param [Time] before <description>
@@ -607,8 +608,7 @@ module Discorb
607
608
  @channel_type = 2
608
609
  #
609
610
  # Edit the voice channel.
610
- # @macro async
611
- # @macro http
611
+ # @async
612
612
  # @macro edit
613
613
  #
614
614
  # @param [String] name The name of the voice channel.
@@ -620,14 +620,14 @@ module Discorb
620
620
  #
621
621
  # @return [Async::Task<self>] The edited voice channel.
622
622
  #
623
- def edit(name: :unset, position: :unset, bitrate: :unset, user_limit: :unset, rtc_region: :unset, reason: nil)
623
+ def edit(name: Discorb::Unset, position: Discorb::Unset, bitrate: Discorb::Unset, user_limit: Discorb::Unset, rtc_region: Discorb::Unset, reason: nil)
624
624
  Async do
625
625
  payload = {}
626
- payload[:name] = name if name != :unset
627
- payload[:position] = position if position != :unset
628
- payload[:bitrate] = bitrate if bitrate != :unset
629
- payload[:user_limit] = user_limit if user_limit != :unset
630
- payload[:rtc_region] = rtc_region if rtc_region != :unset
626
+ payload[:name] = name if name != Discorb::Unset
627
+ payload[:position] = position if position != Discorb::Unset
628
+ payload[:bitrate] = bitrate if bitrate != Discorb::Unset
629
+ payload[:user_limit] = user_limit if user_limit != Discorb::Unset
630
+ payload[:rtc_region] = rtc_region if rtc_region != Discorb::Unset
631
631
 
632
632
  @client.http.patch("/channels/#{@id}", payload, audit_log_reason: reason).wait
633
633
  self
@@ -676,8 +676,7 @@ module Discorb
676
676
 
677
677
  #
678
678
  # Edit the stage channel.
679
- # @macro async
680
- # @macro http
679
+ # @async
681
680
  # @macro edit
682
681
  #
683
682
  # @param [String] name The name of the stage channel.
@@ -688,13 +687,13 @@ module Discorb
688
687
  #
689
688
  # @return [Async::Task<self>] The edited stage channel.
690
689
  #
691
- def edit(name: :unset, position: :unset, bitrate: :unset, rtc_region: :unset, reason: nil)
690
+ def edit(name: Discorb::Unset, position: Discorb::Unset, bitrate: Discorb::Unset, rtc_region: Discorb::Unset, reason: nil)
692
691
  Async do
693
692
  payload = {}
694
- payload[:name] = name if name != :unset
695
- payload[:position] = position if position != :unset
696
- payload[:bitrate] = bitrate if bitrate != :unset
697
- payload[:rtc_region] = rtc_region if rtc_region != :unset
693
+ payload[:name] = name if name != Discorb::Unset
694
+ payload[:position] = position if position != Discorb::Unset
695
+ payload[:bitrate] = bitrate if bitrate != Discorb::Unset
696
+ payload[:rtc_region] = rtc_region if rtc_region != Discorb::Unset
698
697
  @client.http.patch("/channels/#{@id}", payload, audit_log_reason: reason).wait
699
698
  self
700
699
  end
@@ -704,8 +703,7 @@ module Discorb
704
703
 
705
704
  #
706
705
  # Start a stage instance.
707
- # @macro async
708
- # @macro http
706
+ # @async
709
707
  #
710
708
  # @param [String] topic The topic of the stage instance.
711
709
  # @param [Boolean] public Whether the stage instance is public or not.
@@ -722,8 +720,7 @@ module Discorb
722
720
 
723
721
  #
724
722
  # Fetch a current stage instance.
725
- # @macro async
726
- # @macro http
723
+ # @async
727
724
  #
728
725
  # @return [Async::Task<StageInstance>] The current stage instance.
729
726
  # @return [Async::Task<nil>] If there is no current stage instance.
@@ -785,6 +782,19 @@ module Discorb
785
782
  # @!attribute [r] parent
786
783
  # @macro client_cache
787
784
  # @return [Discorb::GuildChannel] The parent channel of the thread.
785
+ # @!attribute [r] me
786
+ # @return [Discorb::ThreadChannel::Member] The bot's member in the thread.
787
+ # @return [nil] If the bot is not in the thread.
788
+ # @!attribute [r] joined?
789
+ # @return [Boolean] Whether the bot is in the thread or not.
790
+ # @!attribute [r] guild
791
+ # @macro client_cache
792
+ # @return [Discorb::Guild] The guild of the thread.
793
+ # @!attribute [r] owner
794
+ # @macro client_cache
795
+ # @macro members_intent
796
+ # @return [Discorb::Member] The owner of the thread.
797
+
788
798
 
789
799
  include Messageable
790
800
  @channel_type = nil
@@ -800,8 +810,7 @@ module Discorb
800
810
 
801
811
  #
802
812
  # Edit the thread.
803
- # @macro async
804
- # @macro http
813
+ # @async
805
814
  # @macro edit
806
815
  #
807
816
  # @param [String] name The name of the thread.
@@ -818,14 +827,14 @@ module Discorb
818
827
  # @see #unarchive
819
828
  # @see #unlock
820
829
  #
821
- def edit(name: :unset, archived: :unset, auto_archive_duration: :unset, archive_in: :unset, locked: :unset, reason: nil)
830
+ def edit(name: Discorb::Unset, archived: Discorb::Unset, auto_archive_duration: Discorb::Unset, archive_in: Discorb::Unset, locked: Discorb::Unset, reason: nil)
822
831
  Async do
823
832
  payload = {}
824
- payload[:name] = name if name != :unset
825
- payload[:archived] = archived if archived != :unset
833
+ payload[:name] = name if name != Discorb::Unset
834
+ payload[:archived] = archived if archived != Discorb::Unset
826
835
  auto_archive_duration ||= archive_in
827
- payload[:auto_archive_duration] = auto_archive_duration if auto_archive_duration != :unset
828
- payload[:locked] = locked if locked != :unset
836
+ payload[:auto_archive_duration] = auto_archive_duration if auto_archive_duration != Discorb::Unset
837
+ payload[:locked] = locked if locked != Discorb::Unset
829
838
  @client.http.patch("/channels/#{@id}", payload, audit_log_reason: reason).wait
830
839
  self
831
840
  end
@@ -890,7 +899,7 @@ module Discorb
890
899
  end
891
900
 
892
901
  def joined?
893
- @members[@client.user.id]
902
+ !!me
894
903
  end
895
904
 
896
905
  def guild
@@ -905,6 +914,13 @@ module Discorb
905
914
  "#<#{self.class} \"##{@name}\" id=#{@id}>"
906
915
  end
907
916
 
917
+ #
918
+ # Add a member to the thread.
919
+ #
920
+ # @param [Discorb::Member, :me] member The member to add. If `:me` is given, the bot will be added.
921
+ #
922
+ # @return [Async::Task<void>] The task.
923
+ #
908
924
  def add_member(member = :me)
909
925
  Async do
910
926
  if member == :me
@@ -917,6 +933,13 @@ module Discorb
917
933
 
918
934
  alias join add_member
919
935
 
936
+ #
937
+ # Remove a member from the thread.
938
+ #
939
+ # @param [Discorb::Member, :me] member The member to remove. If `:me` is given, the bot will be removed.
940
+ #
941
+ # @return [Async::Task<void>] The task.
942
+ #
920
943
  def remove_member(member = :me)
921
944
  Async do
922
945
  if member == :me
@@ -929,6 +952,11 @@ module Discorb
929
952
 
930
953
  alias leave remove_member
931
954
 
955
+ #
956
+ # Fetch members in the thread.
957
+ #
958
+ # @return [Array<Discorb::ThreadChannel::Member>] The members in the thread.
959
+ #
932
960
  def fetch_members
933
961
  Async do
934
962
  _resp, data = @client.http.get("/channels/#{@id}/thread-members").wait
@@ -952,6 +980,9 @@ module Discorb
952
980
  attr_reader :channel_type
953
981
  end
954
982
 
983
+ #
984
+ # Repre
985
+ #
955
986
  class Member < DiscordModel
956
987
  attr_reader :joined_at
957
988