discorb 0.13.0 → 0.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build_main.yml +1 -0
- data/.github/workflows/build_version.yml +1 -0
- data/.github/workflows/crowdin.yml +32 -0
- data/.gitignore +3 -1
- data/.yardopts +2 -0
- data/Changelog.md +399 -388
- data/Gemfile +5 -1
- data/README.md +1 -1
- data/Rakefile +139 -9
- data/crowdin.yml +2 -0
- data/docs/Examples.md +2 -0
- data/docs/application_command.md +7 -5
- data/docs/cli/irb.md +2 -0
- data/docs/cli/new.md +2 -0
- data/docs/cli/run.md +3 -1
- data/docs/cli/setup.md +4 -2
- data/docs/cli.md +2 -0
- data/docs/events.md +6 -4
- data/docs/extension.md +2 -2
- data/docs/faq.md +4 -2
- data/docs/license.md +2 -0
- data/docs/tutorial.md +4 -3
- data/docs/voice_events.md +2 -0
- data/lib/discorb/app_command.rb +8 -7
- data/lib/discorb/application.rb +1 -1
- data/lib/discorb/channel.rb +100 -76
- data/lib/discorb/client.rb +13 -15
- data/lib/discorb/common.rb +3 -1
- data/lib/discorb/emoji.rb +5 -7
- data/lib/discorb/emoji_table.rb +3891 -3891
- data/lib/discorb/event.rb +8 -7
- data/lib/discorb/exe/show.rb +2 -0
- data/lib/discorb/extension.rb +1 -1
- data/lib/discorb/flag.rb +1 -1
- data/lib/discorb/gateway.rb +9 -13
- data/lib/discorb/guild.rb +63 -89
- data/lib/discorb/guild_template.rb +12 -9
- data/lib/discorb/http.rb +82 -44
- data/lib/discorb/integration.rb +3 -0
- data/lib/discorb/interaction/response.rb +27 -25
- data/lib/discorb/interaction/root.rb +8 -0
- data/lib/discorb/invite.rb +3 -2
- data/lib/discorb/member.rb +41 -12
- data/lib/discorb/message.rb +28 -17
- data/lib/discorb/modules.rb +19 -26
- data/lib/discorb/role.rb +15 -11
- data/lib/discorb/sticker.rb +8 -12
- data/lib/discorb/user.rb +7 -7
- data/lib/discorb/voice_state.rb +8 -5
- data/lib/discorb/webhook.rb +38 -47
- data/lib/discorb.rb +1 -1
- data/po/yard.pot +7772 -5154
- data/sig/discorb.rbs +3316 -3819
- data/template-replace/scripts/locale_ja.rb +62 -0
- metadata +5 -3
data/lib/discorb/channel.rb
CHANGED
@@ -166,8 +166,7 @@ module Discorb
|
|
166
166
|
|
167
167
|
#
|
168
168
|
# Deletes the channel.
|
169
|
-
# @
|
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
|
-
# @
|
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:
|
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 !=
|
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
|
-
# @
|
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:
|
279
|
-
topic:
|
280
|
-
rate_limit_per_user:
|
281
|
-
archive_in:
|
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 !=
|
285
|
-
payload[:announce] = announce ? 5 : 0 if announce !=
|
286
|
-
payload[:position] = position if position !=
|
287
|
-
payload[:topic] = topic || "" if topic !=
|
288
|
-
payload[:nsfw] = nsfw if nsfw !=
|
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 ==
|
291
|
-
payload[:rate_limit_per_user] = slowmode || 0 if slowmode !=
|
292
|
-
parent = category if parent ==
|
293
|
-
payload[:parent_id] = parent&.id if parent !=
|
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 !=
|
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
|
-
# @
|
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
|
-
# @
|
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
|
-
# @
|
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
|
-
# @
|
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
|
-
# @
|
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
|
-
# @
|
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
|
-
# @
|
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
|
-
# @
|
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
|
-
# @
|
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,8 +482,7 @@ module Discorb
|
|
484
482
|
|
485
483
|
#
|
486
484
|
# Start thread in the channel.
|
487
|
-
# @
|
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.
|
@@ -522,8 +519,7 @@ module Discorb
|
|
522
519
|
|
523
520
|
#
|
524
521
|
# Fetch archived threads in the channel.
|
525
|
-
# @
|
526
|
-
# @macro http
|
522
|
+
# @async
|
527
523
|
#
|
528
524
|
# @return [Async::Task<Array<Discorb::ThreadChannel>>] The archived threads in the channel.
|
529
525
|
#
|
@@ -536,8 +532,7 @@ module Discorb
|
|
536
532
|
|
537
533
|
#
|
538
534
|
# Fetch archived private threads in the channel.
|
539
|
-
# @
|
540
|
-
# @macro http
|
535
|
+
# @async
|
541
536
|
#
|
542
537
|
# @return [Async::Task<Array<Discorb::ThreadChannel>>] The archived private threads in the channel.
|
543
538
|
#
|
@@ -550,8 +545,7 @@ module Discorb
|
|
550
545
|
|
551
546
|
#
|
552
547
|
# Fetch joined archived private threads in the channel.
|
553
|
-
# @
|
554
|
-
# @macro http
|
548
|
+
# @async
|
555
549
|
#
|
556
550
|
# @param [Integer] limit The limit of threads to fetch.
|
557
551
|
# @param [Time] before <description>
|
@@ -614,8 +608,7 @@ module Discorb
|
|
614
608
|
@channel_type = 2
|
615
609
|
#
|
616
610
|
# Edit the voice channel.
|
617
|
-
# @
|
618
|
-
# @macro http
|
611
|
+
# @async
|
619
612
|
# @macro edit
|
620
613
|
#
|
621
614
|
# @param [String] name The name of the voice channel.
|
@@ -627,14 +620,14 @@ module Discorb
|
|
627
620
|
#
|
628
621
|
# @return [Async::Task<self>] The edited voice channel.
|
629
622
|
#
|
630
|
-
def edit(name:
|
623
|
+
def edit(name: Discorb::Unset, position: Discorb::Unset, bitrate: Discorb::Unset, user_limit: Discorb::Unset, rtc_region: Discorb::Unset, reason: nil)
|
631
624
|
Async do
|
632
625
|
payload = {}
|
633
|
-
payload[:name] = name if name !=
|
634
|
-
payload[:position] = position if position !=
|
635
|
-
payload[:bitrate] = bitrate if bitrate !=
|
636
|
-
payload[:user_limit] = user_limit if user_limit !=
|
637
|
-
payload[:rtc_region] = rtc_region if rtc_region !=
|
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
|
638
631
|
|
639
632
|
@client.http.patch("/channels/#{@id}", payload, audit_log_reason: reason).wait
|
640
633
|
self
|
@@ -683,8 +676,7 @@ module Discorb
|
|
683
676
|
|
684
677
|
#
|
685
678
|
# Edit the stage channel.
|
686
|
-
# @
|
687
|
-
# @macro http
|
679
|
+
# @async
|
688
680
|
# @macro edit
|
689
681
|
#
|
690
682
|
# @param [String] name The name of the stage channel.
|
@@ -695,13 +687,13 @@ module Discorb
|
|
695
687
|
#
|
696
688
|
# @return [Async::Task<self>] The edited stage channel.
|
697
689
|
#
|
698
|
-
def edit(name:
|
690
|
+
def edit(name: Discorb::Unset, position: Discorb::Unset, bitrate: Discorb::Unset, rtc_region: Discorb::Unset, reason: nil)
|
699
691
|
Async do
|
700
692
|
payload = {}
|
701
|
-
payload[:name] = name if name !=
|
702
|
-
payload[:position] = position if position !=
|
703
|
-
payload[:bitrate] = bitrate if bitrate !=
|
704
|
-
payload[:rtc_region] = rtc_region if rtc_region !=
|
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
|
705
697
|
@client.http.patch("/channels/#{@id}", payload, audit_log_reason: reason).wait
|
706
698
|
self
|
707
699
|
end
|
@@ -711,8 +703,7 @@ module Discorb
|
|
711
703
|
|
712
704
|
#
|
713
705
|
# Start a stage instance.
|
714
|
-
# @
|
715
|
-
# @macro http
|
706
|
+
# @async
|
716
707
|
#
|
717
708
|
# @param [String] topic The topic of the stage instance.
|
718
709
|
# @param [Boolean] public Whether the stage instance is public or not.
|
@@ -729,8 +720,7 @@ module Discorb
|
|
729
720
|
|
730
721
|
#
|
731
722
|
# Fetch a current stage instance.
|
732
|
-
# @
|
733
|
-
# @macro http
|
723
|
+
# @async
|
734
724
|
#
|
735
725
|
# @return [Async::Task<StageInstance>] The current stage instance.
|
736
726
|
# @return [Async::Task<nil>] If there is no current stage instance.
|
@@ -792,6 +782,19 @@ module Discorb
|
|
792
782
|
# @!attribute [r] parent
|
793
783
|
# @macro client_cache
|
794
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
|
+
|
795
798
|
|
796
799
|
include Messageable
|
797
800
|
@channel_type = nil
|
@@ -807,8 +810,7 @@ module Discorb
|
|
807
810
|
|
808
811
|
#
|
809
812
|
# Edit the thread.
|
810
|
-
# @
|
811
|
-
# @macro http
|
813
|
+
# @async
|
812
814
|
# @macro edit
|
813
815
|
#
|
814
816
|
# @param [String] name The name of the thread.
|
@@ -825,14 +827,14 @@ module Discorb
|
|
825
827
|
# @see #unarchive
|
826
828
|
# @see #unlock
|
827
829
|
#
|
828
|
-
def edit(name:
|
830
|
+
def edit(name: Discorb::Unset, archived: Discorb::Unset, auto_archive_duration: Discorb::Unset, archive_in: Discorb::Unset, locked: Discorb::Unset, reason: nil)
|
829
831
|
Async do
|
830
832
|
payload = {}
|
831
|
-
payload[:name] = name if name !=
|
832
|
-
payload[:archived] = archived if archived !=
|
833
|
+
payload[:name] = name if name != Discorb::Unset
|
834
|
+
payload[:archived] = archived if archived != Discorb::Unset
|
833
835
|
auto_archive_duration ||= archive_in
|
834
|
-
payload[:auto_archive_duration] = auto_archive_duration if auto_archive_duration !=
|
835
|
-
payload[:locked] = locked if locked !=
|
836
|
+
payload[:auto_archive_duration] = auto_archive_duration if auto_archive_duration != Discorb::Unset
|
837
|
+
payload[:locked] = locked if locked != Discorb::Unset
|
836
838
|
@client.http.patch("/channels/#{@id}", payload, audit_log_reason: reason).wait
|
837
839
|
self
|
838
840
|
end
|
@@ -897,7 +899,7 @@ module Discorb
|
|
897
899
|
end
|
898
900
|
|
899
901
|
def joined?
|
900
|
-
|
902
|
+
!!me
|
901
903
|
end
|
902
904
|
|
903
905
|
def guild
|
@@ -912,6 +914,13 @@ module Discorb
|
|
912
914
|
"#<#{self.class} \"##{@name}\" id=#{@id}>"
|
913
915
|
end
|
914
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
|
+
#
|
915
924
|
def add_member(member = :me)
|
916
925
|
Async do
|
917
926
|
if member == :me
|
@@ -924,6 +933,13 @@ module Discorb
|
|
924
933
|
|
925
934
|
alias join add_member
|
926
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
|
+
#
|
927
943
|
def remove_member(member = :me)
|
928
944
|
Async do
|
929
945
|
if member == :me
|
@@ -936,6 +952,11 @@ module Discorb
|
|
936
952
|
|
937
953
|
alias leave remove_member
|
938
954
|
|
955
|
+
#
|
956
|
+
# Fetch members in the thread.
|
957
|
+
#
|
958
|
+
# @return [Array<Discorb::ThreadChannel::Member>] The members in the thread.
|
959
|
+
#
|
939
960
|
def fetch_members
|
940
961
|
Async do
|
941
962
|
_resp, data = @client.http.get("/channels/#{@id}/thread-members").wait
|
@@ -959,6 +980,9 @@ module Discorb
|
|
959
980
|
attr_reader :channel_type
|
960
981
|
end
|
961
982
|
|
983
|
+
#
|
984
|
+
# Repre
|
985
|
+
#
|
962
986
|
class Member < DiscordModel
|
963
987
|
attr_reader :joined_at
|
964
988
|
|
data/lib/discorb/client.rb
CHANGED
@@ -105,7 +105,7 @@ module Discorb
|
|
105
105
|
|
106
106
|
#
|
107
107
|
# Registers an event handler.
|
108
|
-
# @see file:docs/Events.md
|
108
|
+
# @see file:docs/Events.md Events Documentation
|
109
109
|
#
|
110
110
|
# @param [Symbol] event_name The name of the event.
|
111
111
|
# @param [Symbol] id Custom ID of the event.
|
@@ -146,10 +146,13 @@ module Discorb
|
|
146
146
|
|
147
147
|
#
|
148
148
|
# Dispatch an event.
|
149
|
+
# @async
|
149
150
|
#
|
150
151
|
# @param [Symbol] event_name The name of the event.
|
151
152
|
# @param [Object] args The arguments to pass to the event.
|
152
153
|
#
|
154
|
+
# @return [Async::Task<void>] The task.
|
155
|
+
#
|
153
156
|
def dispatch(event_name, *args)
|
154
157
|
Async do
|
155
158
|
if (conditions = @conditions[event_name])
|
@@ -199,8 +202,7 @@ module Discorb
|
|
199
202
|
|
200
203
|
#
|
201
204
|
# Fetch user from ID.
|
202
|
-
# @
|
203
|
-
# @macro http
|
205
|
+
# @async
|
204
206
|
#
|
205
207
|
# @param [#to_s] id <description>
|
206
208
|
#
|
@@ -217,8 +219,7 @@ module Discorb
|
|
217
219
|
|
218
220
|
#
|
219
221
|
# Fetch channel from ID.
|
220
|
-
# @
|
221
|
-
# @macro http
|
222
|
+
# @async
|
222
223
|
#
|
223
224
|
# @param [#to_s] id The ID of the channel.
|
224
225
|
#
|
@@ -235,8 +236,7 @@ module Discorb
|
|
235
236
|
|
236
237
|
#
|
237
238
|
# Fetch guild from ID.
|
238
|
-
# @
|
239
|
-
# @macro http
|
239
|
+
# @async
|
240
240
|
#
|
241
241
|
# @param [#to_s] id <description>
|
242
242
|
#
|
@@ -253,8 +253,7 @@ module Discorb
|
|
253
253
|
|
254
254
|
#
|
255
255
|
# Fetch invite from code.
|
256
|
-
# @
|
257
|
-
# @macro http
|
256
|
+
# @async
|
258
257
|
#
|
259
258
|
# @param [String] code The code of the invite.
|
260
259
|
# @param [Boolean] with_count Whether to include the count of the invite.
|
@@ -272,8 +271,7 @@ module Discorb
|
|
272
271
|
#
|
273
272
|
# Fetch webhook from ID.
|
274
273
|
# If application was cached, it will be used.
|
275
|
-
# @
|
276
|
-
# @macro http
|
274
|
+
# @async
|
277
275
|
#
|
278
276
|
# @param [Boolean] force Whether to force the fetch.
|
279
277
|
#
|
@@ -291,8 +289,7 @@ module Discorb
|
|
291
289
|
|
292
290
|
#
|
293
291
|
# Fetch nitro sticker pack from ID.
|
294
|
-
# @
|
295
|
-
# @macro http
|
292
|
+
# @async
|
296
293
|
#
|
297
294
|
# @return [Async::Task<Array<Discorb::Sticker::Pack>>] The packs.
|
298
295
|
#
|
@@ -334,12 +331,13 @@ module Discorb
|
|
334
331
|
|
335
332
|
#
|
336
333
|
# Method to wait for a event.
|
334
|
+
# @async
|
337
335
|
#
|
338
336
|
# @param [Symbol] event The name of the event.
|
339
337
|
# @param [Integer] timeout The timeout in seconds.
|
340
338
|
# @param [Proc] check The check to use.
|
341
339
|
#
|
342
|
-
# @return [Object] The result of the event.
|
340
|
+
# @return [Async::Task<Object>] The result of the event.
|
343
341
|
#
|
344
342
|
# @raise [Discorb::TimeoutError] If the event didn't occur in time.
|
345
343
|
#
|
@@ -416,7 +414,7 @@ module Discorb
|
|
416
414
|
#
|
417
415
|
# Starts the client.
|
418
416
|
# @note This method behavior will change by CLI.
|
419
|
-
# @see file:docs/cli.md
|
417
|
+
# @see file:docs/cli.md CLI documentation
|
420
418
|
#
|
421
419
|
# @param [String, nil] token The token to use.
|
422
420
|
#
|
data/lib/discorb/common.rb
CHANGED
@@ -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.13.
|
7
|
+
VERSION = "0.13.1"
|
8
8
|
# @return [String] The user agent for the bot.
|
9
9
|
USER_AGENT = "DiscordBot (https://discorb-lib.github.io #{VERSION}) Ruby/#{RUBY_VERSION}"
|
10
10
|
|
@@ -117,6 +117,8 @@ module Discorb
|
|
117
117
|
alias id to_s
|
118
118
|
end
|
119
119
|
|
120
|
+
# @return [Object] Object that represents nil.
|
121
|
+
# This is used as a default value for optional parameters.
|
120
122
|
Unset = Object.new
|
121
123
|
class << Unset
|
122
124
|
def method_missing(*)
|
data/lib/discorb/emoji.rb
CHANGED
@@ -82,8 +82,7 @@ module Discorb
|
|
82
82
|
|
83
83
|
#
|
84
84
|
# Edit the emoji.
|
85
|
-
# @
|
86
|
-
# @macro http
|
85
|
+
# @async
|
87
86
|
# @macro edit
|
88
87
|
#
|
89
88
|
# @param [String] name The new name of the emoji.
|
@@ -92,11 +91,11 @@ module Discorb
|
|
92
91
|
#
|
93
92
|
# @return [Async::Task<self>] The edited emoji.
|
94
93
|
#
|
95
|
-
def edit(name:
|
94
|
+
def edit(name: Discorb::Unset, roles: Discorb::Unset, reason: nil)
|
96
95
|
Async do
|
97
96
|
payload = {}
|
98
|
-
payload[:name] = name if name !=
|
99
|
-
payload[:roles] = roles.map { |r| Discorb::Utils.try(r, :id) } if roles !=
|
97
|
+
payload[:name] = name if name != Discorb::Unset
|
98
|
+
payload[:roles] = roles.map { |r| Discorb::Utils.try(r, :id) } if roles != Discorb::Unset
|
100
99
|
@client.http.patch("/guilds/#{@guild.id}/emojis/#{@id}", payload, audit_log_reason: reason)
|
101
100
|
self
|
102
101
|
end
|
@@ -106,8 +105,7 @@ module Discorb
|
|
106
105
|
|
107
106
|
#
|
108
107
|
# Delete the emoji.
|
109
|
-
# @
|
110
|
-
# @macro http
|
108
|
+
# @async
|
111
109
|
#
|
112
110
|
# @param [String] reason The reason for deleting the emoji.
|
113
111
|
#
|