discorb 0.12.2 → 0.13.1
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 +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 -367
- data/Gemfile +5 -1
- data/README.md +1 -1
- data/Rakefile +139 -9
- data/crowdin.yml +2 -0
- data/discorb.gemspec +1 -1
- data/docs/Examples.md +2 -0
- data/docs/application_command.md +17 -12
- 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 +59 -5
- 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 +13 -7
- data/lib/discorb/application.rb +32 -2
- data/lib/discorb/audit_logs.rb +28 -16
- data/lib/discorb/channel.rb +112 -81
- data/lib/discorb/client.rb +17 -19
- data/lib/discorb/common.rb +28 -1
- data/lib/discorb/components.rb +12 -0
- data/lib/discorb/dictionary.rb +1 -1
- data/lib/discorb/embed.rb +4 -0
- data/lib/discorb/emoji.rb +9 -7
- data/lib/discorb/emoji_table.rb +3774 -3689
- data/lib/discorb/event.rb +266 -24
- data/lib/discorb/event_handler.rb +39 -0
- data/lib/discorb/exe/show.rb +2 -0
- data/lib/discorb/extension.rb +5 -5
- data/lib/discorb/file.rb +4 -0
- data/lib/discorb/flag.rb +5 -1
- data/lib/discorb/gateway.rb +65 -14
- data/lib/discorb/gateway_requests.rb +4 -0
- data/lib/discorb/guild.rb +169 -82
- data/lib/discorb/guild_template.rb +12 -9
- data/lib/discorb/http.rb +82 -37
- data/lib/discorb/image.rb +7 -5
- data/lib/discorb/integration.rb +4 -1
- data/lib/discorb/intents.rb +8 -3
- data/lib/discorb/interaction/autocomplete.rb +1 -1
- data/lib/discorb/interaction/command.rb +2 -2
- 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/log.rb +4 -0
- data/lib/discorb/member.rb +42 -13
- data/lib/discorb/message.rb +32 -17
- data/lib/discorb/modules.rb +19 -26
- data/lib/discorb/permission.rb +4 -0
- data/lib/discorb/rate_limit.rb +6 -2
- data/lib/discorb/role.rb +15 -11
- data/lib/discorb/sticker.rb +17 -12
- data/lib/discorb/user.rb +8 -7
- data/lib/discorb/voice_state.rb +8 -5
- data/lib/discorb/webhook.rb +38 -47
- data/lib/discorb.rb +2 -2
- data/po/yard.pot +7775 -5157
- data/sig/discorb.rbs +3317 -3820
- data/template-replace/scripts/locale_ja.rb +62 -0
- data/template-replace/scripts/yard_replace.rb +6 -0
- metadata +7 -4
data/lib/discorb/guild.rb
CHANGED
@@ -28,7 +28,7 @@ module Discorb
|
|
28
28
|
attr_reader :features
|
29
29
|
# @return [:none, :elevated] The MFA level of the guild.
|
30
30
|
attr_reader :mfa_level
|
31
|
-
# @return [Discorb::
|
31
|
+
# @return [Discorb::SystemChannelFlag] The flag for the system channel.
|
32
32
|
attr_reader :system_channel_flags
|
33
33
|
# @return [Time] Time that representing when bot has joined the guild.
|
34
34
|
attr_reader :joined_at
|
@@ -96,6 +96,9 @@ module Discorb
|
|
96
96
|
# @return [Boolean] Whether the guild is available.
|
97
97
|
attr_reader :available
|
98
98
|
alias available? available
|
99
|
+
# @return [Dictionary{Discorb::Snowflake => Discorb::ScheduledEvent}] A dictionary of scheduled events in the guild.
|
100
|
+
attr_reader :scheduled_events
|
101
|
+
alias events scheduled_events
|
99
102
|
|
100
103
|
# @!attribute [r] afk_channel
|
101
104
|
# @return [Discorb::VoiceChannel] The AFK channel for this guild.
|
@@ -159,8 +162,9 @@ module Discorb
|
|
159
162
|
|
160
163
|
#
|
161
164
|
# Leave the guild.
|
162
|
-
# @
|
163
|
-
#
|
165
|
+
# @async
|
166
|
+
#
|
167
|
+
# @return [Async::Task<void>] The task.
|
164
168
|
#
|
165
169
|
def leave!
|
166
170
|
Async do
|
@@ -169,10 +173,115 @@ module Discorb
|
|
169
173
|
end
|
170
174
|
end
|
171
175
|
|
176
|
+
#
|
177
|
+
# Fetch scheduled events for the guild.
|
178
|
+
# @async
|
179
|
+
#
|
180
|
+
# @param [Boolean] with_user_count Whether to include the user count in the events.
|
181
|
+
# Defaults to `true`.
|
182
|
+
#
|
183
|
+
# @return [Array<Discorb::ScheduledEvent>] The events for the guild.
|
184
|
+
#
|
185
|
+
def fetch_scheduled_events(with_user_count: true)
|
186
|
+
Async do
|
187
|
+
_resp, events = @client.http.get("/guilds/#{@id}/scheduled-events?with_user_count=#{with_user_count}").wait
|
188
|
+
@scheduled_events = events.map { |e| ScheduledEvent.new(@client, e) }
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
#
|
193
|
+
# Fetch the scheduled event by ID.
|
194
|
+
# @async
|
195
|
+
#
|
196
|
+
# @param [#to_s] id The ID of the scheduled event.
|
197
|
+
#
|
198
|
+
# @return [Async::Task<Discorb::ScheduledEvent>] The event with the given ID.
|
199
|
+
# @return [Async::Task<nil>] If no event with the given ID exists.
|
200
|
+
#
|
201
|
+
def fetch_scheduled_event(id)
|
202
|
+
Async do
|
203
|
+
_resp, event = @client.http.get("/guilds/#{@id}/scheduled-events/#{id}").wait
|
204
|
+
rescue Discorb::NotFoundError
|
205
|
+
return nil
|
206
|
+
else
|
207
|
+
ScheduledEvent.new(@client, event)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
#
|
212
|
+
# Create a scheduled event for the guild.
|
213
|
+
# @async
|
214
|
+
#
|
215
|
+
# @param [:stage_instance, :voice, :external] type The type of event to create.
|
216
|
+
# @param [String] name The name of the event.
|
217
|
+
# @param [String] description The description of the event.
|
218
|
+
# @param [Time] start_time The start time of the event.
|
219
|
+
# @param [Time, nil] end_time The end time of the event. Defaults to `nil`.
|
220
|
+
# @param [Discorb::Channel, Discorb::Snowflake, nil] channel The channel to run the event in.
|
221
|
+
# @param [String, nil] location The location of the event. Defaults to `nil`.
|
222
|
+
# @param [:guild_only] privacy_level The privacy level of the event. This must be `:guild_only`.
|
223
|
+
#
|
224
|
+
# @return [Async::Task<Discorb::ScheduledEvent>] The created event.
|
225
|
+
#
|
226
|
+
def create_scheduled_event(
|
227
|
+
type,
|
228
|
+
name,
|
229
|
+
description,
|
230
|
+
start_time,
|
231
|
+
end_time = nil,
|
232
|
+
privacy_level: :guild_only,
|
233
|
+
location: nil,
|
234
|
+
channel: nil
|
235
|
+
)
|
236
|
+
Async do
|
237
|
+
payload = case type
|
238
|
+
when :stage_instance
|
239
|
+
raise ArgumentError, "channel must be provided for stage_instance events" unless channel
|
240
|
+
{
|
241
|
+
name: name,
|
242
|
+
description: description,
|
243
|
+
scheduled_start_time: start_time.iso8601,
|
244
|
+
scheduled_end_time: end_time&.iso8601,
|
245
|
+
privacy_level: Discorb::ScheduledEvent.privacy_level.key(privacy_level),
|
246
|
+
channel_id: channel&.id,
|
247
|
+
entity_type: Discorb::ScheduledEvent.entity_type.key(:stage_instance),
|
248
|
+
}
|
249
|
+
when :voice
|
250
|
+
raise ArgumentError, "channel must be provided for voice events" unless channel
|
251
|
+
{
|
252
|
+
name: name,
|
253
|
+
description: description,
|
254
|
+
scheduled_start_time: start_time.iso8601,
|
255
|
+
scheduled_end_time: end_time&.iso8601,
|
256
|
+
privacy_level: Discorb::ScheduledEvent.privacy_level.key(privacy_level),
|
257
|
+
channel_id: channel&.id,
|
258
|
+
entity_type: Discorb::ScheduledEvent.entity_type.key(:voice),
|
259
|
+
}
|
260
|
+
when :external
|
261
|
+
raise ArgumentError, "location must be provided for external events" unless location
|
262
|
+
raise ArgumentError, "end_time must be provided for external events" unless end_time
|
263
|
+
{
|
264
|
+
name: name,
|
265
|
+
description: description,
|
266
|
+
scheduled_start_time: start_time.iso8601,
|
267
|
+
scheduled_end_time: end_time.iso8601,
|
268
|
+
privacy_level: Discorb::ScheduledEvent.privacy_level.key(privacy_level),
|
269
|
+
entity_type: Discorb::ScheduledEvent.entity_type.key(:external),
|
270
|
+
entity_metadata: {
|
271
|
+
location: location,
|
272
|
+
},
|
273
|
+
}
|
274
|
+
else
|
275
|
+
raise ArgumentError, "Invalid scheduled event type: #{type}"
|
276
|
+
end
|
277
|
+
_resp, event = @client.http.post("/guilds/#{@id}/scheduled-events", payload).wait
|
278
|
+
Discorb::ScheduledEvent.new(@client, event)
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
172
282
|
#
|
173
283
|
# Fetch emoji list of the guild.
|
174
|
-
# @
|
175
|
-
# @macro http
|
284
|
+
# @async
|
176
285
|
# @note This querys the API every time. We recommend using {#emojis} instead.
|
177
286
|
#
|
178
287
|
# @return [Async::Task<Discorb::Dictionary{Discorb::Snowflake => Discorb::CustomEmoji}>] A dictionary of emoji in the guild.
|
@@ -195,8 +304,7 @@ module Discorb
|
|
195
304
|
|
196
305
|
#
|
197
306
|
# Fetch emoji id of the guild.
|
198
|
-
# @
|
199
|
-
# @macro http
|
307
|
+
# @async
|
200
308
|
# @note This querys the API every time. We recommend using {#emojis} instead.
|
201
309
|
#
|
202
310
|
# @param [#to_s] id The emoji id.
|
@@ -210,8 +318,7 @@ module Discorb
|
|
210
318
|
|
211
319
|
#
|
212
320
|
# Create a custom emoji.
|
213
|
-
# @
|
214
|
-
# @macro http
|
321
|
+
# @async
|
215
322
|
#
|
216
323
|
# @param [#to_s] name The name of the emoji.
|
217
324
|
# @param [Discorb::Image] image The image of the emoji.
|
@@ -233,8 +340,7 @@ module Discorb
|
|
233
340
|
|
234
341
|
#
|
235
342
|
# Fetch webhooks of the guild.
|
236
|
-
# @
|
237
|
-
# @macro http
|
343
|
+
# @async
|
238
344
|
#
|
239
345
|
# @return [Async::Task<Array<Discorb::Webhook>>] A list of webhooks in the guild.
|
240
346
|
#
|
@@ -247,8 +353,7 @@ module Discorb
|
|
247
353
|
|
248
354
|
#
|
249
355
|
# Fetch audit log of the guild.
|
250
|
-
# @
|
251
|
-
# @macro http
|
356
|
+
# @async
|
252
357
|
#
|
253
358
|
# @return [Async::Task<Discorb::AuditLog>] The audit log of the guild.
|
254
359
|
#
|
@@ -261,8 +366,7 @@ module Discorb
|
|
261
366
|
|
262
367
|
#
|
263
368
|
# Fetch channels of the guild.
|
264
|
-
# @
|
265
|
-
# @macro http
|
369
|
+
# @async
|
266
370
|
#
|
267
371
|
# @return [Async::Task<Array<Discorb::Channel>>] A list of channels in the guild.
|
268
372
|
#
|
@@ -275,8 +379,7 @@ module Discorb
|
|
275
379
|
|
276
380
|
#
|
277
381
|
# Create a new text channel.
|
278
|
-
# @
|
279
|
-
# @macro http
|
382
|
+
# @async
|
280
383
|
#
|
281
384
|
# @param [String] name The name of the channel.
|
282
385
|
# @param [String] topic The topic of the channel.
|
@@ -322,8 +425,7 @@ module Discorb
|
|
322
425
|
|
323
426
|
#
|
324
427
|
# Create a new voice channel.
|
325
|
-
# @
|
326
|
-
# @macro http
|
428
|
+
# @async
|
327
429
|
#
|
328
430
|
# @param [String] name The name of the channel.
|
329
431
|
# @param [Integer] bitrate The bitrate of the channel.
|
@@ -364,8 +466,7 @@ module Discorb
|
|
364
466
|
end
|
365
467
|
|
366
468
|
# Create a new category channel.
|
367
|
-
# @
|
368
|
-
# @macro http
|
469
|
+
# @async
|
369
470
|
#
|
370
471
|
# @param [String] name The name of the channel.
|
371
472
|
# @param [Integer] position The position of the channel.
|
@@ -402,8 +503,7 @@ module Discorb
|
|
402
503
|
|
403
504
|
#
|
404
505
|
# Create a new stage channel.
|
405
|
-
# @
|
406
|
-
# @macro http
|
506
|
+
# @async
|
407
507
|
#
|
408
508
|
# @param [String] name The name of the channel.
|
409
509
|
# @param [Integer] bitrate The bitrate of the channel.
|
@@ -440,8 +540,7 @@ module Discorb
|
|
440
540
|
|
441
541
|
#
|
442
542
|
# Create a new news channel.
|
443
|
-
# @
|
444
|
-
# @macro http
|
543
|
+
# @async
|
445
544
|
#
|
446
545
|
# @param [String] name The name of the channel.
|
447
546
|
# @param [String] topic The topic of the channel.
|
@@ -486,8 +585,7 @@ module Discorb
|
|
486
585
|
|
487
586
|
#
|
488
587
|
# Fetch a list of active threads in the guild.
|
489
|
-
# @
|
490
|
-
# @macro http
|
588
|
+
# @async
|
491
589
|
#
|
492
590
|
# @return [Async::Task<Array<Discorb::ThreadChannel>>] The list of threads.
|
493
591
|
#
|
@@ -500,8 +598,7 @@ module Discorb
|
|
500
598
|
|
501
599
|
#
|
502
600
|
# Fetch a member in the guild.
|
503
|
-
# @
|
504
|
-
# @macro http
|
601
|
+
# @async
|
505
602
|
#
|
506
603
|
# @param [#to_s] id The ID of the member to fetch.
|
507
604
|
#
|
@@ -519,8 +616,7 @@ module Discorb
|
|
519
616
|
end
|
520
617
|
|
521
618
|
# Fetch members in the guild.
|
522
|
-
# @
|
523
|
-
# @macro http
|
619
|
+
# @async
|
524
620
|
# @macro members_intent
|
525
621
|
#
|
526
622
|
# @param [Integer] limit The maximum number of members to fetch, 0 for all.
|
@@ -553,8 +649,7 @@ module Discorb
|
|
553
649
|
|
554
650
|
#
|
555
651
|
# Search for members by name in the guild.
|
556
|
-
# @
|
557
|
-
# @macro http
|
652
|
+
# @async
|
558
653
|
#
|
559
654
|
# @param [String] name The name of the member to search for.
|
560
655
|
# @param [Integer] limit The maximum number of members to return.
|
@@ -570,8 +665,7 @@ module Discorb
|
|
570
665
|
|
571
666
|
#
|
572
667
|
# Almost the same as {#fetch_members_named}, but returns a single member.
|
573
|
-
# @
|
574
|
-
# @macro http
|
668
|
+
# @async
|
575
669
|
#
|
576
670
|
# @return [Async::Task<Discorb::Member>] The member.
|
577
671
|
# @return [Async::Task<nil>] If the member is not found.
|
@@ -584,10 +678,13 @@ module Discorb
|
|
584
678
|
|
585
679
|
#
|
586
680
|
# Change nickname of client member.
|
681
|
+
# @async
|
587
682
|
#
|
588
683
|
# @param [String] nickname The nickname to set.
|
589
684
|
# @param [String] reason The reason for changing the nickname.
|
590
685
|
#
|
686
|
+
# @return [Async::Task<void>] The task.
|
687
|
+
#
|
591
688
|
def edit_nickname(nickname, reason: nil)
|
592
689
|
Async do
|
593
690
|
@client.http.patch("/guilds/#{@id}/members/@me/nick", { nick: nickname }, audit_log_reason: reason).wait
|
@@ -600,12 +697,13 @@ module Discorb
|
|
600
697
|
|
601
698
|
#
|
602
699
|
# Kick a member from the guild.
|
603
|
-
# @
|
604
|
-
# @macro http
|
700
|
+
# @async
|
605
701
|
#
|
606
702
|
# @param [Discorb::Member] member The member to kick.
|
607
703
|
# @param [String] reason The reason for kicking the member.
|
608
704
|
#
|
705
|
+
# @return [Async::Task<void>] The task.
|
706
|
+
#
|
609
707
|
def kick_member(member, reason: nil)
|
610
708
|
Async do
|
611
709
|
@client.http.delete("/guilds/#{@id}/members/#{member.id}", audit_log_reason: reason).wait
|
@@ -614,8 +712,7 @@ module Discorb
|
|
614
712
|
|
615
713
|
#
|
616
714
|
# Fetch a list of bans in the guild.
|
617
|
-
# @
|
618
|
-
# @macro http
|
715
|
+
# @async
|
619
716
|
#
|
620
717
|
# @return [Async::Task<Array<Discorb::Guild::Ban>>] The list of bans.
|
621
718
|
#
|
@@ -628,8 +725,7 @@ module Discorb
|
|
628
725
|
|
629
726
|
#
|
630
727
|
# Fetch a ban in the guild.
|
631
|
-
# @
|
632
|
-
# @macro http
|
728
|
+
# @async
|
633
729
|
#
|
634
730
|
# @param [Discorb::User] user The user to fetch.
|
635
731
|
#
|
@@ -648,8 +744,7 @@ module Discorb
|
|
648
744
|
|
649
745
|
#
|
650
746
|
# Checks the user was banned from the guild.
|
651
|
-
# @
|
652
|
-
# @macro http
|
747
|
+
# @async
|
653
748
|
#
|
654
749
|
# @param [Discorb::User] user The user to check.
|
655
750
|
#
|
@@ -663,8 +758,7 @@ module Discorb
|
|
663
758
|
|
664
759
|
#
|
665
760
|
# Ban a member from the guild.
|
666
|
-
# @
|
667
|
-
# @macro http
|
761
|
+
# @async
|
668
762
|
#
|
669
763
|
# @param [Discorb::Member] member The member to ban.
|
670
764
|
# @param [Integer] delete_message_days The number of days to delete messages.
|
@@ -683,12 +777,13 @@ module Discorb
|
|
683
777
|
|
684
778
|
#
|
685
779
|
# Unban a user from the guild.
|
686
|
-
# @
|
687
|
-
# @macro http
|
780
|
+
# @async
|
688
781
|
#
|
689
782
|
# @param [Discorb::User] user The user to unban.
|
690
783
|
# @param [String] reason The reason for unbanning the user.
|
691
784
|
#
|
785
|
+
# @return [Async::Task<void>] The task.
|
786
|
+
#
|
692
787
|
def unban_user(user, reason: nil)
|
693
788
|
Async do
|
694
789
|
@client.http.delete("/guilds/#{@id}/bans/#{user.id}", audit_log_reason: reason).wait
|
@@ -697,8 +792,7 @@ module Discorb
|
|
697
792
|
|
698
793
|
#
|
699
794
|
# Fetch a list of roles in the guild.
|
700
|
-
# @
|
701
|
-
# @macro http
|
795
|
+
# @async
|
702
796
|
#
|
703
797
|
# @return [Async::Task<Array<Discorb::Role>>] The list of roles.
|
704
798
|
#
|
@@ -711,8 +805,7 @@ module Discorb
|
|
711
805
|
|
712
806
|
#
|
713
807
|
# Create a role in the guild.
|
714
|
-
# @
|
715
|
-
# @macro http
|
808
|
+
# @async
|
716
809
|
#
|
717
810
|
# @param [String] name The name of the role.
|
718
811
|
# @param [Discorb::Color] color The color of the role.
|
@@ -738,8 +831,7 @@ module Discorb
|
|
738
831
|
|
739
832
|
#
|
740
833
|
# Fetch how many members will be pruned.
|
741
|
-
# @
|
742
|
-
# @macro http
|
834
|
+
# @async
|
743
835
|
#
|
744
836
|
# @param [Integer] days The number of days to prune.
|
745
837
|
# @param [Array<Discorb::Role>] roles The roles that include for pruning.
|
@@ -760,8 +852,7 @@ module Discorb
|
|
760
852
|
|
761
853
|
#
|
762
854
|
# Prune members from the guild.
|
763
|
-
# @
|
764
|
-
# @macro http
|
855
|
+
# @async
|
765
856
|
#
|
766
857
|
# @param [Integer] days The number of days to prune.
|
767
858
|
# @param [Array<Discorb::Role>] roles The roles that include for pruning.
|
@@ -780,8 +871,7 @@ module Discorb
|
|
780
871
|
|
781
872
|
#
|
782
873
|
# Fetch voice regions that are available in the guild.
|
783
|
-
# @
|
784
|
-
# @macro http
|
874
|
+
# @async
|
785
875
|
#
|
786
876
|
# @return [Async::Task<Array<Discorb::VoiceRegion>>] The available voice regions.
|
787
877
|
#
|
@@ -794,8 +884,7 @@ module Discorb
|
|
794
884
|
|
795
885
|
#
|
796
886
|
# Fetch invites in the guild.
|
797
|
-
# @
|
798
|
-
# @macro http
|
887
|
+
# @async
|
799
888
|
#
|
800
889
|
# @return [Async::Task<Array<Invite>>] The invites.
|
801
890
|
#
|
@@ -808,8 +897,7 @@ module Discorb
|
|
808
897
|
|
809
898
|
#
|
810
899
|
# Fetch integrations in the guild.
|
811
|
-
# @
|
812
|
-
# @macro http
|
900
|
+
# @async
|
813
901
|
#
|
814
902
|
# @return [Async::Task<Array<Discorb::Integration>>] The integrations.
|
815
903
|
#
|
@@ -822,8 +910,7 @@ module Discorb
|
|
822
910
|
|
823
911
|
#
|
824
912
|
# Fetch the widget of the guild.
|
825
|
-
# @
|
826
|
-
# @macro http
|
913
|
+
# @async
|
827
914
|
#
|
828
915
|
# @return [Async::Task<Discorb::Guild::Widget>] The widget.
|
829
916
|
#
|
@@ -836,8 +923,7 @@ module Discorb
|
|
836
923
|
|
837
924
|
#
|
838
925
|
# Fetch the vanity URL of the guild.
|
839
|
-
# @
|
840
|
-
# @macro http
|
926
|
+
# @async
|
841
927
|
#
|
842
928
|
# @return [Async::Task<Discorb::Guild::VanityInvite>] The vanity URL.
|
843
929
|
#
|
@@ -850,10 +936,9 @@ module Discorb
|
|
850
936
|
|
851
937
|
#
|
852
938
|
# Fetch the welcome screen of the guild.
|
853
|
-
# @
|
854
|
-
# @macro http
|
939
|
+
# @async
|
855
940
|
#
|
856
|
-
# @return [Async::Task<Discorb::
|
941
|
+
# @return [Async::Task<Discorb::WelcomeScreen>] The welcome screen.
|
857
942
|
#
|
858
943
|
def fetch_welcome_screen
|
859
944
|
Async do
|
@@ -864,8 +949,7 @@ module Discorb
|
|
864
949
|
|
865
950
|
#
|
866
951
|
# Fetch stickers in the guild.
|
867
|
-
# @
|
868
|
-
# @macro http
|
952
|
+
# @async
|
869
953
|
#
|
870
954
|
# @return [Async::Task<Array<Discorb::Sticker::GuildSticker>>] The stickers.
|
871
955
|
#
|
@@ -878,8 +962,7 @@ module Discorb
|
|
878
962
|
|
879
963
|
#
|
880
964
|
# Fetch the sticker by ID.
|
881
|
-
# @
|
882
|
-
# @macro http
|
965
|
+
# @async
|
883
966
|
#
|
884
967
|
# @param [#to_s] id The ID of the sticker.
|
885
968
|
#
|
@@ -898,8 +981,7 @@ module Discorb
|
|
898
981
|
|
899
982
|
#
|
900
983
|
# Fetch templates in the guild.
|
901
|
-
# @
|
902
|
-
# @macro http
|
984
|
+
# @async
|
903
985
|
#
|
904
986
|
# @return [Async::Task<Discorb::GuildTemplate>] The templates.
|
905
987
|
#
|
@@ -1001,14 +1083,15 @@ module Discorb
|
|
1001
1083
|
|
1002
1084
|
#
|
1003
1085
|
# Edit the widget.
|
1004
|
-
# @
|
1005
|
-
# @macro http
|
1086
|
+
# @async
|
1006
1087
|
# @macro edit
|
1007
1088
|
#
|
1008
1089
|
# @param [Boolean] enabled Whether the widget is enabled.
|
1009
1090
|
# @param [Discorb::GuildChannel] channel The channel.
|
1010
1091
|
# @param [String] reason The reason for editing the widget.
|
1011
1092
|
#
|
1093
|
+
# @return [Async::Task<void>] The task.
|
1094
|
+
#
|
1012
1095
|
def edit(enabled: nil, channel: nil, reason: nil)
|
1013
1096
|
Async do
|
1014
1097
|
payload = {}
|
@@ -1143,6 +1226,7 @@ module Discorb
|
|
1143
1226
|
@presences = Dictionary.new(data[:presences].map { |pr| [Snowflake.new(pr[:user][:id]), Presence.new(@client, pr)] }.to_h)
|
1144
1227
|
@max_presences = data[:max_presences]
|
1145
1228
|
@stage_instances = Dictionary.new(data[:stage_instances].map { |s| [Snowflake.new(s[:id]), StageInstance.new(@client, s)] }.to_h)
|
1229
|
+
@scheduled_events = Dictionary.new(data[:guild_scheduled_events].map { |s| [Snowflake.new(s[:id]), ScheduledEvent.new(@client, s)] }.to_h)
|
1146
1230
|
@data.update(data)
|
1147
1231
|
end
|
1148
1232
|
end
|
@@ -1155,12 +1239,14 @@ module Discorb
|
|
1155
1239
|
# |`1 << 0`|`:member_join`|
|
1156
1240
|
# |`1 << 1`|`:server_boost`|
|
1157
1241
|
# |`1 << 2`|`:setup_tips`|
|
1242
|
+
# |`1 << 3`|`:join_stickers`|
|
1158
1243
|
#
|
1159
1244
|
class SystemChannelFlag < Flag
|
1160
1245
|
@bits = {
|
1161
1246
|
member_join: 0,
|
1162
1247
|
server_boost: 1,
|
1163
1248
|
setup_tips: 2,
|
1249
|
+
join_stickers: 3,
|
1164
1250
|
}.freeze
|
1165
1251
|
end
|
1166
1252
|
|
@@ -1253,8 +1339,7 @@ module Discorb
|
|
1253
1339
|
|
1254
1340
|
#
|
1255
1341
|
# Edits the welcome screen.
|
1256
|
-
# @
|
1257
|
-
# @macro http
|
1342
|
+
# @async
|
1258
1343
|
# @macro edit
|
1259
1344
|
#
|
1260
1345
|
# @param [Boolean] enabled Whether the welcome screen is enabled.
|
@@ -1262,12 +1347,14 @@ module Discorb
|
|
1262
1347
|
# @param [String] description The description of the welcome screen.
|
1263
1348
|
# @param [String] reason The reason for editing the welcome screen.
|
1264
1349
|
#
|
1265
|
-
|
1350
|
+
# @return [Async::Task<void>] The task.
|
1351
|
+
#
|
1352
|
+
def edit(enabled: Discorb::Unset, channels: Discorb::Unset, description: Discorb::Unset, reason: nil)
|
1266
1353
|
Async do
|
1267
1354
|
payload = {}
|
1268
|
-
payload[:enabled] = enabled unless enabled ==
|
1269
|
-
payload[:welcome_channels] = channels.map(&:to_hash) unless channels ==
|
1270
|
-
payload[:description] = description unless description ==
|
1355
|
+
payload[:enabled] = enabled unless enabled == Discorb::Unset
|
1356
|
+
payload[:welcome_channels] = channels.map(&:to_hash) unless channels == Discorb::Unset
|
1357
|
+
payload[:description] = description unless description == Discorb::Unset
|
1271
1358
|
@client.http.patch("/guilds/#{@guild.id}/welcome-screen", payload, audit_log_reason: reason).wait
|
1272
1359
|
end
|
1273
1360
|
end
|
@@ -45,18 +45,19 @@ module Discorb
|
|
45
45
|
|
46
46
|
#
|
47
47
|
# Edit the template.
|
48
|
-
# @
|
49
|
-
# @macro http
|
48
|
+
# @async
|
50
49
|
# @macro edit
|
51
50
|
#
|
52
51
|
# @param [String] name The new name of the template.
|
53
52
|
# @param [String] description The new description of the template.
|
54
53
|
#
|
55
|
-
|
54
|
+
# @return [Async::Task<void>] The task.
|
55
|
+
#
|
56
|
+
def edit(name = nil, description = Discorb::Unset)
|
56
57
|
Async do
|
57
58
|
payload = {}
|
58
59
|
payload[:name] = name if name
|
59
|
-
payload[:description] = description if description !=
|
60
|
+
payload[:description] = description if description != Discorb::Unset
|
60
61
|
@client.http.patch("/guilds/#{@source_guild_id}/templates/#{@code}", payload).wait
|
61
62
|
end
|
62
63
|
end
|
@@ -65,8 +66,9 @@ module Discorb
|
|
65
66
|
|
66
67
|
#
|
67
68
|
# Update the template.
|
68
|
-
# @
|
69
|
-
#
|
69
|
+
# @async
|
70
|
+
#
|
71
|
+
# @return [Async::Task<void>] The task.
|
70
72
|
#
|
71
73
|
def update
|
72
74
|
Async do
|
@@ -77,8 +79,9 @@ module Discorb
|
|
77
79
|
|
78
80
|
#
|
79
81
|
# Delete the template.
|
80
|
-
# @
|
81
|
-
#
|
82
|
+
# @async
|
83
|
+
#
|
84
|
+
# @return [Async::Task<void>] The task.
|
82
85
|
#
|
83
86
|
def delete!
|
84
87
|
Async do
|
@@ -98,7 +101,7 @@ module Discorb
|
|
98
101
|
attr_reader :afk_timeout
|
99
102
|
# @return [Discorb::Dictionary{Discorb::Snowflake => Discorb::Role}] A dictionary of roles in the guild.
|
100
103
|
attr_reader :roles
|
101
|
-
# @return [Discorb::
|
104
|
+
# @return [Discorb::SystemChannelFlag] The flag for the system channel.
|
102
105
|
attr_reader :system_channel_flags
|
103
106
|
# @return [Discorb::Dictionary{Discorb::Snowflake => Discorb::GuildChannel}] A dictionary of channels in the guild.
|
104
107
|
attr_reader :channels
|