discorb 0.15.0 → 0.15.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/.rubocop.yml +6 -2
- data/Changelog.md +9 -0
- data/Rakefile +6 -0
- data/docs/events.md +50 -0
- data/lib/discorb/allowed_mentions.rb +7 -0
- data/lib/discorb/app_command/command.rb +64 -2
- data/lib/discorb/application.rb +16 -7
- data/lib/discorb/asset.rb +9 -0
- data/lib/discorb/attachment.rb +16 -1
- data/lib/discorb/audit_logs.rb +42 -4
- data/lib/discorb/channel.rb +42 -3
- data/lib/discorb/client.rb +4 -0
- data/lib/discorb/common.rb +17 -3
- data/lib/discorb/components/button.rb +5 -6
- data/lib/discorb/components/select_menu.rb +2 -16
- data/lib/discorb/dictionary.rb +2 -0
- data/lib/discorb/embed.rb +33 -7
- data/lib/discorb/emoji.rb +29 -2
- data/lib/discorb/emoji_table.rb +1 -1
- data/lib/discorb/error.rb +7 -1
- data/lib/discorb/event.rb +27 -17
- data/lib/discorb/gateway.rb +79 -22
- data/lib/discorb/gateway_requests.rb +4 -7
- data/lib/discorb/guild.rb +67 -33
- data/lib/discorb/guild_template.rb +24 -3
- data/lib/discorb/http.rb +7 -2
- data/lib/discorb/integration.rb +23 -8
- data/lib/discorb/intents.rb +7 -7
- data/lib/discorb/interaction/autocomplete.rb +2 -2
- data/lib/discorb/interaction/command.rb +32 -3
- data/lib/discorb/interaction/components.rb +14 -1
- data/lib/discorb/interaction/response.rb +12 -0
- data/lib/discorb/interaction/root.rb +15 -0
- data/lib/discorb/invite.rb +11 -7
- data/lib/discorb/log.rb +4 -4
- data/lib/discorb/member.rb +21 -0
- data/lib/discorb/message.rb +9 -1
- data/lib/discorb/message_meta.rb +38 -9
- data/lib/discorb/permission.rb +14 -5
- data/lib/discorb/presence.rb +41 -8
- data/lib/discorb/rate_limit.rb +5 -0
- data/lib/discorb/reaction.rb +6 -0
- data/lib/discorb/role.rb +12 -0
- data/lib/discorb/sticker.rb +22 -14
- data/lib/discorb/user.rb +11 -0
- data/lib/discorb/voice_state.rb +20 -2
- data/lib/discorb/webhook.rb +52 -1
- data/lib/discorb.rb +3 -1
- data/sig/discorb.rbs +6850 -5836
- metadata +2 -2
data/lib/discorb/webhook.rb
CHANGED
@@ -22,7 +22,13 @@ module Discorb
|
|
22
22
|
# @return [String] The URL of the webhook.
|
23
23
|
attr_reader :token
|
24
24
|
|
25
|
+
#
|
26
|
+
# Initializes a webhook.
|
25
27
|
# @private
|
28
|
+
#
|
29
|
+
# @param [Discorb::Client] client The client.
|
30
|
+
# @param [Hash] data The data of the webhook.
|
31
|
+
#
|
26
32
|
def initialize(client, data)
|
27
33
|
@name = data[:name]
|
28
34
|
@guild_id = data[:guild_id] && Snowflake.new(data[:guild_id])
|
@@ -200,7 +206,13 @@ module Discorb
|
|
200
206
|
# @!attribute [r] url
|
201
207
|
# @return [String] The URL of the webhook.
|
202
208
|
|
209
|
+
#
|
210
|
+
# Initializes the incoming webhook.
|
203
211
|
# @private
|
212
|
+
#
|
213
|
+
# @param [Discorb::Client] client The client.
|
214
|
+
# @param [String] url The URL of the webhook.
|
215
|
+
#
|
204
216
|
def initialize(client, data)
|
205
217
|
super
|
206
218
|
@token = data[:token]
|
@@ -222,7 +234,13 @@ module Discorb
|
|
222
234
|
# Represents a source channel of follower webhook.
|
223
235
|
# @return [Discorb::Channel, Discorb::Webhook::FollowerWebhook::Channel] The source channel of follower webhook.
|
224
236
|
|
237
|
+
#
|
238
|
+
# Initializes the follower webhook.
|
225
239
|
# @private
|
240
|
+
#
|
241
|
+
# @param [Discorb::Client] client The client.
|
242
|
+
# @param [Hash] data The data of the follower webhook.
|
243
|
+
#
|
226
244
|
def initialize(client, data)
|
227
245
|
super
|
228
246
|
@source_guild = FollowerWebhook::Guild.new(data[:source_guild])
|
@@ -248,12 +266,21 @@ module Discorb
|
|
248
266
|
# @return [Discorb::Asset] The icon of the guild.
|
249
267
|
attr_reader :icon
|
250
268
|
|
269
|
+
#
|
270
|
+
# Initialize a new guild.
|
251
271
|
# @private
|
272
|
+
#
|
273
|
+
# @param [Hash] data The data of the guild.
|
274
|
+
#
|
252
275
|
def initialize(data)
|
253
276
|
@id = Snowflake.new(data[:id])
|
254
277
|
@name = data[:name]
|
255
278
|
@icon = Asset.new(self, data[:icon])
|
256
279
|
end
|
280
|
+
|
281
|
+
def inspect
|
282
|
+
"#<#{self.class.name} #{@id}: #{@name}>"
|
283
|
+
end
|
257
284
|
end
|
258
285
|
|
259
286
|
#
|
@@ -265,11 +292,20 @@ module Discorb
|
|
265
292
|
# @return [String] The name of the channel.
|
266
293
|
attr_reader :name
|
267
294
|
|
295
|
+
#
|
296
|
+
# Initialize a new channel.
|
268
297
|
# @private
|
298
|
+
#
|
299
|
+
# @param [Hash] data The data of the channel.
|
300
|
+
#
|
269
301
|
def initialize(data)
|
270
302
|
@id = Snowflake.new(data[:id])
|
271
303
|
@name = data[:name]
|
272
304
|
end
|
305
|
+
|
306
|
+
def inspect
|
307
|
+
"#<#{self.class.name} #{@id}: #{@name}>"
|
308
|
+
end
|
273
309
|
end
|
274
310
|
end
|
275
311
|
|
@@ -290,7 +326,13 @@ module Discorb
|
|
290
326
|
# @return [Discorb::Snowflake] The ID of the guild.
|
291
327
|
attr_reader :guild_id
|
292
328
|
|
329
|
+
#
|
330
|
+
# Initializes the message.
|
293
331
|
# @private
|
332
|
+
#
|
333
|
+
# @param [Discorb::Webhook] webhook The webhook.
|
334
|
+
# @param [Hash] data The data of the message.
|
335
|
+
# @param [Discorb::Client] client The client. This will be nil if it's created from {URLWebhook}.
|
294
336
|
def initialize(webhook, data, client = nil)
|
295
337
|
@client = client
|
296
338
|
@webhook = webhook
|
@@ -329,7 +371,7 @@ module Discorb
|
|
329
371
|
|
330
372
|
def _set_data(data)
|
331
373
|
@id = Snowflake.new(data[:id])
|
332
|
-
@type = Discorb::Message
|
374
|
+
@type = Discorb::Message::MESSAGE_TYPE[data[:type]]
|
333
375
|
@content = data[:content]
|
334
376
|
@channel_id = Snowflake.new(data[:channel_id])
|
335
377
|
@author = Author.new(data[:author])
|
@@ -364,7 +406,12 @@ module Discorb
|
|
364
406
|
# @return [String] The discriminator of the author.
|
365
407
|
attr_reader :discriminator
|
366
408
|
|
409
|
+
#
|
410
|
+
# Initializes the author.
|
367
411
|
# @private
|
412
|
+
#
|
413
|
+
# @param [Hash] data The data of the author.
|
414
|
+
#
|
368
415
|
def initialize(data)
|
369
416
|
@data = data
|
370
417
|
@bot = data[:bot]
|
@@ -384,6 +431,10 @@ module Discorb
|
|
384
431
|
end
|
385
432
|
|
386
433
|
alias to_s_user to_s
|
434
|
+
|
435
|
+
def inspect
|
436
|
+
"#<#{self.class.name} #{self}>"
|
437
|
+
end
|
387
438
|
end
|
388
439
|
end
|
389
440
|
|
data/lib/discorb.rb
CHANGED
@@ -4,7 +4,10 @@
|
|
4
4
|
#
|
5
5
|
# @author sevenc-nanashi
|
6
6
|
module Discorb
|
7
|
+
#
|
8
|
+
# Method to define a macro for YARD.
|
7
9
|
# @private
|
10
|
+
#
|
8
11
|
# @!macro [new] async
|
9
12
|
# @note This is an asynchronous method, it will return a `Async::Task` object. Use `Async::Task#wait` to get the result.
|
10
13
|
#
|
@@ -23,7 +26,6 @@ module Discorb
|
|
23
26
|
# @raise [Discorb::HTTPError] HTTP request failed.
|
24
27
|
#
|
25
28
|
def macro
|
26
|
-
# NOTE: this method is only for YARD.
|
27
29
|
puts "Wow, You found the easter egg!\n"
|
28
30
|
red = "\e[31m"
|
29
31
|
reset = "\e[m"
|