discorb 0.13.4 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +2 -0
  3. data/.github/workflows/codeql-analysis.yml +70 -0
  4. data/.github/workflows/lint-push.yml +18 -0
  5. data/.github/workflows/lint.yml +16 -0
  6. data/.rubocop.yml +70 -0
  7. data/Changelog.md +12 -0
  8. data/Gemfile +7 -3
  9. data/Rakefile +22 -22
  10. data/discorb.gemspec +1 -0
  11. data/examples/commands/bookmarker.rb +2 -1
  12. data/examples/commands/hello.rb +1 -0
  13. data/examples/commands/inspect.rb +3 -2
  14. data/examples/components/authorization_button.rb +2 -1
  15. data/examples/components/select_menu.rb +2 -1
  16. data/examples/extension/main.rb +1 -0
  17. data/examples/extension/message_expander.rb +1 -0
  18. data/examples/simple/eval.rb +3 -2
  19. data/examples/simple/ping_pong.rb +1 -0
  20. data/examples/simple/rolepanel.rb +1 -0
  21. data/examples/simple/wait_for_message.rb +4 -3
  22. data/exe/discorb +8 -7
  23. data/lib/discorb/allowed_mentions.rb +64 -0
  24. data/lib/discorb/app_command/command.rb +274 -0
  25. data/lib/discorb/app_command/handler.rb +168 -0
  26. data/lib/discorb/app_command.rb +2 -426
  27. data/lib/discorb/asset.rb +2 -0
  28. data/lib/discorb/audit_logs.rb +3 -3
  29. data/lib/discorb/channel.rb +19 -4
  30. data/lib/discorb/client.rb +30 -27
  31. data/lib/discorb/common.rb +4 -26
  32. data/lib/discorb/components/button.rb +106 -0
  33. data/lib/discorb/components/select_menu.rb +157 -0
  34. data/lib/discorb/components/text_input.rb +96 -0
  35. data/lib/discorb/components.rb +11 -276
  36. data/lib/discorb/dictionary.rb +3 -0
  37. data/lib/discorb/embed.rb +2 -2
  38. data/lib/discorb/emoji.rb +19 -3
  39. data/lib/discorb/emoji_table.rb +1 -1
  40. data/lib/discorb/error.rb +4 -6
  41. data/lib/discorb/event.rb +9 -7
  42. data/lib/discorb/exe/about.rb +1 -0
  43. data/lib/discorb/exe/irb.rb +4 -3
  44. data/lib/discorb/exe/new.rb +6 -7
  45. data/lib/discorb/exe/run.rb +2 -1
  46. data/lib/discorb/exe/setup.rb +8 -5
  47. data/lib/discorb/exe/show.rb +1 -0
  48. data/lib/discorb/extend.rb +19 -14
  49. data/lib/discorb/extension.rb +5 -1
  50. data/lib/discorb/gateway.rb +28 -30
  51. data/lib/discorb/guild.rb +11 -13
  52. data/lib/discorb/guild_template.rb +2 -2
  53. data/lib/discorb/http.rb +15 -17
  54. data/lib/discorb/integration.rb +1 -1
  55. data/lib/discorb/intents.rb +1 -1
  56. data/lib/discorb/interaction/autocomplete.rb +4 -3
  57. data/lib/discorb/interaction/command.rb +34 -9
  58. data/lib/discorb/interaction/components.rb +5 -2
  59. data/lib/discorb/interaction/modal.rb +33 -0
  60. data/lib/discorb/interaction/response.rb +33 -4
  61. data/lib/discorb/interaction/root.rb +1 -0
  62. data/lib/discorb/interaction.rb +2 -1
  63. data/lib/discorb/log.rb +1 -1
  64. data/lib/discorb/member.rb +1 -3
  65. data/lib/discorb/message.rb +26 -277
  66. data/lib/discorb/message_meta.rb +205 -0
  67. data/lib/discorb/modules.rb +1 -1
  68. data/lib/discorb/permission.rb +2 -2
  69. data/lib/discorb/presence.rb +4 -1
  70. data/lib/discorb/rate_limit.rb +2 -4
  71. data/lib/discorb/user.rb +1 -1
  72. data/lib/discorb/utils/colored_puts.rb +1 -0
  73. data/lib/discorb/voice_state.rb +3 -0
  74. data/lib/discorb/webhook.rb +1 -1
  75. data/lib/discorb.rb +1 -0
  76. data/template-replace/scripts/arrow.rb +1 -0
  77. data/template-replace/scripts/favicon.rb +1 -0
  78. data/template-replace/scripts/index.rb +2 -1
  79. data/template-replace/scripts/locale_ja.rb +5 -4
  80. data/template-replace/scripts/sidebar.rb +1 -0
  81. data/template-replace/scripts/version.rb +7 -10
  82. data/template-replace/scripts/yard_replace.rb +5 -4
  83. metadata +16 -2
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  LOCALES = {
2
3
  "ja" => {
3
4
  selector: {
@@ -14,15 +15,15 @@ LOCALES = {
14
15
  },
15
16
  },
16
17
 
17
- }
18
+ }.freeze
18
19
 
