discorb 0.15.0 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +1 -0
  3. data/.github/workflows/build_main.yml +2 -2
  4. data/.github/workflows/build_version.yml +1 -1
  5. data/.github/workflows/codeql-analysis.yml +1 -1
  6. data/.github/workflows/lint-push.yml +3 -5
  7. data/.github/workflows/lint.yml +1 -1
  8. data/.github/workflows/spec.yml +30 -0
  9. data/.lefthook/commit-msg/validator.rb +5 -0
  10. data/.rspec +2 -0
  11. data/.rspec_parallel +2 -0
  12. data/.rubocop.yml +49 -8
  13. data/Changelog.md +32 -1
  14. data/Gemfile +14 -8
  15. data/Rakefile +46 -25
  16. data/bin/console +3 -3
  17. data/docs/Examples.md +1 -1
  18. data/docs/application_command.md +138 -46
  19. data/docs/cli/irb.md +2 -2
  20. data/docs/cli/new.md +14 -9
  21. data/docs/cli/run.md +7 -11
  22. data/docs/cli.md +17 -10
  23. data/docs/events.md +257 -193
  24. data/docs/extension.md +1 -2
  25. data/docs/faq.md +0 -1
  26. data/docs/tutorial.md +12 -12
  27. data/docs/voice_events.md +106 -106
  28. data/examples/commands/message.rb +63 -0
  29. data/examples/commands/permission.rb +18 -0
  30. data/examples/commands/slash.rb +44 -0
  31. data/examples/commands/user.rb +51 -0
  32. data/examples/components/authorization_button.rb +2 -2
  33. data/examples/components/select_menu.rb +2 -2
  34. data/examples/extension/main.rb +1 -1
  35. data/examples/extension/message_expander.rb +5 -2
  36. data/examples/simple/eval.rb +2 -2
  37. data/examples/simple/ping_pong.rb +1 -1
  38. data/examples/simple/rolepanel.rb +2 -2
  39. data/examples/simple/shard.rb +17 -0
  40. data/examples/simple/wait_for_message.rb +1 -1
  41. data/exe/discorb +31 -16
  42. data/lefthook.yml +45 -0
  43. data/lib/discorb/allowed_mentions.rb +8 -0
  44. data/lib/discorb/app_command/command.rb +184 -60
  45. data/lib/discorb/app_command/common.rb +25 -0
  46. data/lib/discorb/app_command/handler.rb +116 -34
  47. data/lib/discorb/app_command.rb +2 -1
  48. data/lib/discorb/application.rb +17 -7
  49. data/lib/discorb/asset.rb +10 -2
  50. data/lib/discorb/attachment.rb +17 -2
  51. data/lib/discorb/audit_logs.rb +53 -12
  52. data/lib/discorb/channel/base.rb +108 -0
  53. data/lib/discorb/channel/category.rb +32 -0
  54. data/lib/discorb/channel/container.rb +44 -0
  55. data/lib/discorb/channel/dm.rb +28 -0
  56. data/lib/discorb/channel/guild.rb +245 -0
  57. data/lib/discorb/channel/stage.rb +140 -0
  58. data/lib/discorb/channel/text.rb +345 -0
  59. data/lib/discorb/channel/thread.rb +321 -0
  60. data/lib/discorb/channel/voice.rb +79 -0
  61. data/lib/discorb/channel.rb +2 -1126
  62. data/lib/discorb/client.rb +160 -64
  63. data/lib/discorb/common.rb +18 -3
  64. data/lib/discorb/components/button.rb +7 -7
  65. data/lib/discorb/components/select_menu.rb +6 -18
  66. data/lib/discorb/components/text_input.rb +12 -2
  67. data/lib/discorb/components.rb +1 -1
  68. data/lib/discorb/dictionary.rb +2 -0
  69. data/lib/discorb/embed.rb +55 -14
  70. data/lib/discorb/emoji.rb +59 -5
  71. data/lib/discorb/emoji_table.rb +4970 -4
  72. data/lib/discorb/error.rb +7 -1
  73. data/lib/discorb/event.rb +56 -21
  74. data/lib/discorb/exe/about.rb +1 -0
  75. data/lib/discorb/exe/irb.rb +2 -4
  76. data/lib/discorb/exe/new.rb +95 -28
  77. data/lib/discorb/exe/run.rb +9 -37
  78. data/lib/discorb/exe/setup.rb +25 -12
  79. data/lib/discorb/exe/show.rb +4 -3
  80. data/lib/discorb/extend.rb +1 -0
  81. data/lib/discorb/extension.rb +6 -3
  82. data/lib/discorb/flag.rb +11 -0
  83. data/lib/discorb/gateway.rb +312 -169
  84. data/lib/discorb/gateway_requests.rb +4 -7
  85. data/lib/discorb/guild.rb +255 -89
  86. data/lib/discorb/guild_template.rb +34 -7
  87. data/lib/discorb/http.rb +23 -11
  88. data/lib/discorb/integration.rb +27 -9
  89. data/lib/discorb/intents.rb +8 -8
  90. data/lib/discorb/interaction/autocomplete.rb +31 -19
  91. data/lib/discorb/interaction/command.rb +70 -17
  92. data/lib/discorb/interaction/components.rb +20 -4
  93. data/lib/discorb/interaction/modal.rb +0 -1
  94. data/lib/discorb/interaction/response.rb +73 -22
  95. data/lib/discorb/interaction/root.rb +29 -14
  96. data/lib/discorb/interaction.rb +1 -0
  97. data/lib/discorb/invite.rb +16 -9
  98. data/lib/discorb/member.rb +46 -5
  99. data/lib/discorb/message.rb +56 -15
  100. data/lib/discorb/message_meta.rb +39 -9
  101. data/lib/discorb/modules.rb +56 -14
  102. data/lib/discorb/permission.rb +14 -5
  103. data/lib/discorb/presence.rb +43 -10
  104. data/lib/discorb/rate_limit.rb +13 -3
  105. data/lib/discorb/reaction.rb +10 -4
  106. data/lib/discorb/role.rb +31 -4
  107. data/lib/discorb/shard.rb +74 -0
  108. data/lib/discorb/sticker.rb +30 -21
  109. data/lib/discorb/user.rb +13 -1
  110. data/lib/discorb/utils/colored_puts.rb +1 -0
  111. data/lib/discorb/voice_state.rb +30 -8
  112. data/lib/discorb/webhook.rb +88 -25
  113. data/lib/discorb.rb +10 -6
  114. data/po/yard.pot +9 -9
  115. data/sig/discorb.rbs +7232 -5837
  116. metadata +23 -6
  117. data/examples/commands/bookmarker.rb +0 -42
  118. data/examples/commands/hello.rb +0 -10
  119. data/examples/commands/inspect.rb +0 -25
  120. data/lib/discorb/log.rb +0 -81
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 497fc76081f6183ccd3ec7c14768e80d81a172c092afa67f26bcec625f7b204f
4
- data.tar.gz: 5d0d4070c729b2b63d6a746fa559900b2205d51f737105d8c8653c59eec01e97
3
+ metadata.gz: 4a56213c17efa8d538ddacbbe14f5d4d32b787384e02d21cf925aa0855db59e3
4
+ data.tar.gz: a3fce194d0f243b931d3918553880656e0bac5b0228d2ccd7147cae1068e1c9b
5
5
  SHA512:
