discorb 0.13.4 → 0.15.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +2 -0
  3. data/.github/workflows/build_version.yml +1 -1
  4. data/.github/workflows/codeql-analysis.yml +70 -0
  5. data/.github/workflows/lint-push.yml +20 -0
  6. data/.github/workflows/lint.yml +16 -0
  7. data/.rubocop.yml +74 -0
  8. data/Changelog.md +30 -0
  9. data/Gemfile +7 -3
  10. data/Rakefile +28 -22
  11. data/discorb.gemspec +1 -0
  12. data/docs/events.md +50 -0
  13. data/docs/faq.md +8 -8
  14. data/examples/commands/bookmarker.rb +2 -1
  15. data/examples/commands/hello.rb +1 -0
  16. data/examples/commands/inspect.rb +3 -2
  17. data/examples/components/authorization_button.rb +2 -1
  18. data/examples/components/select_menu.rb +2 -1
  19. data/examples/extension/main.rb +1 -0
  20. data/examples/extension/message_expander.rb +1 -0
  21. data/examples/simple/eval.rb +3 -2
  22. data/examples/simple/ping_pong.rb +1 -0
  23. data/examples/simple/rolepanel.rb +1 -0
  24. data/examples/simple/wait_for_message.rb +4 -3
  25. data/exe/discorb +8 -7
  26. data/lib/discorb/allowed_mentions.rb +71 -0
  27. data/lib/discorb/app_command/command.rb +336 -0
  28. data/lib/discorb/app_command/handler.rb +168 -0
  29. data/lib/discorb/app_command.rb +2 -426
  30. data/lib/discorb/application.rb +16 -7
  31. data/lib/discorb/asset.rb +11 -0
  32. data/lib/discorb/{file.rb → attachment.rb} +55 -33
  33. data/lib/discorb/audit_logs.rb +45 -7
  34. data/lib/discorb/channel.rb +65 -15
  35. data/lib/discorb/client.rb +34 -27
  36. data/lib/discorb/common.rb +19 -27
  37. data/lib/discorb/components/button.rb +105 -0
  38. data/lib/discorb/components/select_menu.rb +143 -0
  39. data/lib/discorb/components/text_input.rb +96 -0
  40. data/lib/discorb/components.rb +11 -276
  41. data/lib/discorb/dictionary.rb +5 -0
  42. data/lib/discorb/embed.rb +73 -40
  43. data/lib/discorb/emoji.rb +48 -5
  44. data/lib/discorb/error.rb +9 -5
  45. data/lib/discorb/event.rb +36 -24
  46. data/lib/discorb/exe/about.rb +1 -0
  47. data/lib/discorb/exe/irb.rb +4 -3
  48. data/lib/discorb/exe/new.rb +6 -7
  49. data/lib/discorb/exe/run.rb +2 -1
  50. data/lib/discorb/exe/setup.rb +8 -5
  51. data/lib/discorb/exe/show.rb +1 -0
  52. data/lib/discorb/extend.rb +19 -14
  53. data/lib/discorb/extension.rb +5 -1
  54. data/lib/discorb/gateway.rb +112 -51
  55. data/lib/discorb/gateway_requests.rb +4 -7
  56. data/lib/discorb/guild.rb +73 -41
  57. data/lib/discorb/guild_template.rb +26 -5
  58. data/lib/discorb/http.rb +38 -18
  59. data/lib/discorb/integration.rb +24 -9
  60. data/lib/discorb/intents.rb +16 -11
  61. data/lib/discorb/interaction/autocomplete.rb +6 -5
  62. data/lib/discorb/interaction/command.rb +66 -12
  63. data/lib/discorb/interaction/components.rb +19 -3
  64. data/lib/discorb/interaction/modal.rb +33 -0
  65. data/lib/discorb/interaction/response.rb +45 -4
  66. data/lib/discorb/interaction/root.rb +16 -0
  67. data/lib/discorb/interaction.rb +2 -1
  68. data/lib/discorb/invite.rb +11 -7
  69. data/lib/discorb/log.rb +5 -5
  70. data/lib/discorb/member.rb +22 -3
  71. data/lib/discorb/message.rb +39 -234
  72. data/lib/discorb/message_meta.rb +186 -0
  73. data/lib/discorb/modules.rb +39 -15
  74. data/lib/discorb/permission.rb +16 -7
  75. data/lib/discorb/presence.rb +45 -9
  76. data/lib/discorb/rate_limit.rb +7 -4
  77. data/lib/discorb/reaction.rb +6 -0
  78. data/lib/discorb/role.rb +12 -0
  79. data/lib/discorb/sticker.rb +22 -14
  80. data/lib/discorb/user.rb +12 -1
  81. data/lib/discorb/utils/colored_puts.rb +1 -0
  82. data/lib/discorb/voice_state.rb +23 -2
  83. data/lib/discorb/webhook.rb +54 -3
  84. data/lib/discorb.rb +5 -2
  85. data/sig/discorb.rbs +838 -702
  86. data/template-replace/scripts/arrow.rb +1 -0
  87. data/template-replace/scripts/favicon.rb +1 -0
  88. data/template-replace/scripts/index.rb +2 -1
  89. data/template-replace/scripts/locale_ja.rb +5 -4
  90. data/template-replace/scripts/sidebar.rb +1 -0
  91. data/template-replace/scripts/version.rb +7 -10
  92. data/template-replace/scripts/yard_replace.rb +5 -4
  93. metadata +17 -3
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  def replace_arrow(dir)
2
3
  Dir.glob("#{dir}/**/*.html") do |file|
3
4
  content = File.read(file)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "fileutils"
2
3
 
3
4
  def add_favicon(dir)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "fileutils"
2
3
 
3
4
  def replace_index(dir, version)
@@ -5,7 +6,7 @@ def replace_index(dir, version)
5
6
  next if (m = file.match(/[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?/)) && m[0] != version
6
7
 
7
8
  content = File.read(file)
8
- content.gsub!(/(?<=["\/])_index.html/, "a_index.html")
9
+ content.gsub!(%r{(?<=["/])_index.html}, "a_index.html")
9
10
  File.write(file, content)
10
11
  end
11
12
 
@@ -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.15.1
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-03-13 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,15 +145,22 @@ 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
154
+ - lib/discorb/attachment.rb
146
155
  - lib/discorb/audit_logs.rb
147
156
  - lib/discorb/channel.rb
148
157
  - lib/discorb/client.rb
149
158
  - lib/discorb/color.rb
150
159
  - lib/discorb/common.rb
151
160
  - lib/discorb/components.rb
161
+ - lib/discorb/components/button.rb
162
+ - lib/discorb/components/select_menu.rb
163
+ - lib/discorb/components/text_input.rb
152
164
  - lib/discorb/dictionary.rb
153
165
  - lib/discorb/embed.rb
154
166
  - lib/discorb/emoji.rb
@@ -164,7 +176,6 @@ files:
164
176
  - lib/discorb/exe/show.rb
165
177
  - lib/discorb/extend.rb
166
178
  - lib/discorb/extension.rb
167
- - lib/discorb/file.rb
168
179
  - lib/discorb/flag.rb
169
180
  - lib/discorb/gateway.rb
170
181
  - lib/discorb/gateway_requests.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: