discorb 0.18.1 → 0.19.0
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/Changelog.md +9 -0
- data/Gemfile +4 -4
- data/Rakefile +17 -22
- data/Steepfile +8 -6
- data/docs/events.md +2 -2
- data/docs/voice_events.md +6 -6
- data/lib/discorb/automod.rb +1 -1
- data/lib/discorb/channel/guild.rb +3 -3
- data/lib/discorb/channel/text.rb +3 -3
- data/lib/discorb/client.rb +4 -6
- data/lib/discorb/common.rb +1 -1
- data/lib/discorb/embed.rb +1 -1
- data/lib/discorb/emoji.rb +2 -2
- data/lib/discorb/event.rb +2 -2
- data/lib/discorb/gateway.rb +17 -7
- data/lib/discorb/guild.rb +4 -4
- data/lib/discorb/guild_template.rb +2 -2
- data/lib/discorb/integration.rb +2 -2
- data/lib/discorb/interaction/response.rb +83 -77
- data/lib/discorb/interaction/root.rb +136 -0
- data/lib/discorb/invite.rb +1 -1
- data/lib/discorb/message.rb +4 -4
- data/lib/discorb/modules.rb +2 -2
- data/lib/discorb/permission.rb +3 -1
- data/lib/discorb/role.rb +2 -2
- data/lib/discorb/shard.rb +1 -1
- data/lib/discorb/sticker.rb +2 -2
- data/lib/discorb/voice_state.rb +3 -3
- data/lib/discorb/webhook.rb +5 -5
- data/sig/discorb/activity.rbs +1 -0
- data/sig/discorb/allowed_mentions.rbs +1 -0
- data/sig/discorb/app_command/base.rbs +6 -0
- data/sig/discorb/application.rbs +4 -0
- data/sig/discorb/asset.rbs +2 -0
- data/sig/discorb/attachment.rbs +8 -0
- data/sig/discorb/audit_log.rbs +7 -0
- data/sig/discorb/automod.rbs +22 -5
- data/sig/discorb/avatar.rbs +1 -0
- data/sig/discorb/channel/base.rbs +8 -1
- data/sig/discorb/channel/category.rbs +1 -0
- data/sig/discorb/channel/container.rbs +4 -0
- data/sig/discorb/channel/stage.rbs +4 -0
- data/sig/discorb/channel/text.rbs +2 -2
- data/sig/discorb/channel/thread.rbs +11 -0
- data/sig/discorb/channel/voice.rbs +2 -0
- data/sig/discorb/client.rbs +21 -20
- data/sig/discorb/color.rbs +6 -0
- data/sig/discorb/component/base.rbs +1 -0
- data/sig/discorb/component/button.rbs +2 -0
- data/sig/discorb/component/select_menu.rbs +4 -0
- data/sig/discorb/component/text_input.rbs +1 -0
- data/sig/discorb/custom_emoji.rbs +5 -1
- data/sig/discorb/dictionary.rbs +2 -0
- data/sig/discorb/discord_model.rbs +2 -0
- data/sig/discorb/embed.rbs +7 -0
- data/sig/discorb/emoji.rbs +1 -0
- data/sig/discorb/event_handler.rbs +2 -1
- data/sig/discorb/extension.rbs +13 -12
- data/sig/discorb/flag.rbs +2 -0
- data/sig/discorb/gateway.rbs +5 -0
- data/sig/discorb/guild.rbs +6 -4
- data/sig/discorb/guild_template.rbs +1 -1
- data/sig/discorb/http.rbs +4 -1
- data/sig/discorb/image.rbs +2 -0
- data/sig/discorb/integration.rbs +1 -1
- data/sig/discorb/intents.rbs +4 -3
- data/sig/discorb/interaction/base.rbs +33 -0
- data/sig/discorb/interaction/message_component.rbs +1 -2
- data/sig/discorb/interaction/modal.rbs +1 -2
- data/sig/discorb/interaction/responder.rbs +49 -49
- data/sig/discorb/invite.rbs +1 -1
- data/sig/discorb/member.rbs +2 -0
- data/sig/discorb/message.rbs +6 -1
- data/sig/discorb/messageable.rbs +1 -4
- data/sig/discorb/partial_emoji.rbs +3 -0
- data/sig/discorb/permissions.rbs +7 -0
- data/sig/discorb/presence.rbs +2 -0
- data/sig/discorb/reaction.rbs +5 -1
- data/sig/discorb/role.rbs +7 -1
- data/sig/discorb/scheduled_event.rbs +2 -1
- data/sig/discorb/shard.rbs +2 -1
- data/sig/discorb/snowflake.rbs +2 -0
- data/sig/discorb/stage_instance.rbs +9 -3
- data/sig/discorb/sticker.rbs +1 -1
- data/sig/discorb/unicode_emoji.rbs +4 -0
- data/sig/discorb/user.rbs +2 -0
- data/sig/discorb/webhook.rbs +17 -6
- data/sig/discorb/welcome_screen.rbs +1 -0
- data/sig/override.rbs +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 99a6cb7f4f4f1d7c657209570f1327f6a847b7d7db3fb031c645ca4b0a4464af
|
|
4
|
+
data.tar.gz: f207685f5153f73dba3c66f40aaf4ef100063f31746874d57c31b119f5fcb009
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bd641beb11497865a97e267ef1558d1f5162323713f623fcd5109e9e25a7bb41d25e1a59111b0c3b5dcbe43f77a54531973f5874b5d82927956a1ad5f1e4ea03
|
|
7
|
+
data.tar.gz: 8d25ed7b8604b59c4a4f3f8467a268472749ccbc010d216787091ea3da60e24e0ddde95add2dc30f6d40637650d19cd9ef22e54dc2141637ac2e96cd4d55ece1
|
data/Changelog.md
CHANGED
|
@@ -4,6 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
# Changelog
|
|
6
6
|
|
|
7
|
+
## v0.19
|
|
8
|
+
|
|
9
|
+
### v0.19.0
|
|
10
|
+
|
|
11
|
+
- Change!: All bang methods don't have bang anymore. (ex: `Message#delete!`)
|
|
12
|
+
- Add: Add `%a{pure}` annotation to rbs.
|
|
13
|
+
- Add: Add low level APIs to Interaction.
|
|
14
|
+
- Update: Update IDENTIFY key.
|
|
15
|
+
|
|
7
16
|
## v0.18
|
|
8
17
|
|
|
9
18
|
### v0.18.1
|
data/Gemfile
CHANGED
|
@@ -18,7 +18,7 @@ gem "parallel_tests", "~> 3.8"
|
|
|
18
18
|
gem "rspec", "~> 3.11"
|
|
19
19
|
|
|
20
20
|
# Typecheck
|
|
21
|
-
gem "steep", "~> 1.
|
|
21
|
+
gem "steep", "~> 1.1"
|
|
22
22
|
|
|
23
23
|
# Other development tools
|
|
24
24
|
gem "lefthook", "~> 0.7.7"
|
|
@@ -32,6 +32,6 @@ group :docs, optional: true do
|
|
|
32
32
|
gem "rubyzip", "~> 2.3"
|
|
33
33
|
gem "yard", "~> 0.9.26"
|
|
34
34
|
end
|
|
35
|
-
|
|
36
|
-
gem "syntax_tree", "~> 2.8"
|
|
37
|
-
gem "syntax_tree-rbs", "~> 0.
|
|
35
|
+
|
|
36
|
+
gem "syntax_tree", "~> 2.8"
|
|
37
|
+
gem "syntax_tree-rbs", "~> 0.5.0"
|
data/Rakefile
CHANGED
|
@@ -236,6 +236,7 @@ desc "Generate rbs file"
|
|
|
236
236
|
namespace :rbs do
|
|
237
237
|
desc "Generate event signature"
|
|
238
238
|
task :event do
|
|
239
|
+
require "syntax_tree/rbs"
|
|
239
240
|
client_rbs = File.read("sig/discorb/client.rbs")
|
|
240
241
|
extension_rbs = File.read("sig/discorb/extension.rbs")
|
|
241
242
|
event_document = File.read("./docs/events.md")
|
|
@@ -296,41 +297,35 @@ namespace :rbs do
|
|
|
296
297
|
| (:#{event[:name]} event_name, ?id: Symbol?, **untyped metadata) { (#{sig}) -> void } -> void
|
|
297
298
|
RBS
|
|
298
299
|
end
|
|
300
|
+
event_sig << <<~RBS
|
|
301
|
+
| (Symbol event_name, ?id: Symbol?, **untyped metadata) { (*untyped) -> void } -> Discorb::EventHandler
|
|
302
|
+
RBS
|
|
303
|
+
event_lock_sig << <<~RBS
|
|
304
|
+
| (Symbol event, ?Integer? timeout) { (*untyped) -> boolish } -> Async::Task[untyped]
|
|
305
|
+
RBS
|
|
306
|
+
extension_sig << <<~RBS
|
|
307
|
+
| (Symbol event_name, ?id: Symbol?, **untyped metadata) { (*untyped) -> void } -> void
|
|
308
|
+
RBS
|
|
299
309
|
event_sig.sub!("| ", " ").rstrip!
|
|
300
310
|
event_lock_sig.sub!("| ", " ").rstrip!
|
|
301
311
|
extension_sig.sub!("| ", " ").rstrip!
|
|
302
|
-
res = client_rbs.gsub!(
|
|
303
|
-
indent = Regexp.last_match(1)
|
|
304
|
-
"# marker: on\n#{event_sig.gsub(/^/, "#{indent} ")}\n#{indent}# endmarker: on\n"
|
|
305
|
-
end
|
|
312
|
+
res = client_rbs.gsub!(/(?<=def on:\n)(?:[\s\S]*?)(?=\n\n)/, event_sig)
|
|
306
313
|
raise "Failed to generate Client#on" unless res
|
|
307
314
|
|
|
308
|
-
res = client_rbs.gsub!(
|
|
309
|
-
indent = Regexp.last_match(1)
|
|
310
|
-
"# marker: once\n#{event_sig.gsub(/^/, "#{indent} ")}\n#{indent}# endmarker: once\n"
|
|
311
|
-
end
|
|
315
|
+
res = client_rbs.gsub!(/(?<=def once:\n)(?:[\s\S]*?)(?=\n\n)/, event_sig)
|
|
312
316
|
raise "Failed to generate Client#once" unless res
|
|
313
317
|
|
|
314
|
-
res = client_rbs.gsub!(
|
|
315
|
-
indent = Regexp.last_match(1)
|
|
316
|
-
"# marker: event_lock\n#{event_lock_sig.gsub(/^/, "#{indent} ")}\n#{indent}# endmarker: event_lock\n"
|
|
317
|
-
end
|
|
318
|
+
res = client_rbs.gsub!(/(?<=def event_lock:\n)(?:[\s\S]*?)(?=\n\n)/, event_lock_sig)
|
|
318
319
|
raise "Failed to generate Client#event_lock" unless res
|
|
319
320
|
|
|
320
|
-
res = extension_rbs.gsub!(
|
|
321
|
-
indent = Regexp.last_match(1)
|
|
322
|
-
"# marker: event\n#{extension_sig.gsub(/^/, "#{indent} ")}\n#{indent}# endmarker: event\n"
|
|
323
|
-
end
|
|
321
|
+
res = extension_rbs.gsub!(/(?<=def event:\n)(?:[\s\S]*?)(?=\n\n)/, extension_sig)
|
|
324
322
|
raise "Failed to generate Extension.event" unless res
|
|
325
323
|
|
|
326
|
-
res = extension_rbs.gsub!(
|
|
327
|
-
indent = Regexp.last_match(1)
|
|
328
|
-
"# marker: once_event\n#{extension_sig.gsub(/^/, "#{indent} ")}\n#{indent}# endmarker: once_event\n"
|
|
329
|
-
end
|
|
324
|
+
res = extension_rbs.gsub!(/(?<=def once_event:\n)(?:[\s\S]*?)(?=\n\n)/, extension_sig)
|
|
330
325
|
raise "Failed to generate Extension.once_event" unless res
|
|
331
326
|
|
|
332
|
-
File.write("sig/discorb/client.rbs", client_rbs, mode: "wb")
|
|
333
|
-
File.write("sig/discorb/extension.rbs", extension_rbs, mode: "wb")
|
|
327
|
+
File.write("sig/discorb/client.rbs", SyntaxTree::RBS.format(client_rbs), mode: "wb")
|
|
328
|
+
File.write("sig/discorb/extension.rbs", SyntaxTree::RBS.format(extension_rbs), mode: "wb")
|
|
334
329
|
end
|
|
335
330
|
|
|
336
331
|
desc "Generate rbs file using sord"
|
data/Steepfile
CHANGED
|
@@ -15,14 +15,16 @@ target :lib do
|
|
|
15
15
|
config[D::Ruby::UnexpectedSuper] = nil
|
|
16
16
|
config[D::Ruby::UnexpectedPositionalArgument] = nil
|
|
17
17
|
config[D::Ruby::InsufficientPositionalArguments] = nil
|
|
18
|
+
config[D::Ruby::UnknownInstanceVariable] = nil
|
|
19
|
+
config[D::Ruby::UnknownGlobalVariable] = nil
|
|
18
20
|
end
|
|
19
21
|
end
|
|
20
22
|
|
|
21
|
-
target :test do
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
# target :test do
|
|
24
|
+
# signature "sig"
|
|
25
|
+
# signature "examples/sig"
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
# check "examples/**/*.rb"
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
end
|
|
29
|
+
# library "net-http", "timeout"
|
|
30
|
+
# end
|
data/docs/events.md
CHANGED
|
@@ -563,9 +563,9 @@ Fires when a select menu is selected.
|
|
|
563
563
|
| ------------- | -------------------------------------------------- | ----------------------- |
|
|
564
564
|
| `interaction` | {Discorb::MessageComponentInteraction::SelectMenu} | The interaction object. |
|
|
565
565
|
|
|
566
|
-
#### `
|
|
566
|
+
#### `modal_submit(interaction)`
|
|
567
567
|
|
|
568
|
-
Fires when a
|
|
568
|
+
Fires when a modal is submitted.
|
|
569
569
|
|
|
570
570
|
| Parameter | Type | Description |
|
|
571
571
|
| ------------- | --------------------------- | ----------------------- |
|
data/docs/voice_events.md
CHANGED
|
@@ -12,7 +12,7 @@ Fires when someone joins a voice channel.
|
|
|
12
12
|
|
|
13
13
|
| Parameter | Type | Description |
|
|
14
14
|
| --------- | --------------------- | ---------------------------------------- |
|
|
15
|
-
| state
|
|
15
|
+
| `state` | {Discorb::VoiceState} | The voice state of the user that joined. |
|
|
16
16
|
|
|
17
17
|
#### `voice_channel_disconnect(state)`
|
|
18
18
|
|
|
@@ -20,7 +20,7 @@ Fires when someone leaves a voice channel.
|
|
|
20
20
|
|
|
21
21
|
| Parameter | Type | Description |
|
|
22
22
|
| --------- | --------------------- | -------------------------------------- |
|
|
23
|
-
| state
|
|
23
|
+
| `state` | {Discorb::VoiceState} | The voice state of the user that left. |
|
|
24
24
|
|
|
25
25
|
#### `voice_channel_move(before, after)`
|
|
26
26
|
|
|
@@ -28,8 +28,8 @@ Fires when someone moves to a different voice channel.
|
|
|
28
28
|
|
|
29
29
|
| Parameter | Type | Description |
|
|
30
30
|
| --------- | --------------------- | -------------------------------------------- |
|
|
31
|
-
| before
|
|
32
|
-
| after
|
|
31
|
+
| `before` | {Discorb::VoiceState} | The voice state of the user before the move. |
|
|
32
|
+
| `after` | {Discorb::VoiceState} | The voice state of the user after the move. |
|
|
33
33
|
|
|
34
34
|
#### `voice_channel_update(before, after)`
|
|
35
35
|
|
|
@@ -37,8 +37,8 @@ Fires when a voice channel is connected, disconnected, or updated.
|
|
|
37
37
|
|
|
38
38
|
| Parameter | Type | Description |
|
|
39
39
|
| --------- | --------------------- | ---------------------------------- |
|
|
40
|
-
| before
|
|
41
|
-
| after
|
|
40
|
+
| `before` | {Discorb::VoiceState} | The voice state before the update. |
|
|
41
|
+
| `after` | {Discorb::VoiceState} | The voice state after the update. |
|
|
42
42
|
|
|
43
43
|
### Mute Events
|
|
44
44
|
|
data/lib/discorb/automod.rb
CHANGED
|
@@ -89,7 +89,7 @@ module Discorb
|
|
|
89
89
|
#
|
|
90
90
|
# @return [Async::Task<self>] The deleted channel.
|
|
91
91
|
#
|
|
92
|
-
def delete
|
|
92
|
+
def delete(reason: nil)
|
|
93
93
|
Async do
|
|
94
94
|
@client.http.request(Route.new(base_url.wait.to_s, "//webhooks/:webhook_id/:token", :delete), {},
|
|
95
95
|
audit_log_reason: reason).wait
|
|
@@ -98,8 +98,8 @@ module Discorb
|
|
|
98
98
|
end
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
-
alias close
|
|
102
|
-
alias destroy
|
|
101
|
+
alias close delete
|
|
102
|
+
alias destroy delete
|
|
103
103
|
|
|
104
104
|
#
|
|
105
105
|
# Moves the channel to another position.
|
data/lib/discorb/channel/text.rb
CHANGED
|
@@ -135,7 +135,7 @@ module Discorb
|
|
|
135
135
|
#
|
|
136
136
|
# @return [Async::Task<void>] The task.
|
|
137
137
|
#
|
|
138
|
-
def delete_messages
|
|
138
|
+
def delete_messages(*messages, force: false)
|
|
139
139
|
Async do
|
|
140
140
|
messages = messages.flatten
|
|
141
141
|
unless force
|
|
@@ -156,8 +156,8 @@ module Discorb
|
|
|
156
156
|
end
|
|
157
157
|
end
|
|
158
158
|
|
|
159
|
-
alias bulk_delete
|
|
160
|
-
alias destroy_messages
|
|
159
|
+
alias bulk_delete delete_messages
|
|
160
|
+
alias destroy_messages delete_messages
|
|
161
161
|
|
|
162
162
|
#
|
|
163
163
|
# Follow the existing announcement channel.
|
data/lib/discorb/client.rb
CHANGED
|
@@ -473,9 +473,9 @@ module Discorb
|
|
|
473
473
|
#
|
|
474
474
|
# Stops the client.
|
|
475
475
|
#
|
|
476
|
-
def close
|
|
476
|
+
def close
|
|
477
477
|
if @shards.any?
|
|
478
|
-
@shards.each_value(&:close
|
|
478
|
+
@shards.each_value(&:close)
|
|
479
479
|
else
|
|
480
480
|
@connection.send_close
|
|
481
481
|
end
|
|
@@ -521,9 +521,7 @@ module Discorb
|
|
|
521
521
|
setup_commands(token, guild_ids: guild_ids).wait
|
|
522
522
|
clear_commands(token, ENV.fetch("DISCORB_SETUP_CLEAR_GUILDS", "").split(","))
|
|
523
523
|
if ENV.fetch("DISCORB_SETUP_SCRIPT", nil) == "true"
|
|
524
|
-
@events[:setup]&.each
|
|
525
|
-
event.call
|
|
526
|
-
end
|
|
524
|
+
@events[:setup]&.each(&:call)
|
|
527
525
|
self.on_setup if respond_to? :on_setup
|
|
528
526
|
end
|
|
529
527
|
end
|
|
@@ -567,7 +565,7 @@ module Discorb
|
|
|
567
565
|
Signal.trap(:SIGINT) do
|
|
568
566
|
logger.info "SIGINT received, closing..."
|
|
569
567
|
Signal.trap(:SIGINT, "DEFAULT")
|
|
570
|
-
close
|
|
568
|
+
close
|
|
571
569
|
end
|
|
572
570
|
if shards.nil?
|
|
573
571
|
main_loop(nil)
|
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/v10"
|
|
6
6
|
# @return [String] The version of discorb.
|
|
7
|
-
VERSION = "0.
|
|
7
|
+
VERSION = "0.19.0"
|
|
8
8
|
# @return [Array<Integer>] The version array of discorb.
|
|
9
9
|
VERSION_ARRAY = VERSION.split(".").map(&:to_i).freeze
|
|
10
10
|
# @return [String] The user agent for the bot.
|
data/lib/discorb/embed.rb
CHANGED
|
@@ -124,7 +124,7 @@ module Discorb
|
|
|
124
124
|
ret[:image] = @image&.to_hash if @image
|
|
125
125
|
ret[:thumbnail] = @thumbnail&.to_hash if @thumbnail
|
|
126
126
|
ret[:author] = @author&.to_hash if @author
|
|
127
|
-
ret[:fields] = @fields&.map
|
|
127
|
+
ret[:fields] = @fields&.map(&:to_hash) if @fields.any?
|
|
128
128
|
ret
|
|
129
129
|
end
|
|
130
130
|
|
data/lib/discorb/emoji.rb
CHANGED
|
@@ -121,7 +121,7 @@ module Discorb
|
|
|
121
121
|
#
|
|
122
122
|
# @return [Async::Task<self>] The deleted emoji.
|
|
123
123
|
#
|
|
124
|
-
def delete
|
|
124
|
+
def delete(reason: nil)
|
|
125
125
|
Async do
|
|
126
126
|
@client.http.request(
|
|
127
127
|
Route.new("/guilds/#{@guild.id}/emojis/#{@id}", "//guilds/:guild_id/emojis/:emoji_id",
|
|
@@ -132,7 +132,7 @@ module Discorb
|
|
|
132
132
|
end
|
|
133
133
|
end
|
|
134
134
|
|
|
135
|
-
alias destroy
|
|
135
|
+
alias destroy delete
|
|
136
136
|
|
|
137
137
|
#
|
|
138
138
|
# Converts the object to a hash.
|
data/lib/discorb/event.rb
CHANGED
|
@@ -224,14 +224,14 @@ module Discorb
|
|
|
224
224
|
#
|
|
225
225
|
# @return [Async::Task<void>] The task.
|
|
226
226
|
#
|
|
227
|
-
def delete
|
|
227
|
+
def delete
|
|
228
228
|
Async do
|
|
229
229
|
@client.http.request(Route.new("/guilds/#{@guild_id}/scheduled-events/#{@id}",
|
|
230
230
|
"//guilds/:guild_id/scheduled-events/:scheduled_event_id", :delete)).wait
|
|
231
231
|
end
|
|
232
232
|
end
|
|
233
233
|
|
|
234
|
-
alias destroy
|
|
234
|
+
alias destroy delete
|
|
235
235
|
|
|
236
236
|
#
|
|
237
237
|
# Fetches the event users.
|
data/lib/discorb/gateway.rb
CHANGED
|
@@ -48,11 +48,21 @@ module Discorb
|
|
|
48
48
|
alpn_protocols: Async::HTTP::Protocol::HTTP11.names,
|
|
49
49
|
)
|
|
50
50
|
begin
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
reconnect_count = 0
|
|
52
|
+
begin
|
|
53
|
+
self.connection = Async::WebSocket::Client.connect(
|
|
54
|
+
endpoint,
|
|
55
|
+
headers: [["User-Agent", Discorb::USER_AGENT]],
|
|
56
|
+
handler: RawConnection,
|
|
57
|
+
)
|
|
58
|
+
rescue Async::WebSocket::ProtocolError => e
|
|
59
|
+
raise if reconnect_count > 3
|
|
60
|
+
|
|
61
|
+
logger.info "Failed to connect to gateway, retrying...: #{e.message}"
|
|
62
|
+
reconnect_count += 1
|
|
63
|
+
sleep 2 ** reconnect_count
|
|
64
|
+
retry
|
|
65
|
+
end
|
|
56
66
|
con = self.connection
|
|
57
67
|
zlib_stream = Zlib::Inflate.new(Zlib::MAX_WBITS)
|
|
58
68
|
buffer = +""
|
|
@@ -82,7 +92,7 @@ module Discorb
|
|
|
82
92
|
IOError => e
|
|
83
93
|
next if @status == :closed
|
|
84
94
|
|
|
85
|
-
logger.
|
|
95
|
+
logger.info "Gateway connection closed, reconnecting: #{e.class}: #{e.message}"
|
|
86
96
|
con.force_close
|
|
87
97
|
connect_gateway(true)
|
|
88
98
|
next
|
|
@@ -163,7 +173,7 @@ module Discorb
|
|
|
163
173
|
token: @token,
|
|
164
174
|
intents: @intents.value,
|
|
165
175
|
compress: false,
|
|
166
|
-
properties: { "
|
|
176
|
+
properties: { "os" => RUBY_PLATFORM, "browser" => "discorb", "device" => "discorb" },
|
|
167
177
|
}
|
|
168
178
|
payload[:shard] = [shard_id, @shard_count] if shard_id
|
|
169
179
|
payload[:presence] = @identify_presence if @identify_presence
|
data/lib/discorb/guild.rb
CHANGED
|
@@ -179,7 +179,7 @@ module Discorb
|
|
|
179
179
|
#
|
|
180
180
|
# @return [Async::Task<void>] The task.
|
|
181
181
|
#
|
|
182
|
-
def leave
|
|
182
|
+
def leave
|
|
183
183
|
Async do
|
|
184
184
|
@client.http.request(Route.new("/users/@me/guilds/#{@id}", "//users/@me/guilds/:guild_id", :delete)).wait
|
|
185
185
|
@client.guilds.delete(@id)
|
|
@@ -1188,7 +1188,7 @@ module Discorb
|
|
|
1188
1188
|
name,
|
|
1189
1189
|
trigger_type,
|
|
1190
1190
|
actions,
|
|
1191
|
-
event_type = :
|
|
1191
|
+
event_type = :message_send,
|
|
1192
1192
|
enabled: false,
|
|
1193
1193
|
exempt_roles: [],
|
|
1194
1194
|
exempt_channels: [],
|
|
@@ -1203,7 +1203,7 @@ module Discorb
|
|
|
1203
1203
|
trigger_type: Discorb::AutoModRule::TRIGGER_TYPES.key(trigger_type),
|
|
1204
1204
|
metadata: {
|
|
1205
1205
|
keyword_filter: keyword_filter,
|
|
1206
|
-
presets: Discorb::AutoModRule::PRESET_TYPES.key(presets),
|
|
1206
|
+
presets: presets && Discorb::AutoModRule::PRESET_TYPES.key(presets),
|
|
1207
1207
|
},
|
|
1208
1208
|
actions: actions.map(&:to_hash),
|
|
1209
1209
|
enabled: enabled,
|
|
@@ -1381,7 +1381,7 @@ module Discorb
|
|
|
1381
1381
|
#
|
|
1382
1382
|
# @return [String] The url of the banner.
|
|
1383
1383
|
#
|
|
1384
|
-
def banner(guild_id, style:
|
|
1384
|
+
def banner(guild_id, style: :banner)
|
|
1385
1385
|
"#{Discorb::API_BASE_URL}/guilds/#{guild_id}/widget.png&style=#{style}"
|
|
1386
1386
|
end
|
|
1387
1387
|
end
|
|
@@ -93,14 +93,14 @@ module Discorb
|
|
|
93
93
|
#
|
|
94
94
|
# @return [Async::Task<void>] The task.
|
|
95
95
|
#
|
|
96
|
-
def delete
|
|
96
|
+
def delete
|
|
97
97
|
Async do
|
|
98
98
|
@client.http.request(Route.new("/guilds/#{@source_guild_id}/templates/#{@code}",
|
|
99
99
|
"//guilds/:guild_id/templates/:code", :delete)).wait
|
|
100
100
|
end
|
|
101
101
|
end
|
|
102
102
|
|
|
103
|
-
alias destroy
|
|
103
|
+
alias destroy delete
|
|
104
104
|
|
|
105
105
|
#
|
|
106
106
|
# Represents a guild in guild template.
|
data/lib/discorb/integration.rb
CHANGED
|
@@ -72,7 +72,7 @@ module Discorb
|
|
|
72
72
|
#
|
|
73
73
|
# @return [Async::Task<void>] The task.
|
|
74
74
|
#
|
|
75
|
-
def delete
|
|
75
|
+
def delete(reason: nil)
|
|
76
76
|
Async do
|
|
77
77
|
@client.http.request(
|
|
78
78
|
Route.new("/guilds/#{@guild}/integrations/#{@id}", "//guilds/:guild_id/integrations/:integration_id",
|
|
@@ -81,7 +81,7 @@ module Discorb
|
|
|
81
81
|
end
|
|
82
82
|
end
|
|
83
83
|
|
|
84
|
-
alias destroy
|
|
84
|
+
alias destroy delete
|
|
85
85
|
|
|
86
86
|
private
|
|
87
87
|
|
|
@@ -125,86 +125,86 @@ module Discorb
|
|
|
125
125
|
ret
|
|
126
126
|
end
|
|
127
127
|
end
|
|
128
|
+
end
|
|
128
129
|
|
|
130
|
+
#
|
|
131
|
+
# Represents of a callback message of interaction.
|
|
132
|
+
#
|
|
133
|
+
class CallbackMessage
|
|
129
134
|
#
|
|
130
|
-
#
|
|
131
|
-
#
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
@data = data
|
|
145
|
-
@application_id = application_id
|
|
146
|
-
@token = token
|
|
147
|
-
end
|
|
135
|
+
# Initializes a new instance of CallbackMessage.
|
|
136
|
+
# @private
|
|
137
|
+
#
|
|
138
|
+
# @param [Client] client The client.
|
|
139
|
+
# @param [Hash] data The payload.
|
|
140
|
+
# @param [String] application_id The application ID.
|
|
141
|
+
# @param [String] token The token.
|
|
142
|
+
#
|
|
143
|
+
def initialize(client, data, application_id, token)
|
|
144
|
+
@client = client
|
|
145
|
+
@data = data
|
|
146
|
+
@application_id = application_id
|
|
147
|
+
@token = token
|
|
148
|
+
end
|
|
148
149
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
end
|
|
150
|
+
#
|
|
151
|
+
# Edits the callback message.
|
|
152
|
+
# @async
|
|
153
|
+
# @macro edit
|
|
154
|
+
#
|
|
155
|
+
# @param [String] content The new content of the message.
|
|
156
|
+
# @param [Discorb::Embed] embed The new embed of the message.
|
|
157
|
+
# @param [Array<Discorb::Embed>] embeds The new embeds of the message.
|
|
158
|
+
# @param [Array<Discorb::Attachment>] attachments The attachments to remain.
|
|
159
|
+
# @param [Discorb::Attachment] file The file to send.
|
|
160
|
+
# @param [Array<Discorb::Attachment>] files The files to send.
|
|
161
|
+
#
|
|
162
|
+
# @return [Async::Task<void>] The task.
|
|
163
|
+
#
|
|
164
|
+
def edit(
|
|
165
|
+
content = Discorb::Unset,
|
|
166
|
+
embed: Discorb::Unset, embeds: Discorb::Unset,
|
|
167
|
+
file: Discorb::Unset, files: Discorb::Unset,
|
|
168
|
+
attachments: Discorb::Unset
|
|
169
|
+
)
|
|
170
|
+
Async do
|
|
171
|
+
payload = {}
|
|
172
|
+
payload[:content] = content if content != Discorb::Unset
|
|
173
|
+
payload[:embeds] = embed ? [embed.to_hash] : [] if embed != Discorb::Unset
|
|
174
|
+
payload[:embeds] = embeds.map(&:to_hash) if embeds != Discorb::Unset
|
|
175
|
+
payload[:attachments] = attachments.map(&:to_hash) if attachments != Discorb::Unset
|
|
176
|
+
files = [file] if file != Discorb::Unset
|
|
177
|
+
files = [] if files == Discorb::Unset
|
|
178
|
+
@client.http.multipart_request(
|
|
179
|
+
Route.new(
|
|
180
|
+
"/webhooks/#{@application_id}/#{@token}/messages/@original",
|
|
181
|
+
"//webhooks/:webhook_id/:token/messages/@original",
|
|
182
|
+
:patch
|
|
183
|
+
),
|
|
184
|
+
payload,
|
|
185
|
+
files,
|
|
186
|
+
).wait
|
|
187
187
|
end
|
|
188
|
+
end
|
|
188
189
|
|
|
189
|
-
|
|
190
|
+
alias modify edit
|
|
190
191
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
end
|
|
192
|
+
#
|
|
193
|
+
# Deletes the callback message.
|
|
194
|
+
# @async
|
|
195
|
+
# @note This will fail if the message is ephemeral.
|
|
196
|
+
#
|
|
197
|
+
# @return [Async::Task<void>] The task.
|
|
198
|
+
#
|
|
199
|
+
def delete
|
|
200
|
+
Async do
|
|
201
|
+
@client.http.request(Route.new("/webhooks/#{@application_id}/#{@token}/messages/@original",
|
|
202
|
+
"//webhooks/:webhook_id/:token/messages/@original", :delete)).wait
|
|
203
203
|
end
|
|
204
|
+
end
|
|
204
205
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
end
|
|
206
|
+
def inspect
|
|
207
|
+
"#<#{self.class.name} application_id=#{@application_id}"
|
|
208
208
|
end
|
|
209
209
|
end
|
|
210
210
|
|
|
@@ -313,11 +313,17 @@ module Discorb
|
|
|
313
313
|
# @return [Async::Task<void>] The task.
|
|
314
314
|
#
|
|
315
315
|
def show_modal(title, custom_id, components)
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
316
|
+
Async do
|
|
317
|
+
payload = { title: title, custom_id: custom_id, components: Component.to_payload(components) }
|
|
318
|
+
@client.http.request(
|
|
319
|
+
Route.new(
|
|
320
|
+
"/interactions/#{@id}/#{@token}/callback",
|
|
321
|
+
"//interactions/:interaction_id/:token/callback",
|
|
322
|
+
:post
|
|
323
|
+
),
|
|
324
|
+
{ type: 9, data: payload }
|
|
325
|
+
).wait
|
|
326
|
+
end
|
|
321
327
|
end
|
|
322
328
|
end
|
|
323
329
|
|