6
- metadata.gz: bf93daa59116cbd29d408e361b0cebf0e4b681c21eb2e07466f2ea2659f7bec959a58c4bf168c8b5058bb4221bb26352770c94e6bc61a9713a82d72bf98316e8
7
- data.tar.gz: aa07fe600a6397f69584a33d4b79dfd2d64952c4c1fff83a08a84418e0547a78c9b2261fce7e96a46bf19d4dab9ff0972ebe09b2ddf59371d5d74a761282c45e
6
+ metadata.gz: aaced769a9309ab29050fdd89aed3164d7dbfe67e31dba2dd6caf91c83e5b6a16b00a941edc591a529619b13fdc0ec498e0cdfdda07c21849feece7c46a63a06
7
+ data.tar.gz: 205d12c8f88eabd03de31bf9a184e84653727ebb0acc8d05daabe8f3b0e41273665855ecdf8a8456e40cdcefc64c537b756efbaf48c6dbe413ea6a1b10cd7375
data/.gitattributes CHANGED
@@ -1,2 +1,3 @@
1
1
  template-replace/**/* linguist-documentation
2
2
  sig/* linguist-generated
3
+ lib/discorb/emoji_table.rb linguist-generated
@@ -3,7 +3,7 @@ name: Build YARD with main
3
3
  on:
4
4
  workflow_dispatch:
5
5
  schedule:
6
- - cron: "*/8 * * * *"
6
+ - cron: "0 * * * *"
7
7
 
