discorb 0.13.3 → 0.13.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CODE_OF_CONDUCT.md +128 -0
- data/Changelog.md +8 -0
- data/lib/discorb/app_command.rb +24 -2
- data/lib/discorb/channel.rb +42 -49
- data/lib/discorb/client.rb +7 -7
- data/lib/discorb/common.rb +30 -1
- data/lib/discorb/dictionary.rb +10 -2
- data/lib/discorb/emoji.rb +2 -2
- data/lib/discorb/event.rb +4 -4
- data/lib/discorb/gateway.rb +26 -5
- data/lib/discorb/guild.rb +47 -67
- data/lib/discorb/guild_template.rb +3 -3
- data/lib/discorb/http.rb +25 -158
- data/lib/discorb/integration.rb +1 -1
- data/lib/discorb/interaction/autocomplete.rb +1 -1
- data/lib/discorb/interaction/response.rb +8 -8
- data/lib/discorb/invite.rb +1 -1
- data/lib/discorb/log.rb +3 -2
- data/lib/discorb/member.rb +3 -3
- data/lib/discorb/message.rb +5 -5
- data/lib/discorb/modules.rb +10 -10
- data/lib/discorb/presence.rb +2 -2
- data/lib/discorb/rate_limit.rb +14 -18
- data/lib/discorb/role.rb +3 -3
- data/lib/discorb/sticker.rb +2 -2
- data/lib/discorb/user.rb +3 -3
- data/lib/discorb/voice_state.rb +4 -2
- data/lib/discorb/webhook.rb +8 -5
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45868a2fa9284bc0910bdad465983c490f44b721ccc49632df681e79e78fd727
|
4
|
+
data.tar.gz: 969d627479e5381da98e1775186e23f9a193244180135b8dc9396878a425ee43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2732b467bfc1ba6af2d6938b384026e5219bfce03ff646669870e311601ec7b0258a72ba1c4b6fd6c9a60d1c3186c3890842916bb2f387542cf1d2ee7fbafab3
|
7
|
+
data.tar.gz: a825f0d8497f8f62c024fa381441d9a19da54b0aa2fe71a7b87fc6ef17bc74f7e65a1681b6dc9c7abb1a2f746e6d821abaf4ae28ae6d9661226e7276dce2f551
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity
|
10
|
+
and orientation.
|
11
|
+
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
13
|
+
diverse, inclusive, and healthy community.
|
14
|
+
|
15
|
+
## Our Standards
|
16
|
+
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
18
|
+
community include:
|
19
|
+
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
24
|
+
and learning from the experience
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the
|
26
|
+
overall community
|
27
|
+
|
28
|
+
Examples of unacceptable behavior include:
|
29
|
+
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or
|
31
|
+
advances of any kind
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
33
|
+
* Public or private harassment
|
34
|
+
* Publishing others' private information, such as a physical or email
|
35
|
+
address, without their explicit permission
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
37
|
+
professional setting
|
38
|
+
|
39
|
+
## Enforcement Responsibilities
|
40
|
+
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
44
|
+
or harmful.
|
45
|
+
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
49
|
+
decisions when appropriate.
|
50
|
+
|
51
|
+
## Scope
|
52
|
+
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
54
|
+
an individual is officially representing the community in public spaces.
|
55
|
+
Examples of representing our community include using an official e-mail address,
|
56
|
+
posting via an official social media account, or acting as an appointed
|
57
|
+
representative at an online or offline event.
|
58
|
+
|
59
|
+
## Enforcement
|
60
|
+
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
62
|
+
reported to the community leaders responsible for enforcement at
|
63
|
+
Official Discord.
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
65
|
+
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
67
|
+
reporter of any incident.
|
68
|
+
|
69
|
+
## Enforcement Guidelines
|
70
|
+
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
73
|
+
|
74
|
+
### 1. Correction
|
75
|
+
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
77
|
+
unprofessional or unwelcome in the community.
|
78
|
+
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
82
|
+
|
83
|
+
### 2. Warning
|
84
|
+
|
85
|
+
**Community Impact**: A violation through a single incident or series
|
86
|
+
of actions.
|
87
|
+
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
92
|
+
like social media. Violating these terms may lead to a temporary or
|
93
|
+
permanent ban.
|
94
|
+
|
95
|
+
### 3. Temporary Ban
|
96
|
+
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
98
|
+
sustained inappropriate behavior.
|
99
|
+
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
101
|
+
communication with the community for a specified period of time. No public or
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
104
|
+
Violating these terms may lead to a permanent ban.
|
105
|
+
|
106
|
+
### 4. Permanent Ban
|
107
|
+
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
111
|
+
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within
|
113
|
+
the community.
|
114
|
+
|
115
|
+
## Attribution
|
116
|
+
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
118
|
+
version 2.0, available at
|
119
|
+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
120
|
+
|
121
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
122
|
+
enforcement ladder](https://github.com/mozilla/diversity).
|
123
|
+
|
124
|
+
[homepage]: https://www.contributor-covenant.org
|
125
|
+
|
126
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
127
|
+
https://www.contributor-covenant.org/faq. Translations are available at
|
128
|
+
https://www.contributor-covenant.org/translations.
|
data/Changelog.md
CHANGED
@@ -6,6 +6,14 @@
|
|
6
6
|
|
7
7
|
## v0.13
|
8
8
|
|
9
|
+
### v0.13.4
|
10
|
+
|
11
|
+
- Add: Show command on `discorb setup`
|
12
|
+
- Fix: Fix issue when logging in to file(#6, thanks `deanpcmad`)
|
13
|
+
- Fix: Fix rate limit handing
|
14
|
+
- Fix: Fix `Client#users`, it was always empty
|
15
|
+
- Fix: Fix sorting dictionary
|
16
|
+
|
9
17
|
### v0.13.3
|
10
18
|
|
11
19
|
- Fix: Fix INTEGRATION_xxx event
|
data/lib/discorb/app_command.rb
CHANGED
@@ -129,10 +129,32 @@ module Discorb
|
|
129
129
|
end
|
130
130
|
final_guild_ids = local_commands.map(&:guild_ids).flatten.map(&:to_s).uniq
|
131
131
|
app_info = fetch_application.wait
|
132
|
-
http.
|
132
|
+
@http.request(
|
133
|
+
Route.new(
|
134
|
+
"/applications/#{app_info.id}/commands",
|
135
|
+
"//applications/:application_id/commands",
|
136
|
+
:put
|
137
|
+
),
|
138
|
+
global_commands.map(&:to_hash)
|
139
|
+
).wait unless global_commands.empty?
|
140
|
+
if ENV["DISCORB_CLI_FLAG"] == "setup"
|
141
|
+
sputs "Registered commands for global:"
|
142
|
+
global_commands.each do |command|
|
143
|
+
iputs "- #{command.name}"
|
144
|
+
end
|
145
|
+
end
|
133
146
|
final_guild_ids.each do |guild_id|
|
134
147
|
commands = local_commands.select { |c| c.guild_ids.include?(guild_id) }
|
135
|
-
http.
|
148
|
+
@http.request(
|
149
|
+
Route.new("/applications/#{app_info.id}/guilds/#{guild_id}/commands",
|
150
|
+
"//applications/:application_id/guilds/:guild_id/commands",
|
151
|
+
:put),
|
152
|
+
commands.map(&:to_hash)
|
153
|
+
).wait
|
154
|
+
sputs "Registered commands for #{guild_id}:"
|
155
|
+
commands.each do |command|
|
156
|
+
iputs "- #{command.name}"
|
157
|
+
end
|
136
158
|
end unless final_guild_ids.empty?
|
137
159
|
@log.info "Successfully setup commands"
|
138
160
|
end
|
data/lib/discorb/channel.rb
CHANGED
@@ -174,7 +174,7 @@ module Discorb
|
|
174
174
|
#
|
175
175
|
def delete!(reason: nil)
|
176
176
|
Async do
|
177
|
-
@client.http.
|
177
|
+
@client.http.request(Route.new(base_url.wait.to_s, "//webhooks/:webhook_id/:token", :delete), audit_log_reason: reason).wait
|
178
178
|
@deleted = true
|
179
179
|
self
|
180
180
|
end
|
@@ -201,7 +201,7 @@ module Discorb
|
|
201
201
|
}
|
202
202
|
payload[:lock_permissions] = lock_permissions
|
203
203
|
payload[:parent_id] = parent&.id if parent != Discorb::Unset
|
204
|
-
@client.http.
|
204
|
+
@client.http.request(Route.new("/guilds/#{@guild_id}/channels", "//guilds/:guild_id/channels", :patch), payload, audit_log_reason: reason).wait
|
205
205
|
end
|
206
206
|
end
|
207
207
|
|
@@ -292,7 +292,7 @@ module Discorb
|
|
292
292
|
default_auto_archive_duration ||= archive_in
|
293
293
|
payload[:default_auto_archive_duration] = default_auto_archive_duration if default_auto_archive_duration != Discorb::Unset
|
294
294
|
|
295
|
-
@client.http.
|
295
|
+
@client.http.request(Route.new("/channels/#{@id}", "//channels/:channel_id", :patch), payload, audit_log_reason: reason).wait
|
296
296
|
self
|
297
297
|
end
|
298
298
|
end
|
@@ -313,7 +313,7 @@ module Discorb
|
|
313
313
|
payload = {}
|
314
314
|
payload[:name] = name
|
315
315
|
payload[:avatar] = avatar.to_s if avatar
|
316
|
-
_resp, data = @client.http.
|
316
|
+
_resp, data = @client.http.request(Route.new("/channels/#{@id}/webhooks", "//channels/:channel_id/webhooks", :post), payload).wait
|
317
317
|
Webhook.new([@client, data])
|
318
318
|
end
|
319
319
|
end
|
@@ -326,7 +326,7 @@ module Discorb
|
|
326
326
|
#
|
327
327
|
def fetch_webhooks
|
328
328
|
Async do
|
329
|
-
_resp, data = @client.http.
|
329
|
+
_resp, data = @client.http.request(Route.new("/channels/#{@id}/webhooks", "//channels/:channel_id/webhooks", :get)).wait
|
330
330
|
data.map { |webhook| Webhook.new([@client, webhook]) }
|
331
331
|
end
|
332
332
|
end
|
@@ -354,7 +354,7 @@ module Discorb
|
|
354
354
|
|
355
355
|
message_ids = messages.map { |m| Discorb::Utils.try(m, :id).to_s }
|
356
356
|
|
357
|
-
@client.http.
|
357
|
+
@client.http.request(Route.new("/channels/#{@id}/messages/bulk-delete", "//channels/:channel_id/messages/bulk-delete", :post), { messages: message_ids }).wait
|
358
358
|
end
|
359
359
|
end
|
360
360
|
|
@@ -384,7 +384,7 @@ module Discorb
|
|
384
384
|
deny: deny_value,
|
385
385
|
type: target.is_a?(Member) ? 1 : 0,
|
386
386
|
}
|
387
|
-
@client.http.
|
387
|
+
@client.http.request(Route.new("/channels/#{@id}/permissions/#{target.id}", "//channels/:channel_id/permissions/:target_id", :put), payload, audit_log_reason: reason).wait
|
388
388
|
end
|
389
389
|
end
|
390
390
|
|
@@ -404,7 +404,7 @@ module Discorb
|
|
404
404
|
#
|
405
405
|
def delete_permissions(target, reason: nil)
|
406
406
|
Async do
|
407
|
-
@client.http.
|
407
|
+
@client.http.request(Route.new("/channels/#{@id}/permissions/#{target.id}", "//channels/:channel_id/permissions/:target_id", :delete), audit_log_reason: reason).wait
|
408
408
|
end
|
409
409
|
end
|
410
410
|
|
@@ -420,7 +420,7 @@ module Discorb
|
|
420
420
|
#
|
421
421
|
def fetch_invites
|
422
422
|
Async do
|
423
|
-
_resp, data = @client.http.
|
423
|
+
_resp, data = @client.http.request(Route.new("/channels/#{@id}/invites", "//channels/:channel_id/invites", :get)).wait
|
424
424
|
data.map { |invite| Invite.new(@client, invite) }
|
425
425
|
end
|
426
426
|
end
|
@@ -440,7 +440,7 @@ module Discorb
|
|
440
440
|
#
|
441
441
|
def create_invite(max_age: nil, max_uses: nil, temporary: false, unique: false, reason: nil)
|
442
442
|
Async do
|
443
|
-
_resp, data = @client.http.
|
443
|
+
_resp, data = @client.http.request(Route.new("/channels/#{@id}/invites", "//channels/:channel_id/invites", :post), {
|
444
444
|
max_age: max_age,
|
445
445
|
max_uses: max_uses,
|
446
446
|
temporary: temporary,
|
@@ -461,7 +461,7 @@ module Discorb
|
|
461
461
|
#
|
462
462
|
def follow_from(target, reason: nil)
|
463
463
|
Async do
|
464
|
-
@client.http.
|
464
|
+
@client.http.request(Route.new("/channels/#{target.id}/followers", "//channels/:channel_id/followers", :post), { webhook_channel_id: @id }, audit_log_reason: reason).wait
|
465
465
|
end
|
466
466
|
end
|
467
467
|
|
@@ -476,7 +476,7 @@ module Discorb
|
|
476
476
|
#
|
477
477
|
def follow_to(target, reason: nil)
|
478
478
|
Async do
|
479
|
-
@client.http.
|
479
|
+
@client.http.request(Route.new("/channels/#{@id}/followers", "//channels/:channel_id/followers", :post), { webhook_channel_id: target.id }, audit_log_reason: reason).wait
|
480
480
|
end
|
481
481
|
end
|
482
482
|
|
@@ -497,17 +497,15 @@ module Discorb
|
|
497
497
|
def start_thread(name, message: nil, auto_archive_duration: 1440, public: true, rate_limit_per_user: nil, slowmode: nil, reason: nil)
|
498
498
|
Async do
|
499
499
|
_resp, data = if message.nil?
|
500
|
-
@client.http.post
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
audit_log_reason: reason,
|
508
|
-
).wait
|
500
|
+
@client.http.request(Route.new("/channels/#{@id}/threads", "//channels/:channel_id/threads", :post), {
|
501
|
+
name: name,
|
502
|
+
auto_archive_duration: auto_archive_duration,
|
503
|
+
type: public ? 11 : 10,
|
504
|
+
rate_limit_per_user: rate_limit_per_user || slowmode,
|
505
|
+
},
|
506
|
+
audit_log_reason: reason).wait
|
509
507
|
else
|
510
|
-
@client.http.
|
508
|
+
@client.http.request(Route.new("/channels/#{@id}/messages/#{Utils.try(message, :id)}/threads", "//channels/:channel_id/messages/:message_id/threads", :post), {
|
511
509
|
name: name, auto_archive_duration: auto_archive_duration,
|
512
510
|
}, audit_log_reason: reason).wait
|
513
511
|
end
|
@@ -525,7 +523,7 @@ module Discorb
|
|
525
523
|
#
|
526
524
|
def fetch_archived_public_threads
|
527
525
|
Async do
|
528
|
-
_resp, data = @client.http.
|
526
|
+
_resp, data = @client.http.request(Route.new("/channels/#{@id}/threads/archived/public", "//channels/:channel_id/threads/archived/public", :get)).wait
|
529
527
|
data.map { |thread| Channel.make_channel(@client, thread) }
|
530
528
|
end
|
531
529
|
end
|
@@ -538,7 +536,7 @@ module Discorb
|
|
538
536
|
#
|
539
537
|
def fetch_archived_private_threads
|
540
538
|
Async do
|
541
|
-
_resp, data = @client.http.
|
539
|
+
_resp, data = @client.http.request(Route.new("/channels/#{@id}/threads/archived/private", "//channels/:channel_id/threads/archived/private", :get)).wait
|
542
540
|
data.map { |thread| Channel.make_channel(@client, thread) }
|
543
541
|
end
|
544
542
|
end
|
@@ -558,7 +556,7 @@ module Discorb
|
|
558
556
|
before = 0
|
559
557
|
threads = []
|
560
558
|
loop do
|
561
|
-
_resp, data = @client.http.
|
559
|
+
_resp, data = @client.http.request(Route.new("/channels/#{@id}/users/@me/threads/archived/private?before=#{before}", "//channels/:channel_id/users/@me/threads/archived/private", :get)).wait
|
562
560
|
threads += data[:threads].map { |thread| Channel.make_channel(@client, thread) }
|
563
561
|
before = data[:threads][-1][:id]
|
564
562
|
|
@@ -566,7 +564,7 @@ module Discorb
|
|
566
564
|
end
|
567
565
|
threads
|
568
566
|
else
|
569
|
-
_resp, data = @client.http.
|
567
|
+
_resp, data = @client.http.request(Route.new("/channels/#{@id}/users/@me/threads/archived/private?limit=#{limit}&before=#{before}", "//channels/:channel_id/users/@me/threads/archived/private", :get)).wait
|
570
568
|
data.map { |thread| Channel.make_channel(@client, thread) }
|
571
569
|
end
|
572
570
|
end
|
@@ -634,7 +632,7 @@ module Discorb
|
|
634
632
|
payload[:user_limit] = user_limit if user_limit != Discorb::Unset
|
635
633
|
payload[:rtc_region] = rtc_region if rtc_region != Discorb::Unset
|
636
634
|
|
637
|
-
@client.http.
|
635
|
+
@client.http.request(Route.new("/channels/#{@id}", "//channels/:channel_id", :patch), payload, audit_log_reason: reason).wait
|
638
636
|
self
|
639
637
|
end
|
640
638
|
end
|
@@ -707,7 +705,7 @@ module Discorb
|
|
707
705
|
payload[:position] = position if position != Discorb::Unset
|
708
706
|
payload[:bitrate] = bitrate if bitrate != Discorb::Unset
|
709
707
|
payload[:rtc_region] = rtc_region if rtc_region != Discorb::Unset
|
710
|
-
@client.http.
|
708
|
+
@client.http.request(Route.new("/channels/#{@id}", "//channels/:channel_id", :patch), payload, audit_log_reason: reason).wait
|
711
709
|
self
|
712
710
|
end
|
713
711
|
end
|
@@ -726,7 +724,7 @@ module Discorb
|
|
726
724
|
#
|
727
725
|
def start(topic, public: false, reason: nil)
|
728
726
|
Async do
|
729
|
-
_resp, data = @client.http.
|
727
|
+
_resp, data = @client.http.request(Route.new("/stage-instances", "//stage-instances", :post), { channel_id: @id, topic: topic, public: public ? 2 : 1 }, audit_log_reason: reason).wait
|
730
728
|
StageInstance.new(@client, data)
|
731
729
|
end
|
732
730
|
end
|
@@ -740,7 +738,7 @@ module Discorb
|
|
740
738
|
#
|
741
739
|
def fetch_stage_instance
|
742
740
|
Async do
|
743
|
-
_resp, data = @client.http.
|
741
|
+
_resp, data = @client.http.request(Route.new("/stage-instances/#{@id}", "//stage-instances/:stage_instance_id", :get)).wait
|
744
742
|
rescue Discorb::NotFoundError
|
745
743
|
nil
|
746
744
|
else
|
@@ -863,7 +861,7 @@ module Discorb
|
|
863
861
|
auto_archive_duration ||= archive_in
|
864
862
|
payload[:auto_archive_duration] = auto_archive_duration if auto_archive_duration != Discorb::Unset
|
865
863
|
payload[:locked] = locked if locked != Discorb::Unset
|
866
|
-
@client.http.
|
864
|
+
@client.http.request(Route.new("/channels/#{@id}", "//channels/:channel_id", :patch), payload, audit_log_reason: reason).wait
|
867
865
|
self
|
868
866
|
end
|
869
867
|
end
|
@@ -952,9 +950,9 @@ module Discorb
|
|
952
950
|
def add_member(member = :me)
|
953
951
|
Async do
|
954
952
|
if member == :me
|
955
|
-
@client.http.
|
953
|
+
@client.http.request(Route.new("/channels/#{@id}/thread-members/@me", "//channels/:channel_id/thread-members/@me", :post)).wait
|
956
954
|
else
|
957
|
-
@client.http.
|
955
|
+
@client.http.request(Route.new("/channels/#{@id}/thread-members/#{Utils.try(member, :id)}", "//channels/:channel_id/thread-members/:user_id", :post)).wait
|
958
956
|
end
|
959
957
|
end
|
960
958
|
end
|
@@ -971,9 +969,9 @@ module Discorb
|
|
971
969
|
def remove_member(member = :me)
|
972
970
|
Async do
|
973
971
|
if member == :me
|
974
|
-
@client.http.
|
972
|
+
@client.http.request(Route.new("/channels/#{@id}/thread-members/@me", "//channels/:channel_id/thread-members/@me", :delete)).wait
|
975
973
|
else
|
976
|
-
@client.http.
|
974
|
+
@client.http.request(Route.new("/channels/#{@id}/thread-members/#{Utils.try(member, :id)}", "//channels/:channel_id/thread-members/:user_id", :delete)).wait
|
977
975
|
end
|
978
976
|
end
|
979
977
|
end
|
@@ -987,7 +985,7 @@ module Discorb
|
|
987
985
|
#
|
988
986
|
def fetch_members
|
989
987
|
Async do
|
990
|
-
_resp, data = @client.http.
|
988
|
+
_resp, data = @client.http.request(Route.new("/channels/#{@id}/thread-members", "//channels/:channel_id/thread-members", :get)).wait
|
991
989
|
data.map { |d| @members[d[:id]] = Member.new(@client, d) }
|
992
990
|
end
|
993
991
|
end
|
@@ -1062,24 +1060,26 @@ module Discorb
|
|
1062
1060
|
end
|
1063
1061
|
|
1064
1062
|
class CategoryChannel < GuildChannel
|
1065
|
-
attr_reader :channels
|
1066
|
-
|
1067
1063
|
@channel_type = 4
|
1068
1064
|
|
1065
|
+
def channels
|
1066
|
+
@client.channels.values.filter { |channel| channel.parent == self }
|
1067
|
+
end
|
1068
|
+
|
1069
1069
|
def text_channels
|
1070
|
-
|
1070
|
+
channels.filter { |c| c.is_a? TextChannel }
|
1071
1071
|
end
|
1072
1072
|
|
1073
1073
|
def voice_channels
|
1074
|
-
|
1074
|
+
channels.filter { |c| c.is_a? VoiceChannel }
|
1075
1075
|
end
|
1076
1076
|
|
1077
1077
|
def news_channel
|
1078
|
-
|
1078
|
+
channels.filter { |c| c.is_a? NewsChannel }
|
1079
1079
|
end
|
1080
1080
|
|
1081
1081
|
def stage_channels
|
1082
|
-
|
1082
|
+
channels.filter { |c| c.is_a? StageChannel }
|
1083
1083
|
end
|
1084
1084
|
|
1085
1085
|
def create_text_channel(*args, **kwargs)
|
@@ -1097,13 +1097,6 @@ module Discorb
|
|
1097
1097
|
def create_stage_channel(*args, **kwargs)
|
1098
1098
|
guild.create_stage_channel(*args, parent: self, **kwargs)
|
1099
1099
|
end
|
1100
|
-
|
1101
|
-
private
|
1102
|
-
|
1103
|
-
def _set_data(data)
|
1104
|
-
@channels = @client.channels.values.filter { |channel| channel.parent == self }
|
1105
|
-
super
|
1106
|
-
end
|
1107
1100
|
end
|
1108
1101
|
|
1109
1102
|
class DMChannel < Channel
|
data/lib/discorb/client.rb
CHANGED
@@ -63,7 +63,7 @@ module Discorb
|
|
63
63
|
# @param [Discorb::AllowedMentions] allowed_mentions The allowed mentions that the client is using.
|
64
64
|
# @param [Discorb::Intents] intents The intents that the client is currently using.
|
65
65
|
# @param [Integer] message_caches The number of messages to cache.
|
66
|
-
# @param [#
|
66
|
+
# @param [#write] log The IO object to use for logging.
|
67
67
|
# @param [Boolean] colorize_log Whether to colorize the log.
|
68
68
|
# @param [:debug, :info, :warn, :error, :critical] log_level The log level.
|
69
69
|
# @param [Boolean] wait_until_ready Whether to delay event dispatch until ready.
|
@@ -212,7 +212,7 @@ module Discorb
|
|
212
212
|
#
|
213
213
|
def fetch_user(id)
|
214
214
|
Async do
|
215
|
-
_resp, data = http.
|
215
|
+
_resp, data = @http.request(Route.new("/users/#{id}", "//users/:user_id", :get)).wait
|
216
216
|
User.new(self, data)
|
217
217
|
end
|
218
218
|
end
|
@@ -229,7 +229,7 @@ module Discorb
|
|
229
229
|
#
|
230
230
|
def fetch_channel(id)
|
231
231
|
Async do
|
232
|
-
_resp, data = http.
|
232
|
+
_resp, data = @http.request(Route.new("/channels/#{id}", "//channels/:channel_id", :get)).wait
|
233
233
|
Channel.make_channel(self, data)
|
234
234
|
end
|
235
235
|
end
|
@@ -246,7 +246,7 @@ module Discorb
|
|
246
246
|
#
|
247
247
|
def fetch_guild(id)
|
248
248
|
Async do
|
249
|
-
_resp, data = http.
|
249
|
+
_resp, data = @http.request(Route.new("/guilds/#{id}", "//guilds/:guild_id", :get)).wait
|
250
250
|
Guild.new(self, data, false)
|
251
251
|
end
|
252
252
|
end
|
@@ -263,7 +263,7 @@ module Discorb
|
|
263
263
|
#
|
264
264
|
def fetch_invite(code, with_count: false, with_expiration: false)
|
265
265
|
Async do
|
266
|
-
_resp, data = http.
|
266
|
+
_resp, data = @http.request(Route.new("/invites/#{code}?with_count=#{with_count}&with_expiration=#{with_expiration}", "//invites/:code", :get)).wait
|
267
267
|
Invite.new(self, data, false)
|
268
268
|
end
|
269
269
|
end
|
@@ -281,7 +281,7 @@ module Discorb
|
|
281
281
|
Async do
|
282
282
|
next @application if @application && !force
|
283
283
|
|
284
|
-
_resp, data = http.
|
284
|
+
_resp, data = @http.request(Route.new("/oauth2/applications/@me", "//oauth2/applications/@me", :get)).wait
|
285
285
|
@application = Application.new(self, data)
|
286
286
|
@application
|
287
287
|
end
|
@@ -295,7 +295,7 @@ module Discorb
|
|
295
295
|
#
|
296
296
|
def fetch_nitro_sticker_packs
|
297
297
|
Async do
|
298
|
-
_resp, data = http.
|
298
|
+
_resp, data = @http.request(Route.new("/stickers-packs", "//stickers-packs", :get)).wait
|
299
299
|
data.map { |pack| Sticker::Pack.new(self, pack) }
|
300
300
|
end
|
301
301
|
end
|
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.13.
|
7
|
+
VERSION = "0.13.4"
|
8
8
|
# @return [String] The user agent for the bot.
|
9
9
|
USER_AGENT = "DiscordBot (https://discorb-lib.github.io #{VERSION}) Ruby/#{RUBY_VERSION}"
|
10
10
|
|
@@ -117,6 +117,35 @@ module Discorb
|
|
117
117
|
alias id to_s
|
118
118
|
end
|
119
119
|
|
120
|
+
#
|
121
|
+
# Represents an endpoint.
|
122
|
+
# @private
|
123
|
+
#
|
124
|
+
class Route
|
125
|
+
attr_reader :url, :key, :method
|
126
|
+
|
127
|
+
def initialize(url, key, method)
|
128
|
+
@url = url
|
129
|
+
@key = key
|
130
|
+
@method = method
|
131
|
+
end
|
132
|
+
|
133
|
+
def hash
|
134
|
+
@url.hash
|
135
|
+
end
|
136
|
+
|
137
|
+
def identifier
|
138
|
+
"#{@method} #{@key}"
|
139
|
+
end
|
140
|
+
|
141
|
+
def major_param
|
142
|
+
param_type = @key.split("/").find { |k| k.start_with?(":") }
|
143
|
+
return "" unless param_type
|
144
|
+
param = url.gsub(API_BASE_URL, "").split("/")[@key.split("/").index(param_type) - 1]
|
145
|
+
%w[:channel_id :guild_id :webhook_id].include?(param_type) ? param : ""
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
120
149
|
# @return [Object] Object that represents nil.
|
121
150
|
# This is used as a default value for optional parameters.
|
122
151
|
Unset = Object.new
|
data/lib/discorb/dictionary.rb
CHANGED
@@ -16,6 +16,7 @@ module Discorb
|
|
16
16
|
@cache = hash.transform_keys(&:to_s)
|
17
17
|
@limit = limit
|
18
18
|
@sort = sort
|
19
|
+
@cache = @cache.sort_by(&@sort).to_h if @sort
|
19
20
|
end
|
20
21
|
|
21
22
|
#
|
@@ -39,7 +40,7 @@ module Discorb
|
|
39
40
|
# @param [Discorb::Dictionary] other The dictionary to merge.
|
40
41
|
#
|
41
42
|
def merge(other)
|
42
|
-
@cache.merge!(other)
|
43
|
+
@cache.merge!(other.to_h)
|
43
44
|
end
|
44
45
|
|
45
46
|
#
|
@@ -73,6 +74,13 @@ module Discorb
|
|
73
74
|
end
|
74
75
|
end
|
75
76
|
|
77
|
+
#
|
78
|
+
# Convert the dictionary to a hash.
|
79
|
+
#
|
80
|
+
def to_h
|
81
|
+
@cache
|
82
|
+
end
|
83
|
+
|
76
84
|
#
|
77
85
|
# Returns the values of the dictionary.
|
78
86
|
#
|
@@ -104,7 +112,7 @@ module Discorb
|
|
104
112
|
end
|
105
113
|
end
|
106
114
|
|
107
|
-
def respond_to_missing?(name,
|
115
|
+
def respond_to_missing?(name, ...)
|
108
116
|
if values.respond_to?(name)
|
109
117
|
true
|
110
118
|
else
|
data/lib/discorb/emoji.rb
CHANGED
@@ -96,7 +96,7 @@ module Discorb
|
|
96
96
|
payload = {}
|
97
97
|
payload[:name] = name if name != Discorb::Unset
|
98
98
|
payload[:roles] = roles.map { |r| Discorb::Utils.try(r, :id) } if roles != Discorb::Unset
|
99
|
-
@client.http.
|
99
|
+
@client.http.request(Route.new("/guilds/#{@guild.id}/emojis/#{@id}", "//guilds/:guild_id/emojis/:emoji_id", :patch), payload, audit_log_reason: reason)
|
100
100
|
self
|
101
101
|
end
|
102
102
|
end
|
@@ -113,7 +113,7 @@ module Discorb
|
|
113
113
|
#
|
114
114
|
def delete!(reason: nil)
|
115
115
|
Async do
|
116
|
-
@client.http.
|
116
|
+
@client.http.request(Route.new("/guilds/#{@guild.id}/emojis/#{@id}", "//guilds/:guild_id/emojis/:emoji_id", :delete), audit_log_reason: reason).wait
|
117
117
|
@available = false
|
118
118
|
self
|
119
119
|
end
|