discorb 0.9.1 → 0.9.6
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 +2 -0
- data/Changelog.md +30 -1
- data/README.md +6 -6
- data/Rakefile +7 -1
- data/assets/banner.svg +101 -101
- data/docs/application_command.md +8 -7
- data/docs/cli/run.md +3 -3
- data/docs/faq.md +1 -1
- data/docs/license.md +1 -1
- data/lib/discorb/app_command.rb +12 -10
- data/lib/discorb/application.rb +3 -3
- data/lib/discorb/asset.rb +2 -2
- data/lib/discorb/audit_logs.rb +7 -7
- data/lib/discorb/channel.rb +10 -10
- data/lib/discorb/common.rb +3 -3
- data/lib/discorb/components.rb +30 -2
- data/lib/discorb/embed.rb +2 -2
- data/lib/discorb/emoji.rb +3 -3
- data/lib/discorb/error.rb +2 -2
- data/lib/discorb/exe/init.rb +8 -8
- data/lib/discorb/exe/run.rb +1 -1
- data/lib/discorb/extend.rb +21 -0
- data/lib/discorb/extension.rb +1 -1
- data/lib/discorb/file.rb +19 -1
- data/lib/discorb/gateway.rb +9 -11
- data/lib/discorb/gateway_requests.rb +1 -1
- data/lib/discorb/guild.rb +7 -7
- data/lib/discorb/guild_template.rb +4 -4
- data/lib/discorb/http.rb +1 -1
- data/lib/discorb/integration.rb +3 -3
- data/lib/discorb/interaction.rb +108 -37
- data/lib/discorb/invite.rb +2 -2
- data/lib/discorb/log.rb +1 -1
- data/lib/discorb/member.rb +1 -1
- data/lib/discorb/message.rb +34 -10
- data/lib/discorb/modules.rb +15 -49
- data/lib/discorb/permission.rb +2 -2
- data/lib/discorb/presence.rb +8 -8
- data/lib/discorb/rate_limit.rb +1 -1
- data/lib/discorb/reaction.rb +1 -1
- data/lib/discorb/role.rb +2 -2
- data/lib/discorb/sticker.rb +3 -3
- data/lib/discorb/user.rb +2 -2
- data/lib/discorb/utils/colored_puts.rb +3 -3
- data/lib/discorb/utils.rb +1 -1
- data/lib/discorb/voice_state.rb +3 -3
- data/lib/discorb/webhook.rb +7 -8
- data/lib/discorb.rb +1 -1
- data/sig/discorb.rbs +2 -2
- data/template-replace/files/css/common.css +25 -0
- data/template-replace/files/favicon.png +0 -0
- data/template-replace/scripts/arrow.rb +7 -0
- data/template-replace/scripts/favicon.rb +9 -0
- metadata +5 -2
data/lib/discorb/interaction.rb
CHANGED
@@ -33,7 +33,7 @@ module Discorb
|
|
33
33
|
@interaction_type = nil
|
34
34
|
@interaction_name = nil
|
35
35
|
|
36
|
-
#
|
36
|
+
# @private
|
37
37
|
def initialize(client, data)
|
38
38
|
@client = client
|
39
39
|
@id = Snowflake.new(data[:id])
|
@@ -71,10 +71,10 @@ module Discorb
|
|
71
71
|
end
|
72
72
|
|
73
73
|
class << self
|
74
|
-
#
|
74
|
+
# @private
|
75
75
|
attr_reader :interaction_type, :interaction_name, :event_name
|
76
76
|
|
77
|
-
#
|
77
|
+
# @private
|
78
78
|
def make_interaction(client, data)
|
79
79
|
interaction = nil
|
80
80
|
descendants.each do |klass|
|
@@ -87,7 +87,7 @@ module Discorb
|
|
87
87
|
interaction
|
88
88
|
end
|
89
89
|
|
90
|
-
#
|
90
|
+
# @private
|
91
91
|
def descendants
|
92
92
|
ObjectSpace.each_object(Class).select { |klass| klass < self }
|
93
93
|
end
|
@@ -131,6 +131,8 @@ module Discorb
|
|
131
131
|
# @param [Array<Discorb::Component>, Array<Array<Discorb::Component>>] components The components to send.
|
132
132
|
# @param [Boolean] ephemeral Whether to make the response ephemeral.
|
133
133
|
#
|
134
|
+
# @return [Discorb::Interaction::SourceResponse::CallbackMessage, Discorb::Webhook::Message] The callback message.
|
135
|
+
#
|
134
136
|
def post(content = nil, tts: false, embed: nil, embeds: nil, allowed_mentions: nil, components: nil, ephemeral: false)
|
135
137
|
Async do
|
136
138
|
payload = {}
|
@@ -165,14 +167,78 @@ module Discorb
|
|
165
167
|
end
|
166
168
|
payload[:flags] = (ephemeral ? 1 << 6 : 0)
|
167
169
|
|
168
|
-
if @responded
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
170
|
+
ret = if @responded
|
171
|
+
_resp, data = @client.http.post("/webhooks/#{@application_id}/#{@token}", payload).wait
|
172
|
+
webhook = Webhook::URLWebhook.new("/webhooks/#{@application_id}/#{@token}")
|
173
|
+
Webhook::Message.new(webhook, data, @client)
|
174
|
+
elsif @defered
|
175
|
+
@client.http.patch("/webhooks/#{@application_id}/#{@token}/messages/@original", payload).wait
|
176
|
+
CallbackMessage.new(@client, payload, @application_id, @token)
|
177
|
+
else
|
178
|
+
@client.http.post("/interactions/#{@id}/#{@token}/callback", { type: 4, data: payload }).wait
|
179
|
+
CallbackMessage.new(@client, payload, @application_id, @token)
|
180
|
+
end
|
175
181
|
@responded = true
|
182
|
+
ret
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
class CallbackMessage
|
187
|
+
# @private
|
188
|
+
def initialize(client, data, application_id, token)
|
189
|
+
@client = client
|
190
|
+
@data = data
|
191
|
+
@application_id = application_id
|
192
|
+
@token = token
|
193
|
+
end
|
194
|
+
|
195
|
+
#
|
196
|
+
# Edits the callback message.
|
197
|
+
# @macro async
|
198
|
+
# @macro http
|
199
|
+
# @macro edit
|
200
|
+
#
|
201
|
+
# @param [String] content The new content of the message.
|
202
|
+
# @param [Discorb::Embed] embed The new embed of the message.
|
203
|
+
# @param [Array<Discorb::Embed>] embeds The new embeds of the message.
|
204
|
+
# @param [Array<Discorb::Attachment>] attachments The attachments to remain.
|
205
|
+
# @param [Discorb::File] file The file to send.
|
206
|
+
# @param [Array<Discorb::File>] files The files to send.
|
207
|
+
#
|
208
|
+
def edit(
|
209
|
+
content = :unset,
|
210
|
+
embed: :unset, embeds: :unset,
|
211
|
+
file: :unset, files: :unset,
|
212
|
+
attachments: :unset
|
213
|
+
)
|
214
|
+
Async do
|
215
|
+
payload = {}
|
216
|
+
payload[:content] = content if content != :unset
|
217
|
+
payload[:embeds] = embed ? [embed.to_hash] : [] if embed != :unset
|
218
|
+
payload[:embeds] = embeds.map(&:to_hash) if embeds != :unset
|
219
|
+
payload[:attachments] = attachments.map(&:to_hash) if attachments != :unset
|
220
|
+
files = [file] if file != :unset
|
221
|
+
if files == :unset
|
222
|
+
headers = {
|
223
|
+
"Content-Type" => "application/json",
|
224
|
+
}
|
225
|
+
else
|
226
|
+
headers, payload = HTTP.multipart(payload, files)
|
227
|
+
end
|
228
|
+
@client.http.patch("/webhooks/#{@application_id}/#{@token}/messages/@original", payload, headers: headers).wait
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
alias modify edit
|
233
|
+
|
234
|
+
#
|
235
|
+
# Deletes the callback message.
|
236
|
+
# @note This will fail if the message is ephemeral.
|
237
|
+
#
|
238
|
+
def delete!
|
239
|
+
Async do
|
240
|
+
@client.http.delete("/webhooks/#{@application_id}/#{@token}/messages/@original").wait
|
241
|
+
end
|
176
242
|
end
|
177
243
|
end
|
178
244
|
end
|
@@ -189,7 +255,7 @@ module Discorb
|
|
189
255
|
def defer_update(ephemeral: false)
|
190
256
|
Async do
|
191
257
|
@client.http.post("/interactions/#{@id}/#{@token}/callback", {
|
192
|
-
type:
|
258
|
+
type: 6,
|
193
259
|
data: {
|
194
260
|
flags: (ephemeral ? 1 << 6 : 0),
|
195
261
|
},
|
@@ -244,7 +310,7 @@ module Discorb
|
|
244
310
|
payload[:components] = tmp_components.filter { |c| c.length.positive? }.map { |c| { type: 1, components: c.map(&:to_hash) } }
|
245
311
|
end
|
246
312
|
payload[:flags] = (ephemeral ? 1 << 6 : 0)
|
247
|
-
@client.http.post("/interactions/#{@id}/#{@token}/callback", { type:
|
313
|
+
@client.http.post("/interactions/#{@id}/#{@token}/callback", { type: 7, data: payload }).wait
|
248
314
|
end
|
249
315
|
end
|
250
316
|
end
|
@@ -296,28 +362,31 @@ module Discorb
|
|
296
362
|
options = data[:options]
|
297
363
|
end
|
298
364
|
end
|
299
|
-
options ||= []
|
300
|
-
options.map! do |option|
|
301
|
-
case option[:type]
|
302
|
-
when 3, 4, 5, 10
|
303
|
-
option[:value]
|
304
|
-
when 6
|
305
|
-
guild.members[option[:value]] || guild.fetch_member(option[:value]).wait
|
306
|
-
when 7
|
307
|
-
guild.channels[option[:value]] || guild.fetch_channels.wait.find { |channel| channel.id == option[:value] }
|
308
|
-
when 8
|
309
|
-
guild.roles[option[:value]] || guild.fetch_roles.wait.find { |role| role.id == option[:value] }
|
310
|
-
when 9
|
311
|
-
guild.members[option[:value]] || guild.roles[option[:value]] || guild.fetch_member(option[:value]).wait || guild.fetch_roles.wait.find { |role| role.id == option[:value] }
|
312
|
-
end
|
313
|
-
end
|
314
365
|
|
315
366
|
unless (command = @client.bottom_commands.find { |c| c.to_s == name && c.type_raw == 1 })
|
316
367
|
@client.log.warn "Unknown command name #{name}, ignoreing"
|
317
368
|
next
|
318
369
|
end
|
319
370
|
|
320
|
-
command.
|
371
|
+
option_map = command.options.map { |k, v| [k.to_s, v[:default]] }.to_h
|
372
|
+
options ||= []
|
373
|
+
options.each do |option|
|
374
|
+
val = case option[:type]
|
375
|
+
when 3, 4, 5, 10
|
376
|
+
option[:value]
|
377
|
+
when 6
|
378
|
+
guild.members[option[:value]] || guild.fetch_member(option[:value]).wait
|
379
|
+
when 7
|
380
|
+
guild.channels[option[:value]] || guild.fetch_channels.wait.find { |channel| channel.id == option[:value] }
|
381
|
+
when 8
|
382
|
+
guild.roles[option[:value]] || guild.fetch_roles.wait.find { |role| role.id == option[:value] }
|
383
|
+
when 9
|
384
|
+
guild.members[option[:value]] || guild.roles[option[:value]] || guild.fetch_member(option[:value]).wait || guild.fetch_roles.wait.find { |role| role.id == option[:value] }
|
385
|
+
end
|
386
|
+
option_map[option[:name]] = val
|
387
|
+
end
|
388
|
+
|
389
|
+
command.block.call(self, *command.options.map { |k, v| option_map[k.to_s] })
|
321
390
|
end
|
322
391
|
end
|
323
392
|
end
|
@@ -351,7 +420,7 @@ module Discorb
|
|
351
420
|
private
|
352
421
|
|
353
422
|
def _set_data(data)
|
354
|
-
@target = Message.new(@client, data[:resolved][:messages][data[:target_id].to_sym])
|
423
|
+
@target = Message.new(@client, data[:resolved][:messages][data[:target_id].to_sym].merge(guild_id: @guild_id.to_s))
|
355
424
|
@client.commands.find { |c| c.name == data[:name] && c.type_raw == 3 }.block.call(self, @target)
|
356
425
|
end
|
357
426
|
end
|
@@ -363,10 +432,10 @@ module Discorb
|
|
363
432
|
end
|
364
433
|
|
365
434
|
class << self
|
366
|
-
#
|
435
|
+
# @private
|
367
436
|
attr_reader :command_type
|
368
437
|
|
369
|
-
#
|
438
|
+
# @private
|
370
439
|
def make_interaction(client, data)
|
371
440
|
nested_classes.each do |klass|
|
372
441
|
return klass.new(client, data) if !klass.command_type.nil? && klass.command_type == data[:data][:type]
|
@@ -375,7 +444,7 @@ module Discorb
|
|
375
444
|
CommandInteraction.new(client, data)
|
376
445
|
end
|
377
446
|
|
378
|
-
#
|
447
|
+
# @private
|
379
448
|
def nested_classes
|
380
449
|
constants.select { |c| const_get(c).is_a? Class }.map { |c| const_get(c) }
|
381
450
|
end
|
@@ -391,21 +460,23 @@ module Discorb
|
|
391
460
|
include Interaction::UpdateResponse
|
392
461
|
# @return [String] The content of the response.
|
393
462
|
attr_reader :custom_id
|
463
|
+
# @return [Discorb::Message] The target message.
|
464
|
+
attr_reader :message
|
394
465
|
|
395
466
|
@interaction_type = 3
|
396
467
|
@interaction_name = :message_component
|
397
468
|
|
398
|
-
#
|
469
|
+
# @private
|
399
470
|
def initialize(client, data)
|
400
471
|
super
|
401
472
|
@message = Message.new(@client, data[:message].merge({ member: data[:member] }))
|
402
473
|
end
|
403
474
|
|
404
475
|
class << self
|
405
|
-
#
|
476
|
+
# @private
|
406
477
|
attr_reader :component_type
|
407
478
|
|
408
|
-
#
|
479
|
+
# @private
|
409
480
|
def make_interaction(client, data)
|
410
481
|
nested_classes.each do |klass|
|
411
482
|
return klass.new(client, data) if !klass.component_type.nil? && klass.component_type == data[:data][:component_type]
|
@@ -414,7 +485,7 @@ module Discorb
|
|
414
485
|
MessageComponentInteraction.new(client, data)
|
415
486
|
end
|
416
487
|
|
417
|
-
#
|
488
|
+
# @private
|
418
489
|
def nested_classes
|
419
490
|
constants.select { |c| const_get(c).is_a? Class }.map { |c| const_get(c) }
|
420
491
|
end
|
data/lib/discorb/invite.rb
CHANGED
@@ -72,7 +72,7 @@ module Discorb
|
|
72
72
|
2 => :guild,
|
73
73
|
}.freeze
|
74
74
|
|
75
|
-
#
|
75
|
+
# @private
|
76
76
|
def initialize(client, data, gateway)
|
77
77
|
@client = client
|
78
78
|
@data = data[:data]
|
@@ -138,7 +138,7 @@ module Discorb
|
|
138
138
|
end
|
139
139
|
|
140
140
|
class << self
|
141
|
-
#
|
141
|
+
# @private
|
142
142
|
attr_reader :target_types
|
143
143
|
end
|
144
144
|
end
|
data/lib/discorb/log.rb
CHANGED
data/lib/discorb/member.rb
CHANGED
data/lib/discorb/message.rb
CHANGED
@@ -29,7 +29,7 @@ module Discorb
|
|
29
29
|
@replied_user = replied_user
|
30
30
|
end
|
31
31
|
|
32
|
-
#
|
32
|
+
# @private
|
33
33
|
def to_hash(other = nil)
|
34
34
|
payload = {
|
35
35
|
parse: %w[everyone roles users],
|
@@ -183,8 +183,32 @@ module Discorb
|
|
183
183
|
# @!attribute [r] embed
|
184
184
|
# @return [Discorb::Embed] The embed of the message.
|
185
185
|
# @return [nil] If the message has no embed.
|
186
|
+
# @!attribute [r] embed?
|
187
|
+
# @return [Boolean] Whether the message has an embed.
|
188
|
+
# @!attribute [r] reply?
|
189
|
+
# @return [Boolean] Whether the message is a reply.
|
190
|
+
# @!attribute [r] dm?
|
191
|
+
# @return [Boolean] Whether the message was sent in a DM.
|
192
|
+
# @!attribute [r] guild?
|
193
|
+
# @return [Boolean] Whether the message was sent in a guild.
|
194
|
+
|
195
|
+
def embed?
|
196
|
+
@embeds.any?
|
197
|
+
end
|
198
|
+
|
199
|
+
def reply?
|
200
|
+
!@message_reference.nil?
|
201
|
+
end
|
202
|
+
|
203
|
+
def dm?
|
204
|
+
@guild_id.nil?
|
205
|
+
end
|
206
|
+
|
207
|
+
def guild?
|
208
|
+
!@guild_id.nil?
|
209
|
+
end
|
186
210
|
|
187
|
-
#
|
211
|
+
# @private
|
188
212
|
def initialize(client, data, no_cache: false)
|
189
213
|
@client = client
|
190
214
|
@data = {}
|
@@ -272,11 +296,11 @@ module Discorb
|
|
272
296
|
# @param [Array<Discorb::Component>, Array<Array<Discorb::Component>>] components The components to send.
|
273
297
|
# @param [Boolean] supress Whether to supress embeds.
|
274
298
|
#
|
275
|
-
def edit(
|
276
|
-
|
299
|
+
def edit(content = nil, embed: nil, embeds: nil, allowed_mentions: nil,
|
300
|
+
components: nil, supress: nil)
|
277
301
|
Async do
|
278
|
-
channel.edit_message(@id,
|
279
|
-
|
302
|
+
channel.edit_message(@id, content, embed: embed, embeds: embeds, allowed_mentions: allowed_mentions,
|
303
|
+
components: components, supress: supress).wait
|
280
304
|
end
|
281
305
|
end
|
282
306
|
|
@@ -616,7 +640,7 @@ module Discorb
|
|
616
640
|
# @return [Discorb::User] The user.
|
617
641
|
attr_reader :user
|
618
642
|
|
619
|
-
#
|
643
|
+
# @private
|
620
644
|
def initialize(client, data)
|
621
645
|
@id = Snowflake.new(data[:id])
|
622
646
|
@name = data[:name]
|
@@ -641,20 +665,20 @@ module Discorb
|
|
641
665
|
5 => :join_request,
|
642
666
|
}
|
643
667
|
|
644
|
-
#
|
668
|
+
# @private
|
645
669
|
def initialize(data)
|
646
670
|
@name = data[:name]
|
647
671
|
@type = self.class.type(data[:type])
|
648
672
|
end
|
649
673
|
|
650
674
|
class << self
|
651
|
-
#
|
675
|
+
# @private
|
652
676
|
attr_reader :type
|
653
677
|
end
|
654
678
|
end
|
655
679
|
|
656
680
|
class << self
|
657
|
-
#
|
681
|
+
# @private
|
658
682
|
attr_reader :message_type
|
659
683
|
end
|
660
684
|
end
|
data/lib/discorb/modules.rb
CHANGED
@@ -37,26 +37,7 @@ module Discorb
|
|
37
37
|
payload[:allowed_mentions] =
|
38
38
|
allowed_mentions ? allowed_mentions.to_hash(@client.allowed_mentions) : @client.allowed_mentions.to_hash
|
39
39
|
payload[:message_reference] = reference.to_reference if reference
|
40
|
-
if components
|
41
|
-
tmp_components = []
|
42
|
-
tmp_row = []
|
43
|
-
components.each do |c|
|
44
|
-
case c
|
45
|
-
when Array
|
46
|
-
tmp_components << tmp_row
|
47
|
-
tmp_row = []
|
48
|
-
tmp_components << c
|
49
|
-
when SelectMenu
|
50
|
-
tmp_components << tmp_row
|
51
|
-
tmp_row = []
|
52
|
-
tmp_components << [c]
|
53
|
-
else
|
54
|
-
tmp_row << c
|
55
|
-
end
|
56
|
-
end
|
57
|
-
tmp_components << tmp_row
|
58
|
-
payload[:components] = tmp_components.filter { |c| c.length.positive? }.map { |c| { type: 1, components: c.map(&:to_hash) } }
|
59
|
-
end
|
40
|
+
payload[:components] = Component.to_payload(components) if components
|
60
41
|
files = [file] if file
|
61
42
|
if files
|
62
43
|
seperator, payload = HTTP.multipart(payload, files)
|
@@ -69,6 +50,8 @@ module Discorb
|
|
69
50
|
end
|
70
51
|
end
|
71
52
|
|
53
|
+
alias send_message post
|
54
|
+
|
72
55
|
#
|
73
56
|
# Edit a message.
|
74
57
|
# @macro async
|
@@ -95,27 +78,8 @@ module Discorb
|
|
95
78
|
payload[:embeds] = tmp_embed.map(&:to_hash) if tmp_embed
|
96
79
|
payload[:allowed_mentions] =
|
97
80
|
allowed_mentions ? allowed_mentions.to_hash(@client.allowed_mentions) : @client.allowed_mentions.to_hash
|
98
|
-
if components
|
99
|
-
|
100
|
-
tmp_row = []
|
101
|
-
components.each do |c|
|
102
|
-
case c
|
103
|
-
when Array
|
104
|
-
tmp_components << tmp_row
|
105
|
-
tmp_row = []
|
106
|
-
tmp_components << c
|
107
|
-
when SelectMenu
|
108
|
-
tmp_components << tmp_row
|
109
|
-
tmp_row = []
|
110
|
-
tmp_components << [c]
|
111
|
-
else
|
112
|
-
tmp_row << c
|
113
|
-
end
|
114
|
-
end
|
115
|
-
tmp_components << tmp_row
|
116
|
-
payload[:flags] = (supress ? 1 << 2 : 0) unless flags.nil?
|
117
|
-
payload[:components] = tmp_components.filter { |c| c.length.positive? }.map { |c| { type: 1, components: c.map(&:to_hash) } }
|
118
|
-
end
|
81
|
+
payload[:components] = Component.to_payload(components) if components
|
82
|
+
payload[:flags] = (supress ? 1 << 2 : 0) unless supress.nil?
|
119
83
|
@client.http.patch("/channels/#{channel_id.wait}/messages/#{message_id}", payload).wait
|
120
84
|
end
|
121
85
|
end
|
@@ -192,18 +156,20 @@ module Discorb
|
|
192
156
|
# end
|
193
157
|
#
|
194
158
|
def typing
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
159
|
+
if block_given?
|
160
|
+
begin
|
161
|
+
post_task = Async do
|
162
|
+
loop do
|
199
163
|
@client.http.post("/channels/#{@id}/typing", {})
|
200
164
|
sleep(5)
|
201
165
|
end
|
202
|
-
yield
|
203
|
-
ensure
|
204
|
-
post_task.stop
|
205
166
|
end
|
206
|
-
|
167
|
+
yield
|
168
|
+
ensure
|
169
|
+
post_task.stop
|
170
|
+
end
|
171
|
+
else
|
172
|
+
Async do |task|
|
207
173
|
@client.http.post("/channels/#{@id}/typing", {})
|
208
174
|
end
|
209
175
|
end
|
data/lib/discorb/permission.rb
CHANGED
@@ -138,7 +138,7 @@ module Discorb
|
|
138
138
|
}.freeze
|
139
139
|
@bits = @raw_bits.transform_values { |v| 1 << v }.freeze
|
140
140
|
|
141
|
-
#
|
141
|
+
# @private
|
142
142
|
def initialize(allow, deny)
|
143
143
|
@allow = allow
|
144
144
|
@deny = deny
|
@@ -248,7 +248,7 @@ module Discorb
|
|
248
248
|
end
|
249
249
|
|
250
250
|
class << self
|
251
|
-
#
|
251
|
+
# @private
|
252
252
|
attr_reader :bits
|
253
253
|
|
254
254
|
#
|
data/lib/discorb/presence.rb
CHANGED
@@ -19,7 +19,7 @@ module Discorb
|
|
19
19
|
# @!attribute [r] activity
|
20
20
|
# @return [Discorb::Presence::Activity] The activity of the presence.
|
21
21
|
|
22
|
-
#
|
22
|
+
# @private
|
23
23
|
def initialize(client, data)
|
24
24
|
@client = client
|
25
25
|
@data = data
|
@@ -89,7 +89,7 @@ module Discorb
|
|
89
89
|
5 => :competing,
|
90
90
|
}
|
91
91
|
|
92
|
-
#
|
92
|
+
# @private
|
93
93
|
def initialize(data)
|
94
94
|
@name = data[:name]
|
95
95
|
@type = self.class.activity_types[data[:type]]
|
@@ -140,7 +140,7 @@ module Discorb
|
|
140
140
|
# @return [Time] The end time of the activity.
|
141
141
|
attr_reader :end
|
142
142
|
|
143
|
-
#
|
143
|
+
# @private
|
144
144
|
def initialize(data)
|
145
145
|
@start = data[:start] && Time.at(data[:start])
|
146
146
|
@end = data[:end] && Time.at(data[:end])
|
@@ -156,7 +156,7 @@ module Discorb
|
|
156
156
|
# @!attribute [r] max_size
|
157
157
|
# @return [Integer] The max size of the party.
|
158
158
|
|
159
|
-
#
|
159
|
+
# @private
|
160
160
|
def initialize(data)
|
161
161
|
@id = data[:id]
|
162
162
|
@size = data[:size]
|
@@ -226,7 +226,7 @@ module Discorb
|
|
226
226
|
# @return [String] The match secret of the activity.
|
227
227
|
attr_reader :match
|
228
228
|
|
229
|
-
#
|
229
|
+
# @private
|
230
230
|
def initialize(data)
|
231
231
|
@join = data[:join]
|
232
232
|
@spectate = data[:spectate]
|
@@ -244,7 +244,7 @@ module Discorb
|
|
244
244
|
attr_reader :url
|
245
245
|
alias text label
|
246
246
|
|
247
|
-
#
|
247
|
+
# @private
|
248
248
|
def initialize(data)
|
249
249
|
@label = data[0]
|
250
250
|
@url = data[1]
|
@@ -252,7 +252,7 @@ module Discorb
|
|
252
252
|
end
|
253
253
|
|
254
254
|
class << self
|
255
|
-
#
|
255
|
+
# @private
|
256
256
|
attr_reader :activity_types
|
257
257
|
end
|
258
258
|
end
|
@@ -275,7 +275,7 @@ module Discorb
|
|
275
275
|
# @!attribute [r] web?
|
276
276
|
# @return [Boolean] Whether the user is not offline on web.
|
277
277
|
|
278
|
-
#
|
278
|
+
# @private
|
279
279
|
def initialize(data)
|
280
280
|
@desktop = data[:desktop]&.to_sym || :offline
|
281
281
|
@mobile = data[:mobile]&.to_sym || :offline
|
data/lib/discorb/rate_limit.rb
CHANGED
data/lib/discorb/reaction.rb
CHANGED
data/lib/discorb/role.rb
CHANGED
@@ -36,7 +36,7 @@ module Discorb
|
|
36
36
|
|
37
37
|
include Comparable
|
38
38
|
|
39
|
-
#
|
39
|
+
# @private
|
40
40
|
def initialize(client, guild, data)
|
41
41
|
@client = client
|
42
42
|
@guild = guild
|
@@ -154,7 +154,7 @@ module Discorb
|
|
154
154
|
# @!attribute [r] integration?
|
155
155
|
# @return [Boolean] Whether the role is an integration role.
|
156
156
|
|
157
|
-
#
|
157
|
+
# @private
|
158
158
|
def initialize(data)
|
159
159
|
@bot_id = Snowflake.new(data[:bot_id])
|
160
160
|
@integration_id = Snowflake.new(data[:integration_id])
|
data/lib/discorb/sticker.rb
CHANGED
@@ -38,7 +38,7 @@ module Discorb
|
|
38
38
|
2 => :apng,
|
39
39
|
3 => :lottie,
|
40
40
|
}
|
41
|
-
#
|
41
|
+
# @private
|
42
42
|
def initialize(client, data)
|
43
43
|
@client = client
|
44
44
|
_set_data(data)
|
@@ -116,7 +116,7 @@ module Discorb
|
|
116
116
|
# @return [Discorb::Asset] The banner of the pack.
|
117
117
|
attr_reader :banner
|
118
118
|
|
119
|
-
#
|
119
|
+
# @private
|
120
120
|
def initialize(client, data)
|
121
121
|
@client = client
|
122
122
|
@id = Snowflake.new(data[:id])
|
@@ -150,7 +150,7 @@ module Discorb
|
|
150
150
|
end
|
151
151
|
|
152
152
|
class << self
|
153
|
-
#
|
153
|
+
# @private
|
154
154
|
attr_reader :sticker_type, :sticker_format
|
155
155
|
end
|
156
156
|
end
|
data/lib/discorb/user.rb
CHANGED
@@ -26,7 +26,7 @@ module Discorb
|
|
26
26
|
|
27
27
|
include Discorb::Messageable
|
28
28
|
|
29
|
-
#
|
29
|
+
# @private
|
30
30
|
def initialize(client, data)
|
31
31
|
@client = client
|
32
32
|
@data = {}
|
@@ -73,7 +73,7 @@ module Discorb
|
|
73
73
|
|
74
74
|
alias app_owner? bot_owner?
|
75
75
|
|
76
|
-
#
|
76
|
+
# @private
|
77
77
|
def channel_id
|
78
78
|
Async do
|
79
79
|
next @dm_channel_id if @dm_channel_id
|
@@ -1,14 +1,14 @@
|
|
1
|
-
#
|
1
|
+
# @private
|
2
2
|
def sputs(text)
|
3
3
|
puts "\e[92m#{text}\e[m"
|
4
4
|
end
|
5
5
|
|
6
|
-
#
|
6
|
+
# @private
|
7
7
|
def eputs(text)
|
8
8
|
puts "\e[91m#{text}\e[m"
|
9
9
|
end
|
10
10
|
|
11
|
-
#
|
11
|
+
# @private
|
12
12
|
def iputs(text)
|
13
13
|
puts "\e[90m#{text}\e[m"
|
14
14
|
end
|