8
8
  jobs:
9
9
  main:
@@ -11,7 +11,7 @@ jobs:
11
11
  runs-on: ubuntu-latest
12
12
 
13
13
  steps:
14
- - uses: actions/checkout@v2
14
+ - uses: actions/checkout@v3
15
15
  with:
16
16
  fetch-depth: 0
17
17
  - name: Set up Ruby
@@ -11,7 +11,7 @@ jobs:
11
11
  runs-on: ubuntu-latest
12
12
 
13
13
  steps:
14
- - uses: actions/checkout@v2
14
+ - uses: actions/checkout@v3
15
15
  with:
16
16
  fetch-depth: 0
17
17
  - name: Set up Ruby
@@ -38,7 +38,7 @@ jobs:
38
38
 
39
39
  steps:
40
40
  - name: Checkout repository
41
- uses: actions/checkout@v2
41
+ uses: actions/checkout@v3
42
42
 
43
43
  # Initializes the CodeQL tools for scanning.
44
44
  - name: Initialize CodeQL
@@ -1,20 +1,18 @@
1
1
  name: Lint with RuboCop
2
2
  on:
3
3
  push:
4
- branches:
5
- - main
6
4
  jobs:
7
5
  rubocop:
8
6
  runs-on: ubuntu-latest
9
7
  steps:
10
8
  - name: Checkout repository
11
- uses: actions/checkout@v2
9
+ uses: actions/checkout@v3
12
10
  - uses: ruby/setup-ruby@v1
13
11
  with:
14
12
  ruby-version: 3.0.0
15
13
  - name: Install gems
16
14
  run: |
17
- gem install rubocop
15
+ bundle install
18
16
  - name: Run rubocop
19
17
  run: |
20
- rubocop lib
18
+ rake lint
@@ -6,7 +6,7 @@ jobs:
6
6
  runs-on: ubuntu-latest
7
7
  steps:
8
8
  - name: Checkout repository
9
- uses: actions/checkout@v2
9
+ uses: actions/checkout@v3
10
10
  - uses: ruby/setup-ruby@v1
11
11
  with:
12
12
  ruby-version: 3.0.0
@@ -0,0 +1,30 @@
1
+ name: Run spec
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ branches:
7
+ - main
8
+
9
+ jobs:
10
+ main:
11
+ strategy:
12
+ matrix:
13
+ ruby-version:
14
+ - "3.0"
15
+ - "3.1"
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - name: Set up Ruby
19
+ uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: ${{ matrix.ruby-version }}
22
+ bundler-cache: true
23
+ - name: Checkout repository
24
+ uses: actions/checkout@v3
25
+ - name: Install dependencies
26
+ run: |
27
+ bundle install
28
+ gem update uri
29
+ - name: Run spec
30
+ run: bundle exec rake spec
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ message = File.read(ARGV[0])
4
+ raise "Commit message is empty" if message.empty?
5
+ raise "Commit message must be ASCII" unless message.ascii_only?
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ -P spec/**/*.rb
2
+ -p
data/.rspec_parallel ADDED
@@ -0,0 +1,2 @@
1
+ spec/*.spec.rb
2
+ spec/**/*.spec.rb
data/.rubocop.yml CHANGED
@@ -2,25 +2,57 @@ AllCops:
2
2
  NewCops: enable