19
20
  def replace_sidebar_name(dir)
20
- regex = /<a target="_self" href="(.+)_list\.html">\s*([a-zA-Z ]+?)\s*<\/a>/
21
+ regex = %r{<a target="_self" href="(.+)_list\.html">\s*([a-zA-Z ]+?)\s*</a>}
21
22
 
22
23
  Dir.glob("#{dir}/*_list.html") do |file|
23
24
  content = File.read(file)
24
25
  new_content = content.dup
25
- content.scan(regex) do |url, name|
26
+ content.scan(regex) do |_url, name|
26
27
  new_content.gsub!(
27
28
  Regexp.last_match[0],
28
29
  Regexp.last_match[0].gsub(name, LOCALES[ENV["rake_locale"]][:selector][name])
@@ -33,7 +34,7 @@ def replace_sidebar_name(dir)
33
34
  end
34
35
 
35
36
  def replace_title(dir)
36
- regex = /(?:<h1 id="full_list_header">|<title>)([a-zA-Z ]+?)(?:<\/title>|<\/h1>)/
37
+ regex = %r{(?:<h1 id="full_list_header">|<title>)([a-zA-Z ]+?)(?:</title>|</h1>)}
37
38
 
38
39
  Dir.glob("#{dir}/*.html") do |file|
39
40
  content = File.read(file)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  def replace_sidebar(file)
2
3
  html = File.read(file)
3
4
  files_html = <<-HTML
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  def build_version_sidebar(dir, version)
2
3
  raw = File.read("template-replace/resources/version_list.html")
3
4
  template = raw.match(/<!--template-->(.*)<!--endtemplate-->/m)[1]
@@ -9,14 +10,12 @@ def build_version_sidebar(dir, version)
9
10
  .split("\n")
10
11
  .sort_by { |v| Gem::Version.new(v[1..]) }
11
12
  .reverse
12
- .each.with_index do |tag|
13
+ .each do |tag|
13
14
  i += 1
14
15
  sha = `git rev-parse #{tag}`.force_encoding("utf-8").strip
15
16
  tag_version = tag.delete_prefix("v")
16
- cls = i % 2 == 0 ? "even" : "odd"
17
- if tag_version == version
18
- cls += " current"
19
- end
17
+ cls = i.even? ? "even" : "odd"
18
+ cls += " current" if tag_version == version
20
19
  res += template
21
20
  .gsub("!version!", tag_version)
22
21
  .gsub("!path!", "/" + tag_version)
@@ -24,17 +23,15 @@ def build_version_sidebar(dir, version)
24
23
  .gsub("!sha!", sha)
25
24
  end
26
25
  i += 1
27
- cls = i % 2 == 0 ? "even" : "odd"
28
- if version == "main"
29
- cls += " current"
30
- end
26
+ cls = i.even? ? "even" : "odd"
27
+ cls += " current" if version == "main"
31
28
  res.insert 0, template
32
29
  .gsub("!version!", "main")
33
30
  .gsub("!path!", "/main")
34
31
  .gsub("!class!", cls)
35
32
  .gsub("!sha!", "Latest on GitHub")
36
33
  i += 1
37
- cls = i % 2 == 0 ? "even" : "odd"
34
+ cls = i.even? ? "even" : "odd"
38
35
  res.insert 0, template
39
36
  .gsub("!version!", "Latest")
40
37
  .gsub("!path!", "")
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "yard"
2
3
 
3
4
  def yard_replace(dir, version)
@@ -22,11 +23,11 @@ def yard_replace(dir, version)
22
23
  <h1 class="noborder title">Documentation by YARD 0.9.26</h1>
23
24
  HTML3
24
25
  HTML4
25
- if version == "main"
26
- display_version = "(main)"
26
+ display_version = if version == "main"
27
+ "(main)"
27
28
  else
28
- display_version = "v" + version
29
- end
29
+ "v" + version
30
+ end
30
31
  contents.gsub!(/Documentation by YARD \d+\.\d+\.\d+/, "discorb #{display_version} documentation")
31
32
  File.write(file, contents)
32
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discorb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.4
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sevenc-nanashi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-01 00:00:00.000000000 Z
11
+ date: 2022-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -83,15 +83,20 @@ executables:
83
83
  extensions: []
84
84
  extra_rdoc_files: []
85
85
  files:
86
+ - ".gitattributes"
86
87
  - ".github/ISSUE_TEMPLATE/bug_report.md"
87
88
  - ".github/ISSUE_TEMPLATE/config.yml"
88
89
  - ".github/ISSUE_TEMPLATE/feature_request.md"
89
90
  - ".github/PULL_REQUEST_TEMPLATE.md"
90
91
  - ".github/workflows/build_main.yml"
91
92
  - ".github/workflows/build_version.yml"
93
+ - ".github/workflows/codeql-analysis.yml"
92
94
  - ".github/workflows/crowdin.yml"
95
+ - ".github/workflows/lint-push.yml"
96
+ - ".github/workflows/lint.yml"
93
97
  - ".github/workflows/package_register.yml"
94
98
  - ".gitignore"
99
+ - ".rubocop.yml"
95
100
  - ".yardopts"
96
101
  - CODE_OF_CONDUCT.md
97
102
  - CONTRIBUTING.md
@@ -140,7 +145,10 @@ files:
140
145
  - examples/simple/wait_for_message.rb
141
146
  - exe/discorb
142
147
  - lib/discorb.rb
148
+ - lib/discorb/allowed_mentions.rb
143
149
  - lib/discorb/app_command.rb
150
+ - lib/discorb/app_command/command.rb
151
+ - lib/discorb/app_command/handler.rb
144
152
  - lib/discorb/application.rb
145
153
  - lib/discorb/asset.rb
146
154
  - lib/discorb/audit_logs.rb
@@ -149,6 +157,9 @@ files:
149
157
  - lib/discorb/color.rb
150
158
  - lib/discorb/common.rb
151
159
  - lib/discorb/components.rb
160
+ - lib/discorb/components/button.rb
161
+ - lib/discorb/components/select_menu.rb
162
+ - lib/discorb/components/text_input.rb
152
163
  - lib/discorb/dictionary.rb
153
164
  - lib/discorb/embed.rb
154
165
  - lib/discorb/emoji.rb
@@ -178,12 +189,14 @@ files:
178
189
  - lib/discorb/interaction/autocomplete.rb
179
190
  - lib/discorb/interaction/command.rb
180
191
  - lib/discorb/interaction/components.rb
192
+ - lib/discorb/interaction/modal.rb
181
193
  - lib/discorb/interaction/response.rb
182
194
  - lib/discorb/interaction/root.rb
183
195
  - lib/discorb/invite.rb
184
196
  - lib/discorb/log.rb
185
197
  - lib/discorb/member.rb
186
198
  - lib/discorb/message.rb
199
+ - lib/discorb/message_meta.rb
187
200
  - lib/discorb/modules.rb
188
201
  - lib/discorb/permission.rb
189
202
  - lib/discorb/presence.rb
@@ -216,6 +229,7 @@ metadata:
216
229
  source_code_uri: https://github.com/discorb-lib/discorb
217
230
  changelog_uri: https://discorb-lib.github.io/file.Changelog.html
218
231
  documentation_uri: https://discorb-lib.github.io
232
+ rubygems_mfa_required: 'true'
219
233
  post_install_message:
220
234
  rdoc_options: []
221
235
  require_paths: