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/Gemfile
CHANGED
@@ -7,11 +7,15 @@ gemspec
|
|
7
7
|
|
8
8
|
gem "rake", "~> 13.0"
|
9
9
|
|
10
|
-
group :
|
10
|
+
group :development, optional: true do
|
11
11
|
gem "rufo", "~> 0.13.0"
|
12
|
+
gem "sord", "~> 3.0.1"
|
12
13
|
end
|
13
14
|
|
14
15
|
group :docs, optional: true do
|
15
16
|
gem "redcarpet"
|
16
17
|
gem "yard", "~> 0.9.26"
|
18
|
+
gem "gettext", "~> 3.4.1"
|
19
|
+
gem "crowdin-api", "~> 1.0"
|
20
|
+
gem "rubyzip", "~> 2.3"
|
17
21
|
end
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
<div align="center"><img src="./assets/banner.svg" alt="discorb"></div>
|
2
2
|
|
3
|
-
<div align="center"><a href="https://discorb-lib.github.io/"><img src="https://img.shields.io/badge/Document-discorb--lib.github.io-blue.svg?style=flat-square&labelColor=2f3136" alt="Document"></a>
|
3
|
+
<div align="center"><a href="https://discorb-lib.github.io/"><img src="https://img.shields.io/badge/Document-discorb--lib.github.io-blue.svg?style=flat-square&labelColor=2f3136&logo=github&logoColor=fff" alt="Document"></a>
|
4
4
|
<a href="https://rubygems.org/gems/discorb"><img src="https://img.shields.io/gem/dt/discorb?logo=rubygems&logoColor=fff&label=Downloads&style=flat-square&labelColor=2f3136" alt="Gem"></a>
|
5
5
|
<a href="https://rubygems.org/gems/discorb"><img src="https://img.shields.io/gem/v/discorb?logo=rubygems&logoColor=fff&label=Version&style=flat-square&labelColor=2f3136" alt="Gem"></a>
|
6
6
|
<a href="https://discord.gg/hCP6zq8Vpj"><img src="https://img.shields.io/discord/863581274916913193?logo=discord&logoColor=fff&color=5865f2&label=Discord&style=flat-square&labelColor=2f3136" alt="Discord"></a>
|
data/Rakefile
CHANGED
@@ -67,7 +67,7 @@ namespace :document do
|
|
67
67
|
|
68
68
|
desc "Just generate document"
|
69
69
|
task :yard do
|
70
|
-
sh "bundle exec yardoc -o doc/#{version}"
|
70
|
+
sh "bundle exec yardoc -o doc/#{version} --locale #{ENV["rake_locale"] or "en"}"
|
71
71
|
end
|
72
72
|
|
73
73
|
desc "Replace files"
|
@@ -136,6 +136,12 @@ namespace :document do
|
|
136
136
|
end
|
137
137
|
sputs "Successfully replaced CRLF with LF"
|
138
138
|
end
|
139
|
+
|
140
|
+
task :locale do
|
141
|
+
next if ENV["rake_locale"].nil?
|
142
|
+
require_relative "template-replace/scripts/locale_#{ENV["rake_locale"]}.rb"
|
143
|
+
replace_locale("doc/main")
|
144
|
+
end
|
139
145
|
end
|
140
146
|
task :replace => %i[replace:css replace:html replace:eol]
|
141
147
|
|
@@ -152,20 +158,22 @@ namespace :document do
|
|
152
158
|
iputs "Building all versions"
|
153
159
|
FileUtils.rm_rf("doc") rescue nil
|
154
160
|
FileUtils.cp_r("./template-replace/.", "./tmp-template-replace")
|
155
|
-
Rake::Task["document:yard"].
|
156
|
-
Rake::Task["document:replace:html"].
|
157
|
-
Rake::Task["document:replace:css"].
|
158
|
-
Rake::Task["document:replace:eol"].
|
161
|
+
Rake::Task["document:yard"].invoke
|
162
|
+
Rake::Task["document:replace:html"].invoke
|
163
|
+
Rake::Task["document:replace:css"].invoke
|
164
|
+
Rake::Task["document:replace:eol"].invoke
|
165
|
+
Rake::Task["document:replace:locale"].invoke
|
159
166
|
tags = `git tag`.force_encoding("utf-8").split("\n").sort_by { |t| t[1..].split(".").map(&:to_i) }
|
160
167
|
tags.each do |tag|
|
161
168
|
sh "git checkout #{tag} -f"
|
162
169
|
iputs "Building #{tag}"
|
163
170
|
FileUtils.cp_r("./tmp-template-replace/.", "./template-replace")
|
164
171
|
version = tag.delete_prefix("v")
|
165
|
-
Rake::Task["document:yard"].
|
166
|
-
Rake::Task["document:replace:html"].
|
167
|
-
Rake::Task["document:replace:css"].
|
168
|
-
Rake::Task["document:replace:eol"].
|
172
|
+
Rake::Task["document:yard"].invoke
|
173
|
+
Rake::Task["document:replace:html"].invoke
|
174
|
+
Rake::Task["document:replace:css"].invoke
|
175
|
+
Rake::Task["document:replace:eol"].invoke
|
176
|
+
Rake::Task["document:replace:locale"].invoke
|
169
177
|
FileUtils.cp_r("./doc/.", "./tmp-doc")
|
170
178
|
FileUtils.rm_rf("doc")
|
171
179
|
end
|
@@ -190,6 +198,128 @@ namespace :document do
|
|
190
198
|
end
|
191
199
|
sputs "Successfully pushed documents"
|
192
200
|
end
|
201
|
+
|
202
|
+
namespace :locale do
|
203
|
+
task :ja do
|
204
|
+
require "crowdin-api"
|
205
|
+
require "zip"
|
206
|
+
crowdin = Crowdin::Client.new do |config|
|
207
|
+
config.api_token = ENV["CROWDIN_PERSONAL_TOKEN"]
|
208
|
+
config.project_id = ENV["CROWDIN_PROJECT_ID"].to_i
|
209
|
+
end
|
210
|
+
build = crowdin.build_project_translation["data"]["id"]
|
211
|
+
crowdin.download_project_translations("./tmp.zip", build)
|
212
|
+
|
213
|
+
Zip::File.open("tmp.zip") do |zip|
|
214
|
+
zip.each do |entry|
|
215
|
+
zip.extract(entry, entry.name) { true }
|
216
|
+
end
|
217
|
+
end
|
218
|
+
ENV["rake_locale"] = "ja"
|
219
|
+
Rake::Task["document:yard"].invoke
|
220
|
+
Rake::Task["document:replace"].invoke
|
221
|
+
end
|
222
|
+
|
223
|
+
task :en do
|
224
|
+
Rake::Task["document"].invoke("locale:en")
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
task :rbs do
|
230
|
+
require "open3"
|
231
|
+
type_errors = {
|
232
|
+
"SORD_ERROR_SymbolSymbolSymbolInteger" => "{ r: Integer, g: Integer, b: Integer}",
|
233
|
+
"SORD_ERROR_DiscorbRoleDiscorbMemberDiscorbPermissionOverwrite" => "Hash[Discorb::Role | Discorb::Member, Discorb::PermissionOverwrite]",
|
234
|
+
"SORD_ERROR_DiscorbRoleDiscorbMemberPermissionOverwrite" => "Hash[Discorb::Role | Discorb::Member, Discorb::PermissionOverwrite]",
|
235
|
+
"SORD_ERROR_f | SORD_ERROR_F | SORD_ERROR_d | SORD_ERROR_D | SORD_ERROR_t | SORD_ERROR_T | SORD_ERROR_R" => '"f" | "F" | "d" | "D" | "t" | "T" | "R"',
|
236
|
+
"SORD_ERROR_dark | SORD_ERROR_light" => '"dark" | "light"',
|
237
|
+
"SORD_ERROR_SymbolStringSymbolboolSymbolObject" => "String | Integer | Float",
|
238
|
+
}
|
239
|
+
regenerate = ARGV.include?("--regenerate") || ARGV.include?("-r")
|
240
|
+
|
241
|
+
sh "sord gen sig/discorb.rbs --keep-original-comments --no-sord-comments" + (regenerate ? " --regenerate" : " --no-regenerate")
|
242
|
+
base = File.read("sig/discorb.rbs")
|
243
|
+
base.gsub!(/\n +def _set_data: \(.+\) -> untyped\n\n/, "")
|
244
|
+
base.gsub!(/( )?( *)# @private.+?(?:\n\n(?=\1\2#)|(?=\n\2end))/sm, "")
|
245
|
+
base.gsub!(/untyped ([a-z_]*id)/, "_ToS \\1")
|
246
|
+
# #region rbs dictionary
|
247
|
+
base.gsub!(/ class Dictionary.+?end\n/ms, <<-RBS)
|
248
|
+
class Dictionary[K, V]
|
249
|
+
#
|
250
|
+
# Initialize a new Dictionary.
|
251
|
+
#
|
252
|
+
# @param [Hash] hash A hash of items to add to the dictionary.
|
253
|
+
# @param [Integer] limit The maximum number of items in the dictionary.
|
254
|
+
# @param [false, Proc] sort Whether to sort the items in the dictionary.
|
255
|
+
def initialize: (?::Hash[untyped, untyped] hash, ?limit: Integer?, ?sort: (bool | Proc)) -> void
|
256
|
+
|
257
|
+
#
|
258
|
+
# Registers a new item in the dictionary.
|
259
|
+
#
|
260
|
+
# @param [#to_s] id The ID of the item.
|
261
|
+
# @param [Object] body The item to register.
|
262
|
+
#
|
263
|
+
# @return [self] The dictionary.
|
264
|
+
def register: (_ToS id, Object body) -> self
|
265
|
+
|
266
|
+
#
|
267
|
+
# Merges another dictionary into this one.
|
268
|
+
#
|
269
|
+
# @param [Discorb::Dictionary] other The dictionary to merge.
|
270
|
+
def merge: (Discorb::Dictionary other) -> untyped
|
271
|
+
|
272
|
+
#
|
273
|
+
# Removes an item from the dictionary.
|
274
|
+
#
|
275
|
+
# @param [#to_s] id The ID of the item to remove.
|
276
|
+
def remove: (_ToS id) -> untyped
|
277
|
+
|
278
|
+
#
|
279
|
+
# Get an item from the dictionary.
|
280
|
+
#
|
281
|
+
# @param [#to_s] id The ID of the item.
|
282
|
+
# @return [Object] The item.
|
283
|
+
# @return [nil] if the item was not found.
|
284
|
+
#
|
285
|
+
# @overload get(index)
|
286
|
+
# @param [Integer] index The index of the item.
|
287
|
+
#
|
288
|
+
# @return [Object] The item.
|
289
|
+
# @return [nil] if the item is not found.
|
290
|
+
def get: (K id) -> V?
|
291
|
+
|
292
|
+
#
|
293
|
+
# Returns the values of the dictionary.
|
294
|
+
#
|
295
|
+
# @return [Array] The values of the dictionary.
|
296
|
+
def values: () -> ::Array[V]
|
297
|
+
|
298
|
+
#
|
299
|
+
# Checks if the dictionary has an ID.
|
300
|
+
#
|
301
|
+
# @param [#to_s] id The ID to check.
|
302
|
+
#
|
303
|
+
# @return [Boolean] `true` if the dictionary has the ID, `false` otherwise.
|
304
|
+
def has?: (_ToS id) -> bool
|
305
|
+
|
306
|
+
#
|
307
|
+
# Send a message to the array of values.
|
308
|
+
def method_missing: (untyped name) -> untyped
|
309
|
+
|
310
|
+
def respond_to_missing?: (untyped name, untyped args, untyped kwargs) -> bool
|
311
|
+
|
312
|
+
def inspect: () -> untyped
|
313
|
+
|
314
|
+
# @return [Integer] The maximum number of items in the dictionary.
|
315
|
+
attr_accessor limit: Integer
|
316
|
+
end
|
317
|
+
RBS
|
318
|
+
# #endregion
|
319
|
+
type_errors.each do |error, type|
|
320
|
+
base.gsub!(error, type)
|
321
|
+
end
|
322
|
+
File.write("sig/discorb.rbs", base)
|
193
323
|
end
|
194
324
|
|
195
325
|
task :document => %i[document:yard document:replace]
|
data/crowdin.yml
CHANGED
data/discorb.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["sevenc-nanashi"]
|
9
9
|
spec.email = ["sevenc-nanashi@sevenbot.jp"]
|
10
10
|
|
11
|
-
spec.summary = "
|
11
|
+
spec.summary = "A discord API wrapper written in Ruby"
|
12
12
|
spec.homepage = "https://github.com/discorb-lib/discorb"
|
13
13
|
spec.license = "MIT"
|
14
14
|
spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
|
data/docs/Examples.md
CHANGED
data/docs/application_command.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
+
<!--
|
1
2
|
# @title Application Commands
|
3
|
+
-->
|
2
4
|
|
3
5
|
# Application Commands
|
4
6
|
|
@@ -10,7 +12,7 @@ From: [Discord API docs](https://discord.com/developers/docs/interactions/applic
|
|
10
12
|
|
11
13
|
## How do I register an application command?
|
12
14
|
|
13
|
-
Write to
|
15
|
+
Write to your script:
|
14
16
|
- {Discorb::ApplicationCommand::Handler.slash}, {Discorb::ApplicationCommand::Handler.slash_group} for slash commands,
|
15
17
|
- {Discorb::ApplicationCommand::Handler.user_command} for user menu commands,
|
16
18
|
- {Discorb::ApplicationCommand::Handler.message_command} for message menu commands.
|
@@ -49,6 +51,8 @@ client.run(ENV["DISCORD_BOT_TOKEN"])
|
|
49
51
|
| `guild_ids` | The ID of the guild to register the command in. |
|
50
52
|
| `block` | A block that will be called when the command is invoked. |
|
51
53
|
|
54
|
+
Block will be called with a {Discorb::Interaction} object and specified options.
|
55
|
+
|
52
56
|
In `options`, hash should be like this:
|
53
57
|
|
54
58
|
```ruby
|
@@ -66,10 +70,11 @@ In `options`, hash should be like this:
|
|
66
70
|
| `:required` | Whether the argument is required. `optional` will be used if not specified. |
|
67
71
|
| `:optional` | Whether the argument is optional. `required` will be used if not specified. |
|
68
72
|
| `:type` | `Object` | Type of the option. |
|
69
|
-
| `:choice` | `Hash{String => String, Integer, Float}` |
|
73
|
+
| `:choice` | `Hash{String => String, Integer, Float}` | Choice of the option. |
|
70
74
|
| `:default` | `Object` | Default value of the option. |
|
71
75
|
| `:channel_types` | `Array<Class<Discorb::Channel>>` | Type of the channel option. |
|
72
76
|
| `:autocomplete` | `Proc` | Autocomplete function. |
|
77
|
+
| `:range` | `Range` | Range of the option. Only valid for numeric options. (`:int`, `:float`) |
|
73
78
|
|
74
79
|
`choices` should be unspecified if you don't want to use it.
|
75
80
|
`choices` is hash like this:
|
@@ -120,16 +125,16 @@ group.slash("message_expand", "Whether bot should expand message.", {
|
|
120
125
|
type: :boolean,
|
121
126
|
description: "Whether bot should expand message."
|
122
127
|
}
|
123
|
-
}) do |interaction|
|
128
|
+
}) do |interaction, enabled|
|
124
129
|
# ...
|
125
130
|
end
|
126
131
|
|
127
|
-
group.slash("
|
132
|
+
group.slash("level", "Whether level system is enabled.", {
|
128
133
|
"enabled" => {
|
129
134
|
type: :boolean,
|
130
|
-
description: "Whether
|
135
|
+
description: "Whether level system is enabled."
|
131
136
|
}
|
132
|
-
}) do |interaction|
|
137
|
+
}) do |interaction, enabled|
|
133
138
|
# ...
|
134
139
|
end
|
135
140
|
|
@@ -145,15 +150,15 @@ client.slash_group("settings", "Set settings of bot.") do |group|
|
|
145
150
|
type: :boolean,
|
146
151
|
description: "Whether bot should expand message."
|
147
152
|
}
|
148
|
-
}) do |interaction|
|
153
|
+
}) do |interaction, enabled|
|
149
154
|
# ...
|
150
155
|
end
|
151
|
-
group.slash("bump_alert", "Whether
|
156
|
+
group.slash("bump_alert", "Whether level system is enabled.", {
|
152
157
|
"enabled" => {
|
153
158
|
type: :boolean,
|
154
|
-
description: "Whether
|
159
|
+
description: "Whether level system is enabled."
|
155
160
|
}
|
156
|
-
}) do |interaction|
|
161
|
+
}) do |interaction, enabled|
|
157
162
|
# ...
|
158
163
|
end
|
159
164
|
end
|
@@ -242,9 +247,9 @@ Same as above, you can use block for register commands since v0.5.1.
|
|
242
247
|
|
243
248
|
#### Use Auto Completing
|
244
249
|
|
245
|
-
Since v0.11.0, you can use auto
|
250
|
+
Since v0.11.0, you can use auto-completion by setting Proc to `:autocomplete` in options.
|
246
251
|
The proc will be called with interaction object and the argument.
|
247
|
-
The proc should return
|
252
|
+
The proc should return a hash of the autocomplete result.
|
248
253
|
|
249
254
|
```ruby
|
250
255
|
client.slash("hello2", "Greet for you", {
|
data/docs/cli/irb.md
CHANGED
data/docs/cli/new.md
CHANGED
data/docs/cli/run.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
+
<!--
|
1
2
|
# @title CLI: discorb run
|
3
|
+
-->
|
2
4
|
|
3
5
|
# discorb run
|
4
6
|
|
@@ -50,7 +52,7 @@ If not specified, the default will be:
|
|
50
52
|
|
51
53
|
#### `-s`, `--setup`
|
52
54
|
|
53
|
-
Whether to
|
55
|
+
Whether to set up application commands.
|
54
56
|
|
55
57
|
#### `-e`, `--env`
|
56
58
|
|
data/docs/cli/setup.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
<!--
|
1
2
|
# @title CLI: discorb setup
|
3
|
+
-->
|
2
4
|
|
3
5
|
# discorb setup
|
4
6
|
|
5
|
-
This command will
|
7
|
+
This command will set up application commands, and call `setup` event.
|
6
8
|
|
7
9
|
## Usage
|
8
10
|
|
@@ -14,7 +16,7 @@ discorb setup [options] [script]
|
|
14
16
|
|
15
17
|
#### `script`
|
16
18
|
|
17
|
-
The script to
|
19
|
+
The script to set up. Defaults to `main.rb`.
|
18
20
|
|
19
21
|
### Options
|
20
22
|
|
data/docs/cli.md
CHANGED
data/docs/events.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
+
<!--
|
1
2
|
# @title Events
|
3
|
+
-->
|
2
4
|
|
3
5
|
# Events
|
4
6
|
|
@@ -64,7 +66,7 @@ end
|
|
64
66
|
### Client events
|
65
67
|
|
66
68
|
#### `event_receive(event_name, data)`
|
67
|
-
Fires when
|
69
|
+
Fires when an event is received.
|
68
70
|
|
69
71
|
| Parameter | Type | Description |
|
70
72
|
| ---------- | ----- | ----------- |
|
@@ -411,7 +413,7 @@ Fires when a role is deleted.
|
|
411
413
|
|
412
414
|
#### Note
|
413
415
|
|
414
|
-
These events
|
416
|
+
These events require the `guild_members` intent.
|
415
417
|
|
416
418
|
#### `member_add(member)`
|
417
419
|
|
@@ -469,7 +471,7 @@ Fires when a role is deleted.
|
|
469
471
|
|
470
472
|
#### `invite_create(invite)`
|
471
473
|
|
472
|
-
Fires when
|
474
|
+
Fires when an invitation is created.
|
473
475
|
|
474
476
|
| Parameter | Type | Description |
|
475
477
|
| ---------- | ----- | ----------- |
|
@@ -477,7 +479,7 @@ Fires when a invite is created.
|
|
477
479
|
|
478
480
|
#### `invite_delete(invite)`
|
479
481
|
|
480
|
-
Fires when
|
482
|
+
Fires when an invitation is deleted.
|
481
483
|
|
482
484
|
| Parameter | Type | Description |
|
483
485
|
| ---------- | ----- | ----------- |
|
@@ -503,7 +505,50 @@ Fires when a select menu is selected.
|
|
503
505
|
|
504
506
|
### Voice events
|
505
507
|
|
506
|
-
|
508
|
+
Because it's big, it's documented in {file:docs/voice_events.md}.
|
509
|
+
|
510
|
+
### Guild scheduled event events
|
511
|
+
|
512
|
+
#### `scheduled_event_create(event)`
|
513
|
+
|
514
|
+
Fires when a scheduled event is created.
|
515
|
+
|
516
|
+
| Parameter | Type | Description |
|
517
|
+
| ---------- | ----- | ----------- |
|
518
|
+
| `event` | {Discorb::ScheduledEvent}| The created scheduled event. |
|
519
|
+
|
520
|
+
#### `scheduled_event_cancel(event)`, `scheduled_event_delete(event)`
|
521
|
+
|
522
|
+
Fires when a scheduled event is canceled or deleted.
|
523
|
+
|
524
|
+
| Parameter | Type | Description |
|
525
|
+
| ---------- | ----- | ----------- |
|
526
|
+
| `event` | {Discorb::ScheduledEvent}| The deleted scheduled event. |
|
527
|
+
|
528
|
+
#### `scheduled_event_edit(before, after)`
|
529
|
+
|
530
|
+
Fires when a scheduled event is edited.
|
531
|
+
|
532
|
+
| Parameter | Type | Description |
|
533
|
+
| ---------- | ----- | ----------- |
|
534
|
+
| `before` | {Discorb::ScheduledEvent}| The scheduled event before the edit. |
|
535
|
+
| `after` | {Discorb::ScheduledEvent}| The scheduled event after the edit. |
|
536
|
+
|
537
|
+
#### `scheduled_event_start(event)`
|
538
|
+
|
539
|
+
Fires when a scheduled event is started.
|
540
|
+
|
541
|
+
| Parameter | Type | Description |
|
542
|
+
| ---------- | ----- | ----------- |
|
543
|
+
| `event` | {Discorb::ScheduledEvent}| The scheduled event that started. |
|
544
|
+
|
545
|
+
#### `scheduled_event_end(event)`
|
546
|
+
|
547
|
+
Fires when a scheduled event is ended.
|
548
|
+
|
549
|
+
| Parameter | Type | Description |
|
550
|
+
| ---------- | ----- | ----------- |
|
551
|
+
| `event` | {Discorb::ScheduledEvent}| The scheduled event that ended. |
|
507
552
|
|
508
553
|
### Low-level events
|
509
554
|
|
@@ -530,3 +575,12 @@ Fires when `THREAD_CREATE` is received.
|
|
530
575
|
| Parameter | Type | Description |
|
531
576
|
| ---------- | ----- | ----------- |
|
532
577
|
|`thread` | {Discorb::ThreadChannel}| The thread of the event. |
|
578
|
+
|
579
|
+
#### `scheduled_event_update(before, after)`
|
580
|
+
|
581
|
+
Fires when `SCHEDULED_EVENT_UPDATE` is received.
|
582
|
+
|
583
|
+
| Parameter | Type | Description |
|
584
|
+
| ---------- | ----- | ----------- |
|
585
|
+
| `before` | {Discorb::ScheduledEvent}| The scheduled event before the update. |
|
586
|
+
|`after` | {Discorb::ScheduledEvent}| The scheduled event after the update. |
|
data/docs/extension.md
CHANGED
data/docs/faq.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
+
<!--
|
1
2
|
# @title FAQ
|
3
|
+
-->
|
2
4
|
|
3
5
|
# Fequently asked questions
|
4
6
|
|
@@ -6,7 +8,7 @@
|
|
6
8
|
|
7
9
|
### What is `Async::Task`?
|
8
10
|
|
9
|
-
Async::Task is
|
11
|
+
Async::Task is an object for asynchronous tasks.
|
10
12
|
|
11
13
|
https://socketry.github.io/async/ for more information.
|
12
14
|
|
@@ -16,7 +18,7 @@ It means a `server` of Discord.
|
|
16
18
|
|
17
19
|
### What is difference between `User` and `Member`?
|
18
20
|
|
19
|
-
`User` is
|
21
|
+
`User` is an object for account, `Member` is an object for user in guild.
|
20
22
|
|
21
23
|
## How can I ...?
|
22
24
|
|
data/docs/license.md
CHANGED
data/docs/tutorial.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
+
<!--
|
1
2
|
# @title Tutorial
|
3
|
+
-->
|
2
4
|
|
3
5
|
# Tutorial
|
4
6
|
|
@@ -162,7 +164,7 @@ You can see your bot's response by typing `hello` in your server...
|
|
162
164
|
|
163
165
|

|
164
166
|
|
165
|
-
|
167
|
+
Oops! Your bot is responding to bot's messages, it's infinite!
|
166
168
|
|
167
169
|
Terminate your bot by typing `Ctrl + C` in terminal.
|
168
170
|
|
@@ -192,5 +194,4 @@ You did it! Your bot won't respond to bot's messages anymore.
|
|
192
194
|
This is the end of tutorial.
|
193
195
|
|
194
196
|
To learn more, check out the [documentation](https://discorb-lib.github.io/).
|
195
|
-
|
196
|
-
We hope you enjoy this lib! Thanks for reading!
|
197
|
+
You can also check out [Examples](docs/examples).
|
data/docs/voice_events.md
CHANGED
data/lib/discorb/app_command.rb
CHANGED
@@ -27,14 +27,15 @@ module Discorb
|
|
27
27
|
# | `:default` | `Object` | Default value of the option. |
|
28
28
|
# | `:channel_types` | `Array<Class<Discorb::Channel>>` | Type of the channel option. |
|
29
29
|
# | `:autocomplete` | `Proc` | Autocomplete function. |
|
30
|
+
# | `:range` | `Range` | Range of the option. Only valid for numeric options. (`:int`, `:float`) |
|
30
31
|
#
|
31
32
|
# @param [Array<#to_s>, false, nil] guild_ids Guild IDs to set the command to. `false` to global command, `nil` to use default.
|
32
33
|
# @param [Proc] block Command block.
|
33
34
|
#
|
34
35
|
# @return [Discorb::ApplicationCommand::Command::SlashCommand] Command object.
|
35
36
|
#
|
36
|
-
# @see file:docs/application_command.md#register-slash-command
|
37
|
-
# @see file:docs/cli/setup.md
|
37
|
+
# @see file:docs/application_command.md#register-slash-command Application Comamnds: Register Slash Command
|
38
|
+
# @see file:docs/cli/setup.md CLI: setup
|
38
39
|
#
|
39
40
|
def slash(command_name, description, options = {}, guild_ids: nil, &block)
|
40
41
|
command = Discorb::ApplicationCommand::Command::SlashCommand.new(command_name, description, options, guild_ids, block, 1, "")
|
@@ -55,8 +56,8 @@ module Discorb
|
|
55
56
|
#
|
56
57
|
# @return [Discorb::ApplicationCommand::Command::GroupCommand] Command object.
|
57
58
|
#
|
58
|
-
# @see file:docs/
|
59
|
-
# @see file:docs/cli/setup.md
|
59
|
+
# @see file:docs/application_command.md Application Commands
|
60
|
+
# @see file:docs/cli/setup.md CLI: setup
|
60
61
|
#
|
61
62
|
def slash_group(command_name, description, guild_ids: nil, &block)
|
62
63
|
command = Discorb::ApplicationCommand::Command::GroupCommand.new(command_name, description, guild_ids, nil, self)
|
@@ -72,7 +73,7 @@ module Discorb
|
|
72
73
|
# @param [Array<#to_s>, false, nil] guild_ids Guild IDs to set the command to. `false` to global command, `nil` to use default.
|
73
74
|
# @param [Proc] block Command block.
|
74
75
|
# @yield [interaction, message] Block to execute.
|
75
|
-
# @yieldparam [Discorb::
|
76
|
+
# @yieldparam [Discorb::CommandInteraction::UserMenuCommand] interaction Interaction object.
|
76
77
|
# @yieldparam [Discorb::Message] message Message object.
|
77
78
|
#
|
78
79
|
# @return [Discorb::ApplicationCommand::Command] Command object.
|
@@ -90,7 +91,7 @@ module Discorb
|
|
90
91
|
# @param [Array<#to_s>, false, nil] guild_ids Guild IDs to set the command to. `false` to global command, `nil` to use default.
|
91
92
|
# @param [Proc] block Command block.
|
92
93
|
# @yield [interaction, user] Block to execute.
|
93
|
-
# @yieldparam [Discorb::
|
94
|
+
# @yieldparam [Discorb::CommandInteraction::UserMenuCommand] interaction Interaction object.
|
94
95
|
# @yieldparam [Discorb::User] user User object.
|
95
96
|
#
|
96
97
|
# @return [Discorb::ApplicationCommand::Command] Command object.
|
@@ -103,6 +104,7 @@ module Discorb
|
|
103
104
|
|
104
105
|
#
|
105
106
|
# Setup commands.
|
107
|
+
# @async
|
106
108
|
# @see Client#initialize
|
107
109
|
#
|
108
110
|
# @param [String] token Bot token.
|
@@ -251,6 +253,10 @@ module Discorb
|
|
251
253
|
ret[:channel_types] = value[:channel_types].map(&:channel_type) if value[:channel_types]
|
252
254
|
|
253
255
|
ret[:autocomplete] = !!value[:autocomplete] if value[:autocomplete]
|
256
|
+
if value[:range]
|
257
|
+
ret[:min_value] = value[:range].begin
|
258
|
+
ret[:max_value] = value[:range].end
|
259
|
+
end
|
254
260
|
ret
|
255
261
|
end
|
256
262
|
{
|
@@ -304,7 +310,7 @@ module Discorb
|
|
304
310
|
#
|
305
311
|
# @return [Discorb::ApplicationCommand::Command::SubcommandGroup] Command object.
|
306
312
|
#
|
307
|
-
# @see file:docs/
|
313
|
+
# @see file:docs/application_command.md Application Commands
|
308
314
|
#
|
309
315
|
def group(command_name, description, &block)
|
310
316
|
command = Discorb::ApplicationCommand::Command::SubcommandGroup.new(command_name, description, @name, @client)
|