discorb 0.13.0 → 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/.github/workflows/build_main.yml +1 -0
- data/.github/workflows/build_version.yml +4 -3
- data/.github/workflows/crowdin.yml +32 -0
- data/.gitignore +3 -1
- data/.yardopts +2 -0
- data/CODE_OF_CONDUCT.md +128 -0
- data/Changelog.md +420 -388
- data/Gemfile +5 -1
- data/README.md +2 -2
- data/Rakefile +131 -1
- data/crowdin.yml +2 -0
- data/discorb.gemspec +12 -1
- data/docs/Examples.md +2 -0
- data/docs/application_command.md +7 -5
- 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 +6 -4
- 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 +32 -9
- data/lib/discorb/application.rb +1 -1
- data/lib/discorb/asset.rb +1 -1
- data/lib/discorb/channel.rb +170 -125
- data/lib/discorb/client.rb +20 -22
- data/lib/discorb/common.rb +32 -1
- data/lib/discorb/dictionary.rb +10 -2
- data/lib/discorb/emoji.rb +7 -9
- data/lib/discorb/emoji_table.rb +3891 -3891
- data/lib/discorb/event.rb +12 -11
- data/lib/discorb/exe/show.rb +2 -0
- data/lib/discorb/extension.rb +1 -1
- data/lib/discorb/flag.rb +1 -1
- data/lib/discorb/gateway.rb +63 -17
- data/lib/discorb/guild.rb +110 -156
- data/lib/discorb/guild_template.rb +15 -12
- data/lib/discorb/http.rb +41 -136
- data/lib/discorb/integration.rb +34 -2
- data/lib/discorb/interaction/autocomplete.rb +1 -1
- data/lib/discorb/interaction/response.rb +34 -32
- data/lib/discorb/interaction/root.rb +8 -0
- data/lib/discorb/invite.rb +4 -3
- data/lib/discorb/log.rb +3 -2
- data/lib/discorb/member.rb +44 -15
- data/lib/discorb/message.rb +33 -22
- data/lib/discorb/modules.rb +28 -35
- data/lib/discorb/presence.rb +2 -2
- data/lib/discorb/rate_limit.rb +14 -18
- data/lib/discorb/role.rb +18 -14
- data/lib/discorb/sticker.rb +10 -14
- data/lib/discorb/user.rb +10 -10
- data/lib/discorb/voice_state.rb +12 -7
- data/lib/discorb/webhook.rb +44 -50
- data/lib/discorb.rb +1 -1
- data/po/yard.pot +7772 -5154
- data/sig/discorb.rbs +3316 -3819
- data/template-replace/scripts/locale_ja.rb +62 -0
- metadata +18 -5
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>
|
@@ -9,7 +9,7 @@
|
|
9
9
|
|
10
10
|
----
|
11
11
|
|
12
|
-
discorb is a Discord API wrapper
|
12
|
+
discorb is a Discord API wrapper for Ruby, Using [socketry/async](https://github.com/socketry/async).
|
13
13
|
|
14
14
|
## Installation
|
15
15
|
|
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
|
|
@@ -156,6 +162,7 @@ namespace :document do
|
|
156
162
|
Rake::Task["document:replace:html"].execute
|
157
163
|
Rake::Task["document:replace:css"].execute
|
158
164
|
Rake::Task["document:replace:eol"].execute
|
165
|
+
Rake::Task["document:replace:locale"].execute
|
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"
|
@@ -166,6 +173,7 @@ namespace :document do
|
|
166
173
|
Rake::Task["document:replace:html"].execute
|
167
174
|
Rake::Task["document:replace:css"].execute
|
168
175
|
Rake::Task["document:replace:eol"].execute
|
176
|
+
Rake::Task["document:replace:locale"].execute
|
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"].execute
|
220
|
+
Rake::Task["document:replace"].execute
|
221
|
+
end
|
222
|
+
|
223
|
+
task :en do
|
224
|
+
Rake::Task["document"].execute("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,18 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["sevenc-nanashi"]
|
9
9
|
spec.email = ["sevenc-nanashi@sevenbot.jp"]
|
10
10
|
|
11
|
-
spec.summary = "A
|
11
|
+
spec.summary = "A Discord API wrapper for Ruby, Using socketry/async."
|
12
|
+
spec.description = <<~RDOC
|
13
|
+
== discorb
|
14
|
+
discorb is a Discord API wrapper for Ruby, Using {socketry/async}[https://github.com/socketry/async].
|
15
|
+
|
16
|
+
=== Contributing
|
17
|
+
Bug reports, feature requests, and pull requests are welcome on {the GitHub repository}[https://github.com/discorb-lib/discorb].
|
18
|
+
|
19
|
+
=== License
|
20
|
+
This gem is licensed under the MIT License.
|
21
|
+
|
22
|
+
RDOC
|
12
23
|
spec.homepage = "https://github.com/discorb-lib/discorb"
|
13
24
|
spec.license = "MIT"
|
14
25
|
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,7 +51,7 @@ 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
|
|
52
|
-
Block will be called with a {Discorb::
|
54
|
+
Block will be called with a {Discorb::Interaction} object and specified options.
|
53
55
|
|
54
56
|
In `options`, hash should be like this:
|
55
57
|
|
@@ -68,7 +70,7 @@ In `options`, hash should be like this:
|
|
68
70
|
| `:required` | Whether the argument is required. `optional` will be used if not specified. |
|
69
71
|
| `:optional` | Whether the argument is optional. `required` will be used if not specified. |
|
70
72
|
| `:type` | `Object` | Type of the option. |
|
71
|
-
| `:choice` | `Hash{String => String, Integer, Float}` |
|
73
|
+
| `:choice` | `Hash{String => String, Integer, Float}` | Choice of the option. |
|
72
74
|
| `:default` | `Object` | Default value of the option. |
|
73
75
|
| `:channel_types` | `Array<Class<Discorb::Channel>>` | Type of the channel option. |
|
74
76
|
| `:autocomplete` | `Proc` | Autocomplete function. |
|
@@ -245,9 +247,9 @@ Same as above, you can use block for register commands since v0.5.1.
|
|
245
247
|
|
246
248
|
#### Use Auto Completing
|
247
249
|
|
248
|
-
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.
|
249
251
|
The proc will be called with interaction object and the argument.
|
250
|
-
The proc should return
|
252
|
+
The proc should return a hash of the autocomplete result.
|
251
253
|
|
252
254
|
```ruby
|
253
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
|
| ---------- | ----- | ----------- |
|
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
@@ -34,8 +34,8 @@ module Discorb
|
|
34
34
|
#
|
35
35
|
# @return [Discorb::ApplicationCommand::Command::SlashCommand] Command object.
|
36
36
|
#
|
37
|
-
# @see file:docs/application_command.md#register-slash-command
|
38
|
-
# @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
|
39
39
|
#
|
40
40
|
def slash(command_name, description, options = {}, guild_ids: nil, &block)
|
41
41
|
command = Discorb::ApplicationCommand::Command::SlashCommand.new(command_name, description, options, guild_ids, block, 1, "")
|
@@ -56,8 +56,8 @@ module Discorb
|
|
56
56
|
#
|
57
57
|
# @return [Discorb::ApplicationCommand::Command::GroupCommand] Command object.
|
58
58
|
#
|
59
|
-
# @see file:docs/
|
60
|
-
# @see file:docs/cli/setup.md
|
59
|
+
# @see file:docs/application_command.md Application Commands
|
60
|
+
# @see file:docs/cli/setup.md CLI: setup
|
61
61
|
#
|
62
62
|
def slash_group(command_name, description, guild_ids: nil, &block)
|
63
63
|
command = Discorb::ApplicationCommand::Command::GroupCommand.new(command_name, description, guild_ids, nil, self)
|
@@ -73,7 +73,7 @@ module Discorb
|
|
73
73
|
# @param [Array<#to_s>, false, nil] guild_ids Guild IDs to set the command to. `false` to global command, `nil` to use default.
|
74
74
|
# @param [Proc] block Command block.
|
75
75
|
# @yield [interaction, message] Block to execute.
|
76
|
-
# @yieldparam [Discorb::
|
76
|
+
# @yieldparam [Discorb::CommandInteraction::UserMenuCommand] interaction Interaction object.
|
77
77
|
# @yieldparam [Discorb::Message] message Message object.
|
78
78
|
#
|
79
79
|
# @return [Discorb::ApplicationCommand::Command] Command object.
|
@@ -91,7 +91,7 @@ module Discorb
|
|
91
91
|
# @param [Array<#to_s>, false, nil] guild_ids Guild IDs to set the command to. `false` to global command, `nil` to use default.
|
92
92
|
# @param [Proc] block Command block.
|
93
93
|
# @yield [interaction, user] Block to execute.
|
94
|
-
# @yieldparam [Discorb::
|
94
|
+
# @yieldparam [Discorb::CommandInteraction::UserMenuCommand] interaction Interaction object.
|
95
95
|
# @yieldparam [Discorb::User] user User object.
|
96
96
|
#
|
97
97
|
# @return [Discorb::ApplicationCommand::Command] Command object.
|
@@ -104,6 +104,7 @@ module Discorb
|
|
104
104
|
|
105
105
|
#
|
106
106
|
# Setup commands.
|
107
|
+
# @async
|
107
108
|
# @see Client#initialize
|
108
109
|
#
|
109
110
|
# @param [String] token Bot token.
|
@@ -128,10 +129,32 @@ module Discorb
|
|
128
129
|
end
|
129
130
|
final_guild_ids = local_commands.map(&:guild_ids).flatten.map(&:to_s).uniq
|
130
131
|
app_info = fetch_application.wait
|
131
|
-
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
|
132
146
|
final_guild_ids.each do |guild_id|
|
133
147
|
commands = local_commands.select { |c| c.guild_ids.include?(guild_id) }
|
134
|
-
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
|
135
158
|
end unless final_guild_ids.empty?
|
136
159
|
@log.info "Successfully setup commands"
|
137
160
|
end
|
@@ -309,7 +332,7 @@ module Discorb
|
|
309
332
|
#
|
310
333
|
# @return [Discorb::ApplicationCommand::Command::SubcommandGroup] Command object.
|
311
334
|
#
|
312
|
-
# @see file:docs/
|
335
|
+
# @see file:docs/application_command.md Application Commands
|
313
336
|
#
|
314
337
|
def group(command_name, description, &block)
|
315
338
|
command = Discorb::ApplicationCommand::Command::SubcommandGroup.new(command_name, description, @name, @client)
|
data/lib/discorb/application.rb
CHANGED
@@ -131,7 +131,7 @@ module Discorb
|
|
131
131
|
# @return [:invited, :accepted] The member's membership state.
|
132
132
|
attr_reader :membership_state
|
133
133
|
alias state membership_state
|
134
|
-
# @return [Array<
|
134
|
+
# @return [Array<Symbol>] The permissions of the member.
|
135
135
|
# @note This always return `:*`.
|
136
136
|
attr_reader :permissions
|
137
137
|
|