discorb 0.5.4 → 0.6.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/ISSUE_TEMPLATE/bug_report.md +57 -0
- data/.github/ISSUE_TEMPLATE/config.yml +8 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +38 -0
- data/Changelog.md +23 -1
- data/Gemfile.lock +1 -1
- data/docs/application_command.md +8 -8
- data/docs/cli/run.md +11 -1
- data/docs/cli/setup.md +7 -1
- data/docs/events.md +29 -0
- data/docs/extension.md +1 -1
- data/lib/discorb/{command.rb → app_command.rb} +56 -46
- data/lib/discorb/channel.rb +18 -18
- data/lib/discorb/client.rb +35 -25
- data/lib/discorb/color.rb +59 -29
- data/lib/discorb/common.rb +1 -1
- data/lib/discorb/embed.rb +2 -2
- data/lib/discorb/emoji.rb +9 -2
- data/lib/discorb/error.rb +7 -1
- data/lib/discorb/event.rb +5 -5
- data/lib/discorb/exe/init.rb +3 -3
- data/lib/discorb/exe/run.rb +12 -0
- data/lib/discorb/exe/setup.rb +14 -1
- data/lib/discorb/extension.rb +9 -9
- data/lib/discorb/gateway.rb +19 -7
- data/lib/discorb/guild.rb +38 -38
- data/lib/discorb/http.rb +13 -11
- data/lib/discorb/intents.rb +2 -2
- data/lib/discorb/interaction.rb +3 -3
- data/lib/discorb/member.rb +1 -1
- data/lib/discorb/message.rb +5 -5
- data/lib/discorb/modules.rb +5 -5
- data/lib/discorb/user.rb +1 -1
- data/lib/discorb/webhook.rb +1 -1
- data/lib/discorb.rb +1 -1
- data/po/yard.pot +37 -37
- data/sig/discorb.rbs +7218 -0
- metadata +7 -3
data/lib/discorb/channel.rb
CHANGED
@@ -171,7 +171,7 @@ module Discorb
|
|
171
171
|
#
|
172
172
|
# @param [String] reason The reason of deleting the channel.
|
173
173
|
#
|
174
|
-
# @return [self] The deleted channel.
|
174
|
+
# @return [Async::Task<self>] The deleted channel.
|
175
175
|
#
|
176
176
|
def delete!(reason: nil)
|
177
177
|
Async do
|
@@ -194,7 +194,7 @@ module Discorb
|
|
194
194
|
# @param [Discorb::CategoryChannel] parent The parent of channel.
|
195
195
|
# @param [String] reason The reason of moving the channel.
|
196
196
|
#
|
197
|
-
# @return [self] The moved channel.
|
197
|
+
# @return [Async::Task<self>] The moved channel.
|
198
198
|
#
|
199
199
|
def move(position, lock_permissions: false, parent: :unset, reason: nil)
|
200
200
|
Async do
|
@@ -273,7 +273,7 @@ module Discorb
|
|
273
273
|
# @param [Integer] archive_in Alias of `default_auto_archive_duration`.
|
274
274
|
# @param [String] reason The reason of editing the channel.
|
275
275
|
#
|
276
|
-
# @return [self] The edited channel.
|
276
|
+
# @return [Async::Task<self>] The edited channel.
|
277
277
|
#
|
278
278
|
def edit(name: :unset, position: :unset, category: :unset, parent: :unset,
|
279
279
|
topic: :unset, nsfw: :unset, announce: :unset,
|
@@ -310,7 +310,7 @@ module Discorb
|
|
310
310
|
# @param [String] name The name of the webhook.
|
311
311
|
# @param [Discorb::Image] avatar The avatar of the webhook.
|
312
312
|
#
|
313
|
-
# @return [Discorb::Webhook::IncomingWebhook] The created webhook.
|
313
|
+
# @return [Async::Task<Discorb::Webhook::IncomingWebhook>] The created webhook.
|
314
314
|
#
|
315
315
|
def create_webhook(name, avatar: nil)
|
316
316
|
Async do
|
@@ -327,7 +327,7 @@ module Discorb
|
|
327
327
|
# @macro async
|
328
328
|
# @macro http
|
329
329
|
#
|
330
|
-
# @return [Array<Discorb::Webhook
|
330
|
+
# @return [Async::Task<Array<Discorb::Webhook>>] The webhooks in the channel.
|
331
331
|
#
|
332
332
|
def fetch_webhooks
|
333
333
|
Async do
|
@@ -419,7 +419,7 @@ module Discorb
|
|
419
419
|
# @macro async
|
420
420
|
# @macro http
|
421
421
|
#
|
422
|
-
# @return [Array<Discorb::Invite
|
422
|
+
# @return [Async::Task<Array<Discorb::Invite>>] The invites in the channel.
|
423
423
|
#
|
424
424
|
def fetch_invites
|
425
425
|
Async do
|
@@ -440,7 +440,7 @@ module Discorb
|
|
440
440
|
# @note if it's `false` it may return existing invite.
|
441
441
|
# @param [String] reason The reason of creating the invite.
|
442
442
|
#
|
443
|
-
# @return [Invite] The created invite.
|
443
|
+
# @return [Async::Task<Invite>] The created invite.
|
444
444
|
#
|
445
445
|
def create_invite(max_age: nil, max_uses: nil, temporary: false, unique: false, reason: nil)
|
446
446
|
Async do
|
@@ -487,7 +487,7 @@ module Discorb
|
|
487
487
|
# @macro async
|
488
488
|
# @macro http
|
489
489
|
#
|
490
|
-
# @return [Array<Discorb::Message
|
490
|
+
# @return [Async::Task<Array<Discorb::Message>>] The pinned messages in the channel.
|
491
491
|
#
|
492
492
|
def fetch_pins
|
493
493
|
Async do
|
@@ -535,7 +535,7 @@ module Discorb
|
|
535
535
|
# @param [Boolean] public Whether the thread is public.
|
536
536
|
# @param [String] reason The reason of starting the thread.
|
537
537
|
#
|
538
|
-
# @return [Discorb::ThreadChannel] The started thread.
|
538
|
+
# @return [Async::Task<Discorb::ThreadChannel>] The started thread.
|
539
539
|
#
|
540
540
|
def start_thread(name, message: nil, auto_archive_duration: 1440, public: true, reason: nil)
|
541
541
|
Async do
|
@@ -560,7 +560,7 @@ module Discorb
|
|
560
560
|
# @macro async
|
561
561
|
# @macro http
|
562
562
|
#
|
563
|
-
# @return [Array<Discorb::ThreadChannel
|
563
|
+
# @return [Async::Task<Array<Discorb::ThreadChannel>>] The archived threads in the channel.
|
564
564
|
#
|
565
565
|
def fetch_archived_public_threads
|
566
566
|
Async do
|
@@ -574,7 +574,7 @@ module Discorb
|
|
574
574
|
# @macro async
|
575
575
|
# @macro http
|
576
576
|
#
|
577
|
-
# @return [Array<Discorb::ThreadChannel
|
577
|
+
# @return [Async::Task<Array<Discorb::ThreadChannel>>] The archived private threads in the channel.
|
578
578
|
#
|
579
579
|
def fetch_archived_private_threads
|
580
580
|
Async do
|
@@ -591,7 +591,7 @@ module Discorb
|
|
591
591
|
# @param [Integer] limit The limit of threads to fetch.
|
592
592
|
# @param [Time] before <description>
|
593
593
|
#
|
594
|
-
# @return [Array<Discorb::ThreadChannel
|
594
|
+
# @return [Async::Task<Array<Discorb::ThreadChannel>>] The joined archived private threads in the channel.
|
595
595
|
#
|
596
596
|
def fetch_joined_archived_private_threads(limit: nil, before: nil)
|
597
597
|
Async do
|
@@ -660,7 +660,7 @@ module Discorb
|
|
660
660
|
# @param [Symbol] rtc_region The region of the voice channel.
|
661
661
|
# @param [String] reason The reason of editing the voice channel.
|
662
662
|
#
|
663
|
-
# @return [self] The edited voice channel.
|
663
|
+
# @return [Async::Task<self>] The edited voice channel.
|
664
664
|
#
|
665
665
|
def edit(name: :unset, position: :unset, bitrate: :unset, user_limit: :unset, rtc_region: :unset, reason: nil)
|
666
666
|
Async do
|
@@ -728,7 +728,7 @@ module Discorb
|
|
728
728
|
# @param [Symbol] rtc_region The region of the stage channel.
|
729
729
|
# @param [String] reason The reason of editing the stage channel.
|
730
730
|
#
|
731
|
-
# @return [self] The edited stage channel.
|
731
|
+
# @return [Async::Task<self>] The edited stage channel.
|
732
732
|
#
|
733
733
|
def edit(name: :unset, position: :unset, bitrate: :unset, rtc_region: :unset, reason: nil)
|
734
734
|
Async do
|
@@ -753,7 +753,7 @@ module Discorb
|
|
753
753
|
# @param [Boolean] public Whether the stage instance is public or not.
|
754
754
|
# @param [String] reason The reason of starting the stage instance.
|
755
755
|
#
|
756
|
-
# @return [Discorb::StageInstance] The started stage instance.
|
756
|
+
# @return [Async::Task<Discorb::StageInstance>] The started stage instance.
|
757
757
|
#
|
758
758
|
def start(topic, public: false, reason: nil)
|
759
759
|
Async do
|
@@ -767,8 +767,8 @@ module Discorb
|
|
767
767
|
# @macro async
|
768
768
|
# @macro http
|
769
769
|
#
|
770
|
-
# @return [StageInstance] The current stage instance.
|
771
|
-
# @return [nil] If there is no current stage instance.
|
770
|
+
# @return [Async::Task<StageInstance>] The current stage instance.
|
771
|
+
# @return [Async::Task<nil>] If there is no current stage instance.
|
772
772
|
#
|
773
773
|
def fetch_stage_instance
|
774
774
|
Async do
|
@@ -853,7 +853,7 @@ module Discorb
|
|
853
853
|
# @param [Boolean] locked Whether the thread is locked or not.
|
854
854
|
# @param [String] reason The reason of editing the thread.
|
855
855
|
#
|
856
|
-
# @return [self] The edited thread.
|
856
|
+
# @return [Async::Task<self>] The edited thread.
|
857
857
|
#
|
858
858
|
# @see #archive
|
859
859
|
# @see #lock
|
data/lib/discorb/client.rb
CHANGED
@@ -41,7 +41,7 @@ module Discorb
|
|
41
41
|
attr_reader :messages
|
42
42
|
# @return [Discorb::Logger] The logger.
|
43
43
|
attr_reader :log
|
44
|
-
# @return [Array<Discorb::
|
44
|
+
# @return [Array<Discorb::ApplicationCommand::Command>] The commands that the client is using.
|
45
45
|
attr_reader :commands
|
46
46
|
# @return [Float] The ping of the client.
|
47
47
|
# @note This will be calculated from heartbeat and heartbeat_ack.
|
@@ -99,14 +99,15 @@ module Discorb
|
|
99
99
|
#
|
100
100
|
# @param [Symbol] event_name The name of the event.
|
101
101
|
# @param [Symbol] id Custom ID of the event.
|
102
|
-
# @param [Hash]
|
102
|
+
# @param [Hash] metadata The metadata of the event.
|
103
103
|
# @param [Proc] block The block to execute when the event is triggered.
|
104
104
|
#
|
105
105
|
# @return [Discorb::Event] The event.
|
106
106
|
#
|
107
|
-
def on(event_name, id: nil, **
|
108
|
-
ne = Event.new(block, id,
|
107
|
+
def on(event_name, id: nil, **metadata, &block)
|
108
|
+
ne = Event.new(block, id, metadata)
|
109
109
|
@events[event_name] ||= []
|
110
|
+
@events[event_name].delete_if { |e| e.metadata[:override] }
|
110
111
|
@events[event_name] << ne
|
111
112
|
ne
|
112
113
|
end
|
@@ -118,12 +119,9 @@ module Discorb
|
|
118
119
|
#
|
119
120
|
# @return [Discorb::Event] The event.
|
120
121
|
#
|
121
|
-
def once(event_name, id: nil, **
|
122
|
-
|
123
|
-
|
124
|
-
@events[event_name] ||= []
|
125
|
-
@events[event_name] << ne
|
126
|
-
ne
|
122
|
+
def once(event_name, id: nil, **metadata, &block)
|
123
|
+
metadata[:once] = true
|
124
|
+
on(event_name, id: id, **metadata, &block)
|
127
125
|
end
|
128
126
|
|
129
127
|
#
|
@@ -177,7 +175,7 @@ module Discorb
|
|
177
175
|
lambda { |event_args|
|
178
176
|
Async(annotation: "Discorb event: #{event_name}") do |task|
|
179
177
|
if block.is_a?(Discorb::Event)
|
180
|
-
@events[event_name].delete(block) if block.
|
178
|
+
@events[event_name].delete(block) if block.metadata[:once]
|
181
179
|
end
|
182
180
|
block.call(*event_args)
|
183
181
|
@log.debug "Dispatched proc with ID #{block.id.inspect}"
|
@@ -202,7 +200,7 @@ module Discorb
|
|
202
200
|
#
|
203
201
|
# @param [#to_s] id <description>
|
204
202
|
#
|
205
|
-
# @return [Discorb::User] The user.
|
203
|
+
# @return [Async::Task<Discorb::User>] The user.
|
206
204
|
#
|
207
205
|
# @raise [Discorb::NotFoundError] If the user doesn't exist.
|
208
206
|
#
|
@@ -220,7 +218,7 @@ module Discorb
|
|
220
218
|
#
|
221
219
|
# @param [#to_s] id The ID of the channel.
|
222
220
|
#
|
223
|
-
# @return [Discorb::Channel] The channel.
|
221
|
+
# @return [Async::Task<Discorb::Channel>] The channel.
|
224
222
|
#
|
225
223
|
# @raise [Discorb::NotFoundError] If the channel doesn't exist.
|
226
224
|
#
|
@@ -238,7 +236,7 @@ module Discorb
|
|
238
236
|
#
|
239
237
|
# @param [#to_s] id <description>
|
240
238
|
#
|
241
|
-
# @return [Discorb::Guild] The guild.
|
239
|
+
# @return [Async::Task<Discorb::Guild>] The guild.
|
242
240
|
#
|
243
241
|
# @raise [Discorb::NotFoundError] If the guild doesn't exist.
|
244
242
|
#
|
@@ -258,7 +256,7 @@ module Discorb
|
|
258
256
|
# @param [Boolean] with_count Whether to include the count of the invite.
|
259
257
|
# @param [Boolean] with_expiration Whether to include the expiration of the invite.
|
260
258
|
#
|
261
|
-
# @return [Discorb::Invite] The invite.
|
259
|
+
# @return [Async::Task<Discorb::Invite>] The invite.
|
262
260
|
#
|
263
261
|
def fetch_invite(code, with_count: false, with_expiration: false)
|
264
262
|
Async do
|
@@ -275,7 +273,7 @@ module Discorb
|
|
275
273
|
#
|
276
274
|
# @param [Boolean] force Whether to force the fetch.
|
277
275
|
#
|
278
|
-
# @return [Discorb::Application] The application.
|
276
|
+
# @return [Async::Task<Discorb::Application>] The application.
|
279
277
|
#
|
280
278
|
def fetch_application(force: false)
|
281
279
|
Async do
|
@@ -292,7 +290,7 @@ module Discorb
|
|
292
290
|
# @macro async
|
293
291
|
# @macro http
|
294
292
|
#
|
295
|
-
# @return [Array<Discorb::Sticker::Pack
|
293
|
+
# @return [Async::Task<Array<Discorb::Sticker::Pack>>] The packs.
|
296
294
|
#
|
297
295
|
def fetch_nitro_sticker_packs
|
298
296
|
Async do
|
@@ -369,10 +367,11 @@ module Discorb
|
|
369
367
|
def extend(mod)
|
370
368
|
if mod.respond_to?(:events)
|
371
369
|
@events.each_value do |event|
|
372
|
-
event.delete_if { |c| c.
|
370
|
+
event.delete_if { |c| c.metadata[:extension] == mod.name }
|
373
371
|
end
|
374
372
|
mod.events.each do |name, events|
|
375
|
-
@events[name]
|
373
|
+
@events[name] ||= []
|
374
|
+
@events[name].delete_if { |c| c.metadata[:override] }
|
376
375
|
events.each do |event|
|
377
376
|
@events[name] << event
|
378
377
|
end
|
@@ -391,16 +390,20 @@ module Discorb
|
|
391
390
|
end
|
392
391
|
|
393
392
|
include Discorb::Gateway::Handler
|
394
|
-
include Discorb::
|
393
|
+
include Discorb::ApplicationCommand::Handler
|
395
394
|
|
396
395
|
#
|
397
396
|
# Starts the client.
|
398
397
|
# @note This method behavior will change by CLI.
|
399
398
|
# @see file:docs/cli.md
|
400
399
|
#
|
401
|
-
# @param [String] token The token to use.
|
400
|
+
# @param [String, nil] token The token to use.
|
402
401
|
#
|
403
|
-
|
402
|
+
# @note If the token is nil, you should use `discorb run` with the `-t` or `--token` option.
|
403
|
+
#
|
404
|
+
def run(token = nil)
|
405
|
+
token ||= ENV["DISCORB_CLI_TOKEN"]
|
406
|
+
raise ArgumentError, "Token is not specified, and -t/--token is not specified" if token.nil?
|
404
407
|
case ENV["DISCORB_CLI_FLAG"]
|
405
408
|
when nil
|
406
409
|
start_client(token)
|
@@ -436,7 +439,14 @@ module Discorb
|
|
436
439
|
end
|
437
440
|
start_client(token)
|
438
441
|
when "setup"
|
439
|
-
|
442
|
+
guild_ids = "global"
|
443
|
+
if guilds = ENV["DISCORB_SETUP_GUILDS"]
|
444
|
+
guild_ids = guilds.split(",")
|
445
|
+
end
|
446
|
+
if guild_ids == ["global"]
|
447
|
+
guild_ids = false
|
448
|
+
end
|
449
|
+
setup_commands(token, guild_ids: guild_ids).wait
|
440
450
|
end
|
441
451
|
end
|
442
452
|
|
@@ -460,7 +470,7 @@ module Discorb
|
|
460
470
|
}
|
461
471
|
@token = token.to_s
|
462
472
|
@close_condition = Async::Condition.new
|
463
|
-
main_task = Async do
|
473
|
+
@main_task = Async do
|
464
474
|
@status = :running
|
465
475
|
connect_gateway(true).wait
|
466
476
|
rescue
|
@@ -469,7 +479,7 @@ module Discorb
|
|
469
479
|
raise
|
470
480
|
end
|
471
481
|
@close_condition.wait
|
472
|
-
main_task.stop
|
482
|
+
@main_task.stop
|
473
483
|
end
|
474
484
|
end
|
475
485
|
end
|
data/lib/discorb/color.rb
CHANGED
@@ -130,35 +130,65 @@ module Discorb
|
|
130
130
|
#
|
131
131
|
# Create a color from a Discord's color.
|
132
132
|
# Currently these colors are supported:
|
133
|
-
#
|
134
|
-
#
|
135
|
-
#
|
136
|
-
#
|
137
|
-
#
|
138
|
-
#
|
139
|
-
#
|
140
|
-
#
|
141
|
-
#
|
142
|
-
#
|
143
|
-
#
|
144
|
-
#
|
145
|
-
#
|
146
|
-
#
|
147
|
-
#
|
148
|
-
#
|
149
|
-
#
|
150
|
-
#
|
151
|
-
#
|
152
|
-
#
|
153
|
-
#
|
154
|
-
#
|
155
|
-
#
|
156
|
-
#
|
157
|
-
#
|
158
|
-
#
|
159
|
-
#
|
160
|
-
#
|
161
|
-
#
|
133
|
+
# | Color Name | Hexadecimal |
|
134
|
+
# |------------|------------|
|
135
|
+
# | `:teal` | `#1abc9c` |
|
136
|
+
# | `:dark_teal` | `#11806a` |
|
137
|
+
# | `:green` | `#2ecc71` |
|
138
|
+
# | `:dark_green` | `#1f8b4c` |
|
139
|
+
# | `:blue` | `#3498db` |
|
140
|
+
# | `:dark_blue` | `#206694` |
|
141
|
+
# | `:purple` | `#9b59b6` |
|
142
|
+
# | `:dark_purple` | `#71368a` |
|
143
|
+
# | `:magenta` | `#e91e63` |
|
144
|
+
# | `:dark_magenta` | `#ad1457` |
|
145
|
+
# | `:gold` | `#f1c40f` |
|
146
|
+
# | `:dark_gold` | `#c27c0e` |
|
147
|
+
# | `:orange` | `#e67e22` |
|
148
|
+
# | `:dark_orange` | `#a84300` |
|
149
|
+
# | `:red` | `#e74c3c` |
|
150
|
+
# | `:dark_red` | `#992d22` |
|
151
|
+
# | `:lighter_grey` | `#95a5a6` |
|
152
|
+
# | `:lighter_gray` | `#95a5a6` |
|
153
|
+
# | `:dark_grey` | `#607d8b` |
|
154
|
+
# | `:dark_gray` | `#607d8b` |
|
155
|
+
# | `:light_grey` | `#979c9f` |
|
156
|
+
# | `:light_gray` | `#979c9f` |
|
157
|
+
# | `:darker_grey` | `#546e7a` |
|
158
|
+
# | `:darker_gray` | `#546e7a` |
|
159
|
+
# | `:og_blurple` | `#7289da` |
|
160
|
+
# | `:blurple` | `#5865f2` |
|
161
|
+
# | `:greyple` | `#99aab5` |
|
162
|
+
# | `:dark_theme` | `#36393f` |
|
163
|
+
# | `:fuchsia` | `#eb459e` |
|
164
|
+
# | `:dark_teal` | `#11806a` |
|
165
|
+
# | `:green` | `#2ecc71` |
|
166
|
+
# | `:dark_green` | `#1f8b4c` |
|
167
|
+
# | `:blue` | `#3498db` |
|
168
|
+
# | `:dark_blue` | `#206694` |
|
169
|
+
# | `:purple` | `#9b59b6` |
|
170
|
+
# | `:dark_purple` | `#71368a` |
|
171
|
+
# | `:magenta` | `#e91e63` |
|
172
|
+
# | `:dark_magenta` | `#ad1457` |
|
173
|
+
# | `:gold` | `#f1c40f` |
|
174
|
+
# | `:dark_gold` | `#c27c0e` |
|
175
|
+
# | `:orange` | `#e67e22` |
|
176
|
+
# | `:dark_orange` | `#a84300` |
|
177
|
+
# | `:red` | `#e74c3c` |
|
178
|
+
# | `:dark_red` | `#992d22` |
|
179
|
+
# | `:lighter_grey` | `#95a5a6` |
|
180
|
+
# | `:lighter_gray` | `#95a5a6` |
|
181
|
+
# | `:dark_grey` | `#607d8b` |
|
182
|
+
# | `:dark_gray` | `#607d8b` |
|
183
|
+
# | `:light_grey` | `#979c9f` |
|
184
|
+
# | `:light_gray` | `#979c9f` |
|
185
|
+
# | `:darker_grey` | `#546e7a` |
|
186
|
+
# | `:darker_gray` | `#546e7a` |
|
187
|
+
# | `:og_blurple` | `#7289da` |
|
188
|
+
# | `:blurple` | `#5865f2` |
|
189
|
+
# | `:greyple` | `#99aab5` |
|
190
|
+
# | `:dark_theme` | `#36393f` |
|
191
|
+
# | `:fuchsia` | `#eb459e` |
|
162
192
|
#
|
163
193
|
# @param [Symbol] color A Discord color name.
|
164
194
|
#
|
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.
|
7
|
+
VERSION = "0.6.1"
|
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/embed.rb
CHANGED
@@ -65,9 +65,9 @@ module Discorb
|
|
65
65
|
@timestamp = data[:timestamp] && Time.iso8601(data[:timestamp])
|
66
66
|
@type = data[:type]
|
67
67
|
@color = data[:color] && Color.new(data[:color])
|
68
|
-
@footer = data[:footer] && Footer.new(data[:footer][:text], icon: data[:footer][:
|
68
|
+
@footer = data[:footer] && Footer.new(data[:footer][:text], icon: data[:footer][:icon_url])
|
69
69
|
@author = if data[:author]
|
70
|
-
Author.new(data[:author][:name], icon: data[:author][:
|
70
|
+
Author.new(data[:author][:name], icon: data[:author][:icon_url],
|
71
71
|
url: data[:author][:url])
|
72
72
|
end
|
73
73
|
@thumbnail = data[:thumbnail] && Thumbnail.new(data[:thumbnail])
|
data/lib/discorb/emoji.rb
CHANGED
@@ -6,6 +6,13 @@ module Discorb
|
|
6
6
|
# Represents a Discord emoji.
|
7
7
|
# @abstract
|
8
8
|
class Emoji
|
9
|
+
def eql?(other)
|
10
|
+
other.is_a?(self.class) && other.to_uri == to_uri
|
11
|
+
end
|
12
|
+
|
13
|
+
def ==(other)
|
14
|
+
eql?(other)
|
15
|
+
end
|
9
16
|
end
|
10
17
|
|
11
18
|
# Represents a custom emoji in discord.
|
@@ -79,7 +86,7 @@ module Discorb
|
|
79
86
|
# @param [Array<Discorb::Role>] roles The new roles that can use this emoji.
|
80
87
|
# @param [String] reason The reason for editing the emoji.
|
81
88
|
#
|
82
|
-
# @return [self] The edited emoji.
|
89
|
+
# @return [Async::Task<self>] The edited emoji.
|
83
90
|
#
|
84
91
|
def edit(name: :unset, roles: :unset, reason: nil)
|
85
92
|
Async do
|
@@ -100,7 +107,7 @@ module Discorb
|
|
100
107
|
#
|
101
108
|
# @param [String] reason The reason for deleting the emoji.
|
102
109
|
#
|
103
|
-
# @return [self] The deleted emoji.
|
110
|
+
# @return [Async::Task<self>] The deleted emoji.
|
104
111
|
#
|
105
112
|
def delete!(reason: nil)
|
106
113
|
Async do
|