3
3
  TargetRubyVersion: 3.0
4
4
  Exclude:
5
- - examples/**/*.rb
5
+ - lib/discorb/emoji_table.rb
6
6
 
7
- Layout:
8
- Enabled: false
7
+ require:
8
+ - rubocop-rake
9
+ - rubocop-rspec
10
+
11
+ # Layout:
12
+ # Enabled: false
9
13
  Metrics:
10
14
  Enabled: false
11
15
 
12
- Style/TrailingCommaInHashLiteral: # Disabled for rufo
16
+ Layout/EndOfLine:
17
+ EnforcedStyle: lf
18
+
19
+ Layout/IndentationWidth:
20
+ AllowedPatterns: ['if']
21
+
22
+ Layout/HeredocIndentation:
13
23
  Enabled: false
14
24
 
15
- Style/StringLiterals: # Disabled for rufo
25
+ Layout/ClosingHeredocIndentation:
16
26
  Enabled: false
17
27
 
28
+ Layout/CaseIndentation:
29
+ Enabled: false
30
+
31
+ Layout/ElseAlignment:
32
+ Enabled: false
33
+
34
+ Layout/EndAlignment:
35
+ Enabled: false
36
+
37
+ Style/TrailingCommaInHashLiteral: # Disabled for rufo
38
+ EnforcedStyleForMultiline: consistent_comma
39
+
40
+ Style/TrailingCommaInArrayLiteral: # Disabled for rufo
41
+ EnforcedStyleForMultiline: consistent_comma
42
+
43
+ Style/StringLiterals: # Disabled for rufo
44
+ Enabled: true
45
+ EnforcedStyle: double_quotes
46
+
18
47
  Style/TrailingCommaInArguments: # Disabled for rufo
19
48
  Enabled: false
20
49
 
21
50
  Style/StringLiteralsInInterpolation: # Disabled for rufo
22
51
  Enabled: false
23
52
 
53
+ Layout/SpaceAroundOperators: # Changed for rufo
54
+ EnforcedStyleForExponentOperator: space
55
+
24
56
  Style/StringConcatenation: # + looks better
25
57
  Enabled: false
26
58
 
@@ -63,8 +95,17 @@ Lint/Debugger: # For /exe
63
95
  Style/GuardClause: # For make it extendable
64
96
  Enabled: false
65
97
 
66
- Layout/EndOfLine: # For git
67
- EnforcedStyle: lf
68
-
69
98
  Lint/ScriptPermission: # For GitHub Actions
99
+ Enabled: false
100
+
101
+ Style/NumericLiterals: # For style
102
+ Enabled: false
103
+
104
+ RSpec/FilePath:
105
+ Enabled: false
106
+
107
+ RSpec/ExampleLength:
108
+ Enabled: false
109
+
110
+ RSpec/MultipleExpectations:
70
111
  Enabled: false
data/Changelog.md CHANGED
@@ -4,8 +4,40 @@
4
4
 
5
5
  # Changelog
6
6
 
7
+ ## v0.17
8
+
9
+ ### v0.17.0
10
+
11
+ - Change!: Delete `Interaction#target` and `Interaction#fired_by`.
12
+ - Change: `Interaction#user` and `Interaction#member` are same.
13
+ - Add: Include Messageable in VoiceChannel
14
+ - Add: Add `--[no-]bundler` option to `discorb` command.
15
+ - Add: Add `--[no-]comment` option to `discorb new` command.
16
+ - Fix PermissionOverwrite was initialized with string.
17
+ - Fix emoji with different skin tones raises ArgumentError.
18
+ - Fix `Asset#endpoint` raises NameError.
19
+ - Fix `:error` event may call itself.
20
+
21
+ ## v0.16
22
+
23
+ ### v0.16.0
24
+
25
+ - Change!: Use built-in Logger instead of custom Logger.
26
+ - Delete!: `--log-level`, `--[no-]log-color` is deleted.
27
+ - Add: Support sharding
28
+ - Add: Use Mutex for preventing connection duplications.
29
+
7
30
  ## v0.15
8
31
 
32
+ ### v0.15.1
33
+
34
+ - Add: Add `Member#can_manage?`
35
+ - Add: Add `Discorb::VERSION_ARRAY`
36
+ - Fix: `Snowflake#timestamp` includes milliseconds now
37
+ - Fix: `TextChannel#create_invite` will no longer return `ArgumentError`
38
+ - Fix: Connection will not closed with 4001 when `Client#update_presence`
39
+ is called
40
+
9
41
  ### v0.15.0
10
42
 
11
43
  - Add: Migrate to API v10
@@ -438,4 +470,3 @@ end
438
470
  ### v0.0.1
439
471
 
440
472
  - Initial release
441
-
data/Gemfile CHANGED
@@ -7,10 +7,20 @@ gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
9
 
10
- group :development, optional: true do
11
- gem "rufo", "~> 0.13.0"
12
- gem "sord", "~> 3.0.1"
13
- end
10
+ # Rubocop
11
+ gem "rubocop", "~> 1.25"
12
+ gem "rubocop-rake", "~> 0.6.0"
13
+ gem "rubocop-rspec", "~> 2.9"
14
+
15
+ # RSpec
16
+ gem "async-rspec", "~> 1.16"
17
+ gem "parallel_tests", "~> 3.8"
18
+ gem "rspec", "~> 3.11"
19
+
20
+ # Other development tools
21
+ gem "lefthook", "~> 0.7.7"
22
+ gem "rufo", "~> 0.13.0"
23
+ gem "sord", "~> 3.0.1"
14
24
 
15
25
  group :docs, optional: true do
16
26
  gem "crowdin-api", "~> 1.0"
@@ -19,7 +29,3 @@ group :docs, optional: true do
19
29
  gem "rubyzip", "~> 2.3"
20
30
  gem "yard", "~> 0.9.26"
21
31
  end
22
-
23
- group :lint, optional: true do
24
- gem "rubocop", "~> 1.25"
25
- end
data/Rakefile CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "bundler/gem_tasks"
4
4
  require_relative "lib/discorb/utils/colored_puts"
5
+ require "parallel_tests"
5
6
  task default: %i[]
6
7
 
7
8
  # @private
@@ -15,6 +16,11 @@ def current_version
15
16
  end
16
17
  end
17
18
 
19
+ desc "Run spec with parallel_rspec"
20
+ task :spec do
21
+ sh "parallel_rspec spec/*.spec.rb spec/**/*.spec.rb"
22
+ end
23
+
18
24
  desc "Build emoji_table.rb"
19
25
  task :emoji_table do
20
26
  require_relative "lib/discorb"
@@ -65,7 +71,7 @@ namespace :document do
65
71
  version = current_version
66
72
  desc "Just generate document"
67
73
  task :yard do
68
- sh "bundle exec yardoc -o doc/#{version} --locale #{ENV["rake_locale"] or "en"}"
74
+ sh "bundle exec yardoc -o doc/#{version} --locale #{ENV.fetch("rake_locale", nil) or "en"}"
69
75
  end
70
76
 
71
77
  desc "Replace files"
@@ -76,7 +82,7 @@ namespace :document do
76
82
  task :css do
77
83
  iputs "Replacing css"
78
84
  Dir.glob("template-replace/files/**/*.*")
79
- .map { |f| f.delete_prefix("template-replace/files") }.each do |file|
85
+ .map { |f| f.delete_prefix("template-replace/files") }.each do |file|
80
86
  FileUtils.cp("template-replace/files" + file, "doc/#{version}/#{file}")
81
87
  end
82
88
  sputs "Successfully replaced css"
