discorb 0.0.4 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +14 -2
- data/Gemfile.lock +1 -1
- data/README.md +4 -3
- data/discorb.gemspec +3 -3
- data/docs/events.md +50 -54
- data/docs/voice_events.md +32 -32
- data/examples/components/authorization_button.rb +2 -2
- data/examples/components/select_menu.rb +2 -2
- data/examples/extension/message_expander.rb +1 -1
- data/examples/simple/eval.rb +2 -2
- data/examples/simple/ping_pong.rb +1 -1
- data/examples/simple/rolepanel.rb +3 -3
- data/examples/simple/wait_for_message.rb +1 -1
- data/lib/discorb/channel.rb +36 -32
- data/lib/discorb/client.rb +11 -11
- data/lib/discorb/common.rb +1 -1
- data/lib/discorb/emoji.rb +2 -2
- data/lib/discorb/gateway.rb +10 -8
- data/lib/discorb/guild.rb +38 -38
- data/lib/discorb/guild_template.rb +3 -3
- data/lib/discorb/{internet.rb → http.rb} +2 -2
- data/lib/discorb/integration.rb +1 -1
- data/lib/discorb/interaction.rb +6 -6
- data/lib/discorb/invite.rb +1 -1
- data/lib/discorb/member.rb +3 -3
- data/lib/discorb/message.rb +11 -11
- data/lib/discorb/modules.rb +7 -7
- data/lib/discorb/role.rb +3 -3
- data/lib/discorb/sticker.rb +2 -2
- data/lib/discorb/user.rb +2 -2
- data/lib/discorb/voice_state.rb +2 -2
- data/lib/discorb/webhook.rb +11 -13
- data/lib/discorb.rb +1 -1
- metadata +6 -6
data/lib/discorb/client.rb
CHANGED
@@ -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::
|
20
|
-
attr_reader :
|
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.
|
@@ -124,7 +124,7 @@ module Discorb
|
|
124
124
|
# @param [Object] args The arguments to pass to the event.
|
125
125
|
#
|
126
126
|
def dispatch(event_name, *args)
|
127
|
-
Async do
|
127
|
+
Async do
|
128
128
|
if (conditions = @conditions[event_name])
|
129
129
|
ids = Set[*conditions.map(&:first).map(&:object_id)]
|
130
130
|
conditions.delete_if do |condition|
|
@@ -148,7 +148,7 @@ module Discorb
|
|
148
148
|
lambda { |event_args|
|
149
149
|
Async(annotation: "Discorb event: #{event_name}") do |task|
|
150
150
|
@events[event_name].delete(block) if block.discriminator[:once]
|
151
|
-
block.call(
|
151
|
+
block.call(*event_args)
|
152
152
|
@log.debug "Dispatched proc with ID #{block.id.inspect}"
|
153
153
|
rescue StandardError, ScriptError => e
|
154
154
|
message = "An error occurred while dispatching proc with ID #{block.id.inspect}\n#{e.full_message}"
|
@@ -187,7 +187,7 @@ module Discorb
|
|
187
187
|
#
|
188
188
|
def fetch_user(id)
|
189
189
|
Async do
|
190
|
-
_resp, data =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
278
|
+
_resp, data = http.get("/stickers-packs").wait
|
279
279
|
data.map { |pack| Sticker::Pack.new(self, pack) }
|
280
280
|
end
|
281
281
|
end
|
@@ -293,7 +293,7 @@ module Discorb
|
|
293
293
|
end
|
294
294
|
payload[:status] = status unless status.nil?
|
295
295
|
if @connection
|
296
|
-
Async do
|
296
|
+
Async do
|
297
297
|
send_gateway(3, **payload)
|
298
298
|
end
|
299
299
|
else
|
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.0.
|
7
|
+
VERSION = "0.0.8"
|
8
8
|
# @return [String] The user agent for the bot.
|
9
9
|
USER_AGENT = "DiscordBot (https://github.com/discorb-lib/discorb #{VERSION}) Ruby/#{RUBY_VERSION}"
|
10
10
|
|
data/lib/discorb/emoji.rb
CHANGED
@@ -86,7 +86,7 @@ module Discorb
|
|
86
86
|
payload = {}
|
87
87
|
payload[:name] = name if name != :unset
|
88
88
|
payload[:roles] = roles.map { |r| Discorb::Utils.try(r, :id) } if roles != :unset
|
89
|
-
@client.
|
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.
|
107
|
+
@client.http.delete("/guilds/#{@guild.id}/emojis/#{@id}", audit_log_reason: reason).wait
|
108
108
|
@available = false
|
109
109
|
self
|
110
110
|
end
|
data/lib/discorb/gateway.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "async/http"
|
4
|
+
|
3
5
|
module Discorb
|
4
6
|
#
|
5
7
|
# A module to handle gateway.
|
@@ -87,7 +89,7 @@ module Discorb
|
|
87
89
|
#
|
88
90
|
# @return [Discorb::Message] The message.
|
89
91
|
def fetch_message(force: false)
|
90
|
-
Async do
|
92
|
+
Async do
|
91
93
|
next @message if !force && @message
|
92
94
|
|
93
95
|
@message = @channel.fetch_message(@message_id).wait
|
@@ -136,7 +138,7 @@ module Discorb
|
|
136
138
|
#
|
137
139
|
# @return [Discorb::Message] The message.
|
138
140
|
def fetch_message(force: false)
|
139
|
-
Async do
|
141
|
+
Async do
|
140
142
|
next @message if !force && @message
|
141
143
|
|
142
144
|
@message = @channel.fetch_message(@message_id).wait
|
@@ -188,7 +190,7 @@ module Discorb
|
|
188
190
|
#
|
189
191
|
# @return [Discorb::Message] The message.
|
190
192
|
def fetch_message(force: false)
|
191
|
-
Async do
|
193
|
+
Async do
|
192
194
|
next @message if !force && @message
|
193
195
|
|
194
196
|
@message = @channel.fetch_message(@message_id).wait
|
@@ -453,10 +455,10 @@ module Discorb
|
|
453
455
|
|
454
456
|
def connect_gateway(first)
|
455
457
|
@log.info "Connecting to gateway."
|
456
|
-
Async do
|
457
|
-
@
|
458
|
+
Async do
|
459
|
+
@http = HTTP.new(self) if first
|
458
460
|
@first = first
|
459
|
-
_, gateway_response = @
|
461
|
+
_, gateway_response = @http.get("/gateway").wait
|
460
462
|
gateway_url = gateway_response[:url]
|
461
463
|
endpoint = Async::HTTP::Endpoint.parse("#{gateway_url}?v=9&encoding=json",
|
462
464
|
alpn_protocols: Async::HTTP::Protocol::HTTP11.names)
|
@@ -710,14 +712,14 @@ module Discorb
|
|
710
712
|
dispatch(:member_add, nm)
|
711
713
|
when "GUILD_MEMBER_UPDATE"
|
712
714
|
return @log.warn "Unknown guild id #{data[:guild_id]}, ignoring" unless (guild = @guilds[data[:guild_id]])
|
713
|
-
return @log.warn "Unknown member id #{data[:id]}, ignoring" unless (nm = guild.members[data[:id]])
|
715
|
+
return @log.warn "Unknown member id #{data[:user][:id]}, ignoring" unless (nm = guild.members[data[:user][:id]])
|
714
716
|
|
715
717
|
old = Member.new(self, data[:guild_id], data[:user], data.update({ no_cache: true }))
|
716
718
|
nm.send(:_set_data, data[:user], data)
|
717
719
|
dispatch(:member_update, old, nm)
|
718
720
|
when "GUILD_MEMBER_REMOVE"
|
719
721
|
return @log.warn "Unknown guild id #{data[:guild_id]}, ignoring" unless (guild = @guilds[data[:guild_id]])
|
720
|
-
return @log.warn "Unknown member id #{data[:id]}, ignoring" unless (member = guild.members.delete(data[:id]))
|
722
|
+
return @log.warn "Unknown member id #{data[:user][:id]}, ignoring" unless (member = guild.members.delete(data[:user][:id]))
|
721
723
|
|
722
724
|
dispatch(:member_remove, member)
|
723
725
|
when "GUILD_BAN_ADD"
|
data/lib/discorb/guild.rb
CHANGED
@@ -164,7 +164,7 @@ module Discorb
|
|
164
164
|
#
|
165
165
|
def leave!
|
166
166
|
Async do
|
167
|
-
@client.
|
167
|
+
@client.http.delete("/users/@me/guilds/#{@id}").wait
|
168
168
|
@client.guilds.delete(@id)
|
169
169
|
end
|
170
170
|
end
|
@@ -179,7 +179,7 @@ module Discorb
|
|
179
179
|
#
|
180
180
|
def fetch_emoji_list
|
181
181
|
Async do
|
182
|
-
_resp, data = @client.
|
182
|
+
_resp, data = @client.http.get("/guilds/#{@id}/emojis").wait
|
183
183
|
@emojis = Dictionary.new
|
184
184
|
ids = @emojis.map(&:id).map(&:to_s)
|
185
185
|
data.map do |e|
|
@@ -204,7 +204,7 @@ module Discorb
|
|
204
204
|
# @return [Discorb::CustomEmoji] The emoji with the given id.
|
205
205
|
#
|
206
206
|
def fetch_emoji(id)
|
207
|
-
_resp, data = @client.
|
207
|
+
_resp, data = @client.http.get("/guilds/#{@id}/emojis/#{id}").wait
|
208
208
|
@emojis[e[:id]] = CustomEmoji.new(@client, self, data)
|
209
209
|
end
|
210
210
|
|
@@ -220,7 +220,7 @@ module Discorb
|
|
220
220
|
# @return [Discorb::CustomEmoji] The created emoji.
|
221
221
|
#
|
222
222
|
def create_emoji(name, image, roles: [])
|
223
|
-
_resp, data = @client.
|
223
|
+
_resp, data = @client.http.post(
|
224
224
|
"/guilds/#{@id}/emojis",
|
225
225
|
{
|
226
226
|
name: name,
|
@@ -240,7 +240,7 @@ module Discorb
|
|
240
240
|
#
|
241
241
|
def fetch_webhooks
|
242
242
|
Async do
|
243
|
-
_resp, data = @client.
|
243
|
+
_resp, data = @client.http.get("/guilds/#{@id}/webhooks").wait
|
244
244
|
data.map { |webhook| Webhook.new([@client, webhook]) }
|
245
245
|
end
|
246
246
|
end
|
@@ -254,7 +254,7 @@ module Discorb
|
|
254
254
|
#
|
255
255
|
def fetch_audit_log
|
256
256
|
Async do
|
257
|
-
_resp, data = @client.
|
257
|
+
_resp, data = @client.http.get("/guilds/#{@id}/audit-logs").wait
|
258
258
|
AuditLog.new(@client, data, self)
|
259
259
|
end
|
260
260
|
end
|
@@ -268,7 +268,7 @@ module Discorb
|
|
268
268
|
#
|
269
269
|
def fetch_channels
|
270
270
|
Async do
|
271
|
-
_resp, data = @client.
|
271
|
+
_resp, data = @client.http.get("/guilds/#{@id}/channels").wait
|
272
272
|
data.map { |c| Channel.make_channel(@client, c) }
|
273
273
|
end
|
274
274
|
end
|
@@ -312,7 +312,7 @@ module Discorb
|
|
312
312
|
end
|
313
313
|
end
|
314
314
|
payload[:parent_id] = parent.id if parent
|
315
|
-
_resp, data = @client.
|
315
|
+
_resp, data = @client.http.post(
|
316
316
|
"/guilds/#{@id}/channels", payload, audit_log_reason: reason,
|
317
317
|
).wait
|
318
318
|
payload[:parent_id] = parent&.id
|
@@ -355,7 +355,7 @@ module Discorb
|
|
355
355
|
end
|
356
356
|
end
|
357
357
|
payload[:parent_id] = parent.id if parent
|
358
|
-
_resp, data = @client.
|
358
|
+
_resp, data = @client.http.post(
|
359
359
|
"/guilds/#{@id}/channels", payload, audit_log_reason: reason,
|
360
360
|
).wait
|
361
361
|
payload[:parent_id] = parent&.id
|
@@ -391,7 +391,7 @@ module Discorb
|
|
391
391
|
end
|
392
392
|
end
|
393
393
|
payload[:parent_id] = parent&.id
|
394
|
-
_resp, data = @client.
|
394
|
+
_resp, data = @client.http.post(
|
395
395
|
"/guilds/#{@id}/channels", payload, audit_log_reason: reason,
|
396
396
|
).wait
|
397
397
|
Channel.make_channel(@client, data)
|
@@ -431,7 +431,7 @@ module Discorb
|
|
431
431
|
end
|
432
432
|
end
|
433
433
|
payload[:parent_id] = parent&.id
|
434
|
-
_resp, data = @client.
|
434
|
+
_resp, data = @client.http.post(
|
435
435
|
"/guilds/#{@id}/channels", payload, audit_log_reason: reason,
|
436
436
|
).wait
|
437
437
|
Channel.make_channel(@client, data)
|
@@ -477,7 +477,7 @@ module Discorb
|
|
477
477
|
end
|
478
478
|
payload[:nsfw] = nsfw unless nsfw.nil?
|
479
479
|
payload[:parent_id] = parent&.id
|
480
|
-
_resp, data = @client.
|
480
|
+
_resp, data = @client.http.post(
|
481
481
|
"/guilds/#{@id}/channels", payload, audit_log_reason: reason,
|
482
482
|
).wait
|
483
483
|
Channel.make_channel(@client, data)
|
@@ -493,7 +493,7 @@ module Discorb
|
|
493
493
|
#
|
494
494
|
def fetch_active_threads
|
495
495
|
Async do
|
496
|
-
_resp, data = @client.
|
496
|
+
_resp, data = @client.http.get("/guilds/#{@id}/threads/active").wait
|
497
497
|
data[:threads].map { |t| Channel.make_thread(@client, t) }
|
498
498
|
end
|
499
499
|
end
|
@@ -511,7 +511,7 @@ module Discorb
|
|
511
511
|
#
|
512
512
|
def fetch_member(id)
|
513
513
|
Async do
|
514
|
-
_resp, data = @client.
|
514
|
+
_resp, data = @client.http.get("/guilds/#{@id}/members/#{id}").wait
|
515
515
|
rescue Discorb::NotFoundError
|
516
516
|
nil
|
517
517
|
else
|
@@ -531,7 +531,7 @@ module Discorb
|
|
531
531
|
#
|
532
532
|
def fetch_members_named(name, limit: 1)
|
533
533
|
Async do
|
534
|
-
_resp, data = @client.
|
534
|
+
_resp, data = @client.http.get("/guilds/#{@id}/members/search?#{URI.encode_www_form({ query: name, limit: limit })}").wait
|
535
535
|
data.map { |d| Member.new(@client, @id, d[:user], d) }
|
536
536
|
end
|
537
537
|
end
|
@@ -558,7 +558,7 @@ module Discorb
|
|
558
558
|
#
|
559
559
|
def edit_nickname(nickname, reason: nil)
|
560
560
|
Async do
|
561
|
-
@client.
|
561
|
+
@client.http.patch("/guilds/#{@id}/members/@me/nick", { nick: nickname }, audit_log_reason: reason).wait
|
562
562
|
end
|
563
563
|
end
|
564
564
|
|
@@ -576,7 +576,7 @@ module Discorb
|
|
576
576
|
#
|
577
577
|
def kick_member(member, reason: nil)
|
578
578
|
Async do
|
579
|
-
@client.
|
579
|
+
@client.http.delete("/guilds/#{@id}/members/#{member.id}", audit_log_reason: reason).wait
|
580
580
|
end
|
581
581
|
end
|
582
582
|
|
@@ -589,7 +589,7 @@ module Discorb
|
|
589
589
|
#
|
590
590
|
def fetch_bans
|
591
591
|
Async do
|
592
|
-
_resp, data = @client.
|
592
|
+
_resp, data = @client.http.get("/guilds/#{@id}/bans").wait
|
593
593
|
data.map { |d| Ban.new(@client, self, d) }
|
594
594
|
end
|
595
595
|
end
|
@@ -606,7 +606,7 @@ module Discorb
|
|
606
606
|
#
|
607
607
|
def fetch_ban(user)
|
608
608
|
Async do
|
609
|
-
_resp, data = @client.
|
609
|
+
_resp, data = @client.http.get("/guilds/#{@id}/bans/#{user.id}").wait
|
610
610
|
rescue Discorb::NotFoundError
|
611
611
|
nil
|
612
612
|
else
|
@@ -642,7 +642,7 @@ module Discorb
|
|
642
642
|
#
|
643
643
|
def ban_member(member, delete_message_days: 0, reason: nil)
|
644
644
|
Async do
|
645
|
-
_resp, data = @client.
|
645
|
+
_resp, data = @client.http.post(
|
646
646
|
"/guilds/#{@id}/bans", { user: member.id, delete_message_days: delete_message_days }, audit_log_reason: reason,
|
647
647
|
).wait
|
648
648
|
Ban.new(@client, self, data)
|
@@ -659,7 +659,7 @@ module Discorb
|
|
659
659
|
#
|
660
660
|
def unban_user(user, reason: nil)
|
661
661
|
Async do
|
662
|
-
@client.
|
662
|
+
@client.http.delete("/guilds/#{@id}/bans/#{user.id}", audit_log_reason: reason).wait
|
663
663
|
end
|
664
664
|
end
|
665
665
|
|
@@ -672,7 +672,7 @@ module Discorb
|
|
672
672
|
#
|
673
673
|
def fetch_roles
|
674
674
|
Async do
|
675
|
-
_resp, data = @client.
|
675
|
+
_resp, data = @client.http.get("/guilds/#{@id}/roles").wait
|
676
676
|
data.map { |d| Role.new(@client, self, d) }
|
677
677
|
end
|
678
678
|
end
|
@@ -697,7 +697,7 @@ module Discorb
|
|
697
697
|
payload[:color] = color.to_i if color
|
698
698
|
payload[:hoist] = hoist if hoist
|
699
699
|
payload[:mentionable] = mentionable if mentionable
|
700
|
-
_resp, data = @client.
|
700
|
+
_resp, data = @client.http.post(
|
701
701
|
"/guilds/#{@id}/roles", payload, audit_log_reason: reason,
|
702
702
|
).wait
|
703
703
|
Role.new(@client, self, data)
|
@@ -721,7 +721,7 @@ module Discorb
|
|
721
721
|
include_roles: @id.to_s,
|
722
722
|
}
|
723
723
|
param[:include_roles] = roles.map(&:id).map(&:to_s).join(";") if roles.any?
|
724
|
-
_resp, data = @client.
|
724
|
+
_resp, data = @client.http.get("/guilds/#{@id}/prune?#{URI.encode_www_form(params)}").wait
|
725
725
|
data[:pruned]
|
726
726
|
end
|
727
727
|
end
|
@@ -739,7 +739,7 @@ module Discorb
|
|
739
739
|
#
|
740
740
|
def prune(days = 7, roles: [], reason: nil)
|
741
741
|
Async do
|
742
|
-
_resp, data = @client.
|
742
|
+
_resp, data = @client.http.post(
|
743
743
|
"/guilds/#{@id}/prune", { days: days, roles: roles.map(&:id) }, audit_log_reason: reason,
|
744
744
|
).wait
|
745
745
|
data[:pruned]
|
@@ -755,7 +755,7 @@ module Discorb
|
|
755
755
|
#
|
756
756
|
def fetch_voice_regions
|
757
757
|
Async do
|
758
|
-
_resp, data = @client.
|
758
|
+
_resp, data = @client.http.get("/guilds/#{@id}/voice").wait
|
759
759
|
data.map { |d| VoiceRegion.new(@client, d) }
|
760
760
|
end
|
761
761
|
end
|
@@ -769,7 +769,7 @@ module Discorb
|
|
769
769
|
#
|
770
770
|
def fetch_invites
|
771
771
|
Async do
|
772
|
-
_resp, data = @client.
|
772
|
+
_resp, data = @client.http.get("/guilds/#{@id}/invites").wait
|
773
773
|
data.map { |d| Invite.new(@client, d) }
|
774
774
|
end
|
775
775
|
end
|
@@ -783,7 +783,7 @@ module Discorb
|
|
783
783
|
#
|
784
784
|
def fetch_integrations
|
785
785
|
Async do
|
786
|
-
_resp, data = @client.
|
786
|
+
_resp, data = @client.http.get("/guilds/#{@id}/integrations").wait
|
787
787
|
data.map { |d| Integration.new(@client, d) }
|
788
788
|
end
|
789
789
|
end
|
@@ -797,7 +797,7 @@ module Discorb
|
|
797
797
|
#
|
798
798
|
def fetch_widget
|
799
799
|
Async do
|
800
|
-
_resp, data = @client.
|
800
|
+
_resp, data = @client.http.get("/guilds/#{@id}/widget").wait
|
801
801
|
Widget.new(@client, @id, data)
|
802
802
|
end
|
803
803
|
end
|
@@ -811,7 +811,7 @@ module Discorb
|
|
811
811
|
#
|
812
812
|
def fetch_vanity_invite
|
813
813
|
Async do
|
814
|
-
_resp, data = @client.
|
814
|
+
_resp, data = @client.http.get("/guilds/#{@id}/vanity-url").wait
|
815
815
|
VanityInvite.new(@client, self, data)
|
816
816
|
end
|
817
817
|
end
|
@@ -825,7 +825,7 @@ module Discorb
|
|
825
825
|
#
|
826
826
|
def fetch_welcome_screen
|
827
827
|
Async do
|
828
|
-
_resp, data = @client.
|
828
|
+
_resp, data = @client.http.get("/guilds/#{@id}/welcome-screen").wait
|
829
829
|
WelcomeScreen.new(@client, self, data)
|
830
830
|
end
|
831
831
|
end
|
@@ -839,7 +839,7 @@ module Discorb
|
|
839
839
|
#
|
840
840
|
def fetch_stickers
|
841
841
|
Async do
|
842
|
-
_resp, data = @client.
|
842
|
+
_resp, data = @client.http.get("/guilds/#{@id}/stickers").wait
|
843
843
|
data.map { |d| Sticker::GuildSticker.new(@client, d) }
|
844
844
|
end
|
845
845
|
end
|
@@ -856,7 +856,7 @@ module Discorb
|
|
856
856
|
#
|
857
857
|
def fetch_sticker(id)
|
858
858
|
Async do
|
859
|
-
_resp, data = @client.
|
859
|
+
_resp, data = @client.http.get("/guilds/#{@id}/stickers/#{id}").wait
|
860
860
|
rescue Discorb::NotFoundError
|
861
861
|
nil
|
862
862
|
else
|
@@ -873,7 +873,7 @@ module Discorb
|
|
873
873
|
#
|
874
874
|
def fetch_templates
|
875
875
|
Async do
|
876
|
-
_resp, data = @client.
|
876
|
+
_resp, data = @client.http.get("/guilds/#{@id}/templates").wait
|
877
877
|
data.map { |d| GuildTemplate.new(@client, d) }
|
878
878
|
end
|
879
879
|
end
|
@@ -901,7 +901,7 @@ module Discorb
|
|
901
901
|
#
|
902
902
|
def create_template(name, description = nil, reason: nil)
|
903
903
|
Async do
|
904
|
-
_resp, data = @client.
|
904
|
+
_resp, data = @client.http.post(
|
905
905
|
"/guilds/#{@id}/templates", { name: name, description: description }, audit_log_reason: reason,
|
906
906
|
).wait
|
907
907
|
GuildTemplate.new(@client, data)
|
@@ -982,7 +982,7 @@ module Discorb
|
|
982
982
|
payload = {}
|
983
983
|
payload[:enabled] = enabled unless enabled.nil?
|
984
984
|
payload[:channel_id] = channel.id if channel_id
|
985
|
-
@client.
|
985
|
+
@client.http.patch("/guilds/#{@guild_id}/widget", payload, audit_log_reason: reason).wait
|
986
986
|
end
|
987
987
|
end
|
988
988
|
|
@@ -1059,7 +1059,7 @@ module Discorb
|
|
1059
1059
|
@members = Discorb::Dictionary.new
|
1060
1060
|
data[:members].each do |m|
|
1061
1061
|
Member.new(@client, @id, m[:user], m)
|
1062
|
-
end
|
1062
|
+
end if data[:members]
|
1063
1063
|
@splash = data[:splash] && Asset.new(self, data[:splash], path: "splashes/#{@id}")
|
1064
1064
|
@discovery_splash = data[:discovery_splash] && Asset.new(self, data[:discovery_splash], path: "discovery-splashes/#{@id}")
|
1065
1065
|
@owner_id = data[:owner_id]
|
@@ -1236,7 +1236,7 @@ module Discorb
|
|
1236
1236
|
payload[:enabled] = enabled unless enabled == :unset
|
1237
1237
|
payload[:welcome_channels] = channels.map(&:to_hash) unless channels == :unset
|
1238
1238
|
payload[:description] = description unless description == :unset
|
1239
|
-
@client.
|
1239
|
+
@client.http.patch("/guilds/#{@guild.id}/welcome-screen", payload, audit_log_reason: reason).wait
|
1240
1240
|
end
|
1241
1241
|
end
|
1242
1242
|
end
|