discorb 0.12.2 → 0.13.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/workflows/build_main.yml +1 -0
- data/.github/workflows/build_version.yml +1 -0
- data/.github/workflows/crowdin.yml +32 -0
- data/.gitignore +3 -1
- data/.yardopts +2 -0
- data/Changelog.md +399 -367
- data/Gemfile +5 -1
- data/README.md +1 -1
- data/Rakefile +139 -9
- data/crowdin.yml +2 -0
- data/discorb.gemspec +1 -1
- data/docs/Examples.md +2 -0
- data/docs/application_command.md +17 -12
- data/docs/cli/irb.md +2 -0
- data/docs/cli/new.md +2 -0
- data/docs/cli/run.md +3 -1
- data/docs/cli/setup.md +4 -2
- data/docs/cli.md +2 -0
- data/docs/events.md +59 -5
- data/docs/extension.md +2 -2
- data/docs/faq.md +4 -2
- data/docs/license.md +2 -0
- data/docs/tutorial.md +4 -3
- data/docs/voice_events.md +2 -0
- data/lib/discorb/app_command.rb +13 -7
- data/lib/discorb/application.rb +32 -2
- data/lib/discorb/audit_logs.rb +28 -16
- data/lib/discorb/channel.rb +112 -81
- data/lib/discorb/client.rb +17 -19
- data/lib/discorb/common.rb +28 -1
- data/lib/discorb/components.rb +12 -0
- data/lib/discorb/dictionary.rb +1 -1
- data/lib/discorb/embed.rb +4 -0
- data/lib/discorb/emoji.rb +9 -7
- data/lib/discorb/emoji_table.rb +3774 -3689
- data/lib/discorb/event.rb +266 -24
- data/lib/discorb/event_handler.rb +39 -0
- data/lib/discorb/exe/show.rb +2 -0
- data/lib/discorb/extension.rb +5 -5
- data/lib/discorb/file.rb +4 -0
- data/lib/discorb/flag.rb +5 -1
- data/lib/discorb/gateway.rb +65 -14
- data/lib/discorb/gateway_requests.rb +4 -0
- data/lib/discorb/guild.rb +169 -82
- data/lib/discorb/guild_template.rb +12 -9
- data/lib/discorb/http.rb +82 -37
- data/lib/discorb/image.rb +7 -5
- data/lib/discorb/integration.rb +4 -1
- data/lib/discorb/intents.rb +8 -3
- data/lib/discorb/interaction/autocomplete.rb +1 -1
- data/lib/discorb/interaction/command.rb +2 -2
- data/lib/discorb/interaction/response.rb +27 -25
- data/lib/discorb/interaction/root.rb +8 -0
- data/lib/discorb/invite.rb +3 -2
- data/lib/discorb/log.rb +4 -0
- data/lib/discorb/member.rb +42 -13
- data/lib/discorb/message.rb +32 -17
- data/lib/discorb/modules.rb +19 -26
- data/lib/discorb/permission.rb +4 -0
- data/lib/discorb/rate_limit.rb +6 -2
- data/lib/discorb/role.rb +15 -11
- data/lib/discorb/sticker.rb +17 -12
- data/lib/discorb/user.rb +8 -7
- data/lib/discorb/voice_state.rb +8 -5
- data/lib/discorb/webhook.rb +38 -47
- data/lib/discorb.rb +2 -2
- data/po/yard.pot +7775 -5157
- data/sig/discorb.rbs +3317 -3820
- data/template-replace/scripts/locale_ja.rb +62 -0
- data/template-replace/scripts/yard_replace.rb +6 -0
- metadata +7 -4
data/lib/discorb/webhook.rb
CHANGED
@@ -43,8 +43,7 @@ module Discorb
|
|
43
43
|
|
44
44
|
#
|
45
45
|
# Posts a message to the webhook.
|
46
|
-
# @
|
47
|
-
# @macro http
|
46
|
+
# @async
|
48
47
|
#
|
49
48
|
# @param [String] content The content of the message.
|
50
49
|
# @param [Boolean] tts Whether the message should be sent as text-to-speech.
|
@@ -61,7 +60,7 @@ module Discorb
|
|
61
60
|
# @return [Async::Task<nil>] If `wait` is false.
|
62
61
|
#
|
63
62
|
def post(content = nil, tts: false, embed: nil, embeds: nil, allowed_mentions: nil,
|
64
|
-
file: nil, files: nil, username: nil, avatar_url:
|
63
|
+
file: nil, files: nil, username: nil, avatar_url: Discorb::Unset, wait: true)
|
65
64
|
Async do
|
66
65
|
payload = {}
|
67
66
|
payload[:content] = content if content
|
@@ -74,17 +73,9 @@ module Discorb
|
|
74
73
|
payload[:embeds] = tmp_embed.map(&:to_hash) if tmp_embed
|
75
74
|
payload[:allowed_mentions] = allowed_mentions&.to_hash
|
76
75
|
payload[:username] = username if username
|
77
|
-
payload[:avatar_url] = avatar_url if avatar_url !=
|
78
|
-
files = [file]
|
79
|
-
|
80
|
-
headers, payload = HTTP.multipart(payload, files)
|
81
|
-
else
|
82
|
-
headers = {
|
83
|
-
"Content-Type" => "application/json",
|
84
|
-
}
|
85
|
-
end
|
86
|
-
_resp, data = @http.post("#{url}?wait=#{wait}", payload, headers: headers).wait
|
87
|
-
|
76
|
+
payload[:avatar_url] = avatar_url if avatar_url != Discorb::Unset
|
77
|
+
files = [file]
|
78
|
+
_resp, data = @http.multipart_post("#{url}?wait=#{wait}", files, payload, headers: headers).wait
|
88
79
|
data && Webhook::Message.new(self, data)
|
89
80
|
end
|
90
81
|
end
|
@@ -93,20 +84,21 @@ module Discorb
|
|
93
84
|
|
94
85
|
#
|
95
86
|
# Edits the webhook.
|
96
|
-
# @
|
97
|
-
# @macro http
|
87
|
+
# @async
|
98
88
|
# @macro edit
|
99
89
|
#
|
100
90
|
# @param [String] name The new name of the webhook.
|
101
91
|
# @param [Discorb::Image] avatar The new avatar of the webhook.
|
102
92
|
# @param [Discorb::GuildChannel] channel The new channel of the webhook.
|
103
93
|
#
|
104
|
-
|
94
|
+
# @return [Async::Task<void>] The task.
|
95
|
+
#
|
96
|
+
def edit(name: Discorb::Unset, avatar: Discorb::Unset, channel: Discorb::Unset)
|
105
97
|
Async do
|
106
98
|
payload = {}
|
107
|
-
payload[:name] = name if name !=
|
108
|
-
payload[:avatar] = avatar if avatar !=
|
109
|
-
payload[:channel_id] = Utils.try(channel, :id) if channel !=
|
99
|
+
payload[:name] = name if name != Discorb::Unset
|
100
|
+
payload[:avatar] = avatar if avatar != Discorb::Unset
|
101
|
+
payload[:channel_id] = Utils.try(channel, :id) if channel != Discorb::Unset
|
110
102
|
@http.patch(url.to_s, payload).wait
|
111
103
|
end
|
112
104
|
end
|
@@ -115,8 +107,9 @@ module Discorb
|
|
115
107
|
|
116
108
|
#
|
117
109
|
# Deletes the webhook.
|
118
|
-
# @
|
119
|
-
#
|
110
|
+
# @async
|
111
|
+
#
|
112
|
+
# @return [Async::Task<void>] The task.
|
120
113
|
#
|
121
114
|
def delete!
|
122
115
|
Async do
|
@@ -129,8 +122,7 @@ module Discorb
|
|
129
122
|
|
130
123
|
#
|
131
124
|
# Edits the webhook's message.
|
132
|
-
# @
|
133
|
-
# @macro http
|
125
|
+
# @async
|
134
126
|
# @macro edit
|
135
127
|
#
|
136
128
|
# @param [Discorb::Webhook::Message] message The message to edit.
|
@@ -142,29 +134,24 @@ module Discorb
|
|
142
134
|
# @param [Array<Discorb::File>] files The files to send.
|
143
135
|
# @param [Discorb::AllowedMentions] allowed_mentions The allowed mentions to send.
|
144
136
|
#
|
137
|
+
# @return [Async::Task<void>] The task.
|
138
|
+
#
|
145
139
|
def edit_message(
|
146
|
-
message, content =
|
147
|
-
embed:
|
148
|
-
file:
|
149
|
-
attachments:
|
150
|
-
allowed_mentions:
|
140
|
+
message, content = Discorb::Unset,
|
141
|
+
embed: Discorb::Unset, embeds: Discorb::Unset,
|
142
|
+
file: Discorb::Unset, files: Discorb::Unset,
|
143
|
+
attachments: Discorb::Unset,
|
144
|
+
allowed_mentions: Discorb::Unset
|
151
145
|
)
|
152
146
|
Async do
|
153
147
|
payload = {}
|
154
|
-
payload[:content] = content if content !=
|
155
|
-
payload[:embeds] = embed ? [embed.to_hash] : [] if embed !=
|
156
|
-
payload[:embeds] = embeds.map(&:to_hash) if embeds !=
|
157
|
-
payload[:attachments] = attachments.map(&:to_hash) if attachments !=
|
158
|
-
payload[:allowed_mentions] = allowed_mentions if allowed_mentions !=
|
159
|
-
files = [file] if file !=
|
160
|
-
|
161
|
-
headers = {
|
162
|
-
"Content-Type" => "application/json",
|
163
|
-
}
|
164
|
-
else
|
165
|
-
headers, payload = HTTP.multipart(payload, files)
|
166
|
-
end
|
167
|
-
_resp, data = @http.patch("#{url}/messages/#{Utils.try(message, :id)}", payload, headers: headers).wait
|
148
|
+
payload[:content] = content if content != Discorb::Unset
|
149
|
+
payload[:embeds] = embed ? [embed.to_hash] : [] if embed != Discorb::Unset
|
150
|
+
payload[:embeds] = embeds.map(&:to_hash) if embeds != Discorb::Unset
|
151
|
+
payload[:attachments] = attachments.map(&:to_hash) if attachments != Discorb::Unset
|
152
|
+
payload[:allowed_mentions] = allowed_mentions if allowed_mentions != Discorb::Unset
|
153
|
+
files = [file] if file != Discorb::Unset
|
154
|
+
_resp, data = @http.multipart_patch("#{url}/messages/#{Utils.try(message, :id)}", payload, headers: headers).wait
|
168
155
|
message.send(:_set_data, data)
|
169
156
|
message
|
170
157
|
end
|
@@ -175,6 +162,8 @@ module Discorb
|
|
175
162
|
#
|
176
163
|
# @param [Discorb::Webhook::Message] message The message to delete.
|
177
164
|
#
|
165
|
+
# @return [Async::Task<void>] The task.
|
166
|
+
#
|
178
167
|
def delete_message!(message)
|
179
168
|
Async do
|
180
169
|
@http.delete("#{url}/messages/#{Utils.try(message, :id)}").wait
|
@@ -308,12 +297,13 @@ module Discorb
|
|
308
297
|
|
309
298
|
#
|
310
299
|
# Edits the message.
|
311
|
-
# @
|
312
|
-
# @macro http
|
300
|
+
# @async
|
313
301
|
# @macro edit
|
314
302
|
#
|
315
303
|
# @param (see Webhook#edit_message)
|
316
304
|
#
|
305
|
+
# @return [Async::Task<void>] The task.
|
306
|
+
#
|
317
307
|
def edit(...)
|
318
308
|
Async do
|
319
309
|
@webhook.edit_message(self, ...).wait
|
@@ -322,8 +312,9 @@ module Discorb
|
|
322
312
|
|
323
313
|
#
|
324
314
|
# Deletes the message.
|
325
|
-
# @
|
326
|
-
#
|
315
|
+
# @async
|
316
|
+
#
|
317
|
+
# @return [Async::Task<void>] The task.
|
327
318
|
#
|
328
319
|
def delete!
|
329
320
|
Async do
|
data/lib/discorb.rb
CHANGED
@@ -16,7 +16,7 @@ module Discorb
|
|
16
16
|
# @note You must enable `GUILD_MEMBERS` intent to use this method.
|
17
17
|
#
|
18
18
|
# @!macro edit
|
19
|
-
# @note The arguments of this method are defaultly set to
|
19
|
+
# @note The arguments of this method are defaultly set to `Discorb::Unset`. Specify value to set the value, if not don't specify or specify `Discorb::Unset`.
|
20
20
|
#
|
21
21
|
# @!macro http
|
22
22
|
# @note This method calls HTTP request.
|
@@ -41,7 +41,7 @@ end
|
|
41
41
|
|
42
42
|
require_order = %w[common flag dictionary error rate_limit http intents emoji_table modules] +
|
43
43
|
%w[user member guild emoji channel embed message] +
|
44
|
-
%w[application audit_logs color components event] +
|
44
|
+
%w[application audit_logs color components event event_handler] +
|
45
45
|
%w[file guild_template image integration interaction invite log permission] +
|
46
46
|
%w[presence reaction role sticker utils voice_state webhook] +
|
47
47
|
%w[gateway_requests gateway app_command] +
|