@@ -135,9 +141,11 @@ namespace :document do
135
141
  sputs "Successfully replaced CRLF with LF"
136
142
  end
137
143
 
144
+ desc "change locale of current document"
138
145
  task :locale do
139
146
  next if ENV["rake_locale"].nil?
140
- require_relative "template-replace/scripts/locale_#{ENV["rake_locale"]}.rb"
147
+
148
+ require_relative "template-replace/scripts/locale_#{ENV.fetch("rake_locale", nil)}.rb"
141
149
  replace_locale("doc/main")
142
150
  end
143
151
  end
@@ -196,11 +204,12 @@ namespace :document do
196
204
  end
197
205
 
198
206
  namespace :locale do
207
+ desc "Generate Japanese document"
199
208
  task :ja do
200
209
  require "crowdin-api"
201
210
  require "zip"
202
211
  crowdin = Crowdin::Client.new do |config|
203
- config.api_token = ENV["CROWDIN_PERSONAL_TOKEN"]
212
+ config.api_token = ENV.fetch("CROWDIN_PERSONAL_TOKEN", nil)
204
213
  config.project_id = ENV["CROWDIN_PROJECT_ID"].to_i
205
214
  end
206
215
  build = crowdin.build_project_translation["data"]["id"]
@@ -216,14 +225,17 @@ namespace :document do
216
225
  Rake::Task["document:replace"].execute
217
226
  end
218
227
 
228
+ desc "Generate English document"
219
229
  task :en do
220
230
  Rake::Task["document"].execute("locale:en")
221
231
  end
222
232
  end
223
233
  end
224
234
 
235
+ desc "Generate rbs file using sord"
225
236
  task :rbs do
226
237
  require "open3"
238
+ # rubocop: disable Layout/LineLength
227
239
  type_errors = {
228
240
  "SORD_ERROR_SymbolSymbolSymbolInteger" => "{ r: Integer, g: Integer, b: Integer}",
229
241
  "SORD_ERROR_DiscorbRoleDiscorbMemberDiscorbPermissionOverwrite" => "Hash[Discorb::Role | Discorb::Member, Discorb::PermissionOverwrite]",
@@ -232,9 +244,11 @@ task :rbs do
232
244
  "SORD_ERROR_dark | SORD_ERROR_light" => '"dark" | "light"',
233
245
  "SORD_ERROR_SymbolStringSymbolboolSymbolObject" => "String | Integer | Float",
234
246
  }
247
+ # rubocop: enable Layout/LineLength
235
248
  regenerate = ARGV.include?("--regenerate") || ARGV.include?("-r")
236
249
 
237
- sh "sord gen sig/discorb.rbs --keep-original-comments --no-sord-comments" + (regenerate ? " --regenerate" : " --no-regenerate")
250
+ sh "sord gen sig/discorb.rbs --keep-original-comments --no-sord-comments" +
251
+ (regenerate ? " --regenerate" : " --no-regenerate")
238
252
  base = File.read("sig/discorb.rbs")
239
253
  base.gsub!(/\n +def _set_data: \(.+\) -> untyped\n\n/, "")
240
254
  base.gsub!(/( )?( *)# @private.+?(?:\n\n(?=\1\2#)|(?=\n\2end))/sm, "")
@@ -242,64 +256,64 @@ task :rbs do
242
256
  # #region rbs dictionary
243
257
  base.gsub!(/ class Dictionary.+?end\n/ms, <<-RBS)
244
258
  class Dictionary[K, V]
245
- #
259
+ ##{" "}
246
260
  # Initialize a new Dictionary.
247
- #
261
+ ##{" "}
248
262
  # @param [Hash] hash A hash of items to add to the dictionary.
249
263
  # @param [Integer] limit The maximum number of items in the dictionary.
250
264
  # @param [false, Proc] sort Whether to sort the items in the dictionary.
251
265
  def initialize: (?::Hash[untyped, untyped] hash, ?limit: Integer?, ?sort: (bool | Proc)) -> void
252
266
 
253
- #
267
+ ##{" "}
254
268
  # Registers a new item in the dictionary.
255
- #
269
+ ##{" "}
256
270
  # @param [#to_s] id The ID of the item.
257
271
  # @param [Object] body The item to register.
258
- #
272
+ ##{" "}
259
273
  # @return [self] The dictionary.
260
274
  def register: (_ToS id, Object body) -> self
261
275
 
262
- #
276
+ ##{" "}
263
277
  # Merges another dictionary into this one.
264
- #
278
+ ##{" "}
265
279
  # @param [Discorb::Dictionary] other The dictionary to merge.
266
280
  def merge: (Discorb::Dictionary other) -> untyped
267
281
 
268
- #
282
+ ##{" "}
269
283
  # Removes an item from the dictionary.
270
- #
284
+ ##{" "}
271
285
  # @param [#to_s] id The ID of the item to remove.
272
286
  def remove: (_ToS id) -> untyped
273
287
 
274
- #
288
+ ##{" "}
275
289
  # Get an item from the dictionary.
276
- #
290
+ ##{" "}
277
291
  # @param [#to_s] id The ID of the item.
278
292
  # @return [Object] The item.
279
293
  # @return [nil] if the item was not found.
280
- #
294
+ ##{" "}
281
295
  # @overload get(index)
282
296
  # @param [Integer] index The index of the item.
283
- #
297
+ ##{" "}
284
298
  # @return [Object] The item.
285
299
  # @return [nil] if the item is not found.
286
300
  def get: (K id) -> V?
287
301
 
288
- #
302
+ ##{" "}
289
303
  # Returns the values of the dictionary.
290
- #
304
+ ##{" "}
291
305
  # @return [Array] The values of the dictionary.
292
306
  def values: () -> ::Array[V]
293
307
 
294
- #
308
+ ##{" "}
295
309
  # Checks if the dictionary has an ID.
296
- #
310
+ ##{" "}
297
311
  # @param [#to_s] id The ID to check.
298
- #
312
+ ##{" "}
299
313
  # @return [Boolean] `true` if the dictionary has the ID, `false` otherwise.
300
314
  def has?: (_ToS id) -> bool
301
315
 
302
- #
316
+ ##{" "}
303
317
  # Send a message to the array of values.
304
318
  def method_missing: (untyped name) -> untyped
305
319
 
@@ -315,11 +329,18 @@ task :rbs do
315
329
  type_errors.each do |error, type|
316
330
  base.gsub!(error, type)
317
331
  end
332
+ base.gsub!("end\n\n\nend", "end\n")
318
333
  File.write("sig/discorb.rbs", base)
319
334
  end
320
335
 
321
336
  task document: %i[document:yard document:replace]
322
337
 
338
+ desc "Lint code with rubocop"
323
339
  task :lint do
324
- sh "rubocop lib"
340
+ sh "rubocop lib spec Rakefile"
341
+ end
342
+
343
+ desc "Autofix code with rubocop"
344
+ task "lint:fix" do
345
+ sh "rubocop lib spec Rakefile -A"
325
346
  end
data/bin/console CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'bundler/setup'
5
- require 'discorb'
4
+ require "bundler/setup"
5
+ require "discorb"
6
6
 
7
7
  # You can add fixtures and/or initialization code here to make experimenting
8
8
  # with your gem easier. You can also use a different console, if you like.
@@ -11,5 +11,5 @@ require 'discorb'
11
11
  # require "pry"
12
12
  # Pry.start
13
13
 
14
- require 'irb'
14
+ require "irb"
15
15
  IRB.start(__FILE__)
data/docs/Examples.md CHANGED
@@ -25,4 +25,4 @@
25
25
  #### Note
26
26
 
27
27
  This example is not shown correctly in the docs.
28
- [Read this example on GitHub](https://github.com/discorb-lib/discorb/blob/main/examples/components/select_menu.rb).
28
+ [Read this example on GitHub](https://github.com/discorb-lib/discorb/blob/main/examples/components/select_menu.rb).