discorb 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7cbb9d9b8bc52a96963769da188aadd9ba90a69fea99180ab5ead21688d66dff
4
- data.tar.gz: ea4fc64d658da53ae3ea2fb4f22158b7ceb2d23f121f9805755c7764d570565c
3
+ metadata.gz: 4f5c9c3f2c3e472300d1fe8462b9e667008bce0a30d11b2ce6cf866f697aedb0
4
+ data.tar.gz: d2c2fa2edd51a84a1001675d0572bfae3464f5d25b85865a95a7c7f5daebf109
5
5
  SHA512:
6
- metadata.gz: 3cd9d2c4e0fb5594208c2f9f7e88227048f8ee9cea83cbc55a82c2161f10477299ed258e92b4d63ad9c5d62502b489d06289421a28b8fc07d8fababa81300379
7
- data.tar.gz: '0901bdff3462640d611e94e456035e7b5f27918fc56189b1d841fb19e92d51b2e72cb2b1970335656c3b42607523009a79dd4c57c83b44433a9013cbd1ecf350'
6
+ metadata.gz: ed4bb639464a3adc7a5982088149421d6d15f7e3c4be37bb59855a5d106ee5a1e1756b10ba401fd3d3ced9008c15e99bb3967f93eb7ff197903fb6cf95e19699
7
+ data.tar.gz: fc6809db6b8e7a7e65e70fb49ce3b25a2aa4f42145477730e234511a95f278879759d76f5ee9547fa213f34ce3c413f5ba167c7f042d7f73a954718ba22e51d4
data/.gitignore CHANGED
@@ -53,4 +53,5 @@ build-iPhoneSimulator/
53
53
  .rvmrc
54
54
 
55
55
  # Used by RuboCop. Remote config files pulled in from inherit_from directive.
56
- # .rubocop-https?--*
56
+ # .rubocop-https?--*
57
+ tmp-template-replace
data/.yardopts CHANGED
@@ -2,6 +2,7 @@
2
2
  --no-private
3
3
  --markup markdown
4
4
  --tag flags:"Flags"
5
+ --verbose
5
6
  -
6
- docs/*.md
7
+ docs/**/*.md
7
8
  Changelog.md
data/Changelog.md CHANGED
@@ -56,4 +56,21 @@
56
56
  ## 0.2.1
57
57
 
58
58
  - Fix: Fix NoMethodError in reaction event
59
- - Add: Add Changelog.md to document
59
+ - Add: Add Changelog.md to document
60
+
61
+ ## 0.2.2 (yanked)
62
+
63
+ - Add: Add `Snowflake#to_str`
64
+
65
+ ## 0.2.3
66
+
67
+ - Fix: Fix critical error
68
+
69
+ ## 0.2.4
70
+
71
+ - Fix: Fix error in `Embed#image=`, `Embed#thumbnail=`
72
+
73
+ ## 0.2.5
74
+
75
+ - Add: Add way to add event listener
76
+ - Change: Move document to https://discorb-lib.github.io/
data/Gemfile CHANGED
@@ -1,22 +1,17 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- # Specify your gem's dependencies in discorb.gemspec
6
- gemspec
7
-
8
- gem "rake", "~> 13.0"
9
-
10
- gem "async"
11
- gem "async-websocket"
12
-
13
- gem "mime-types", "~> 3.3"
14
-
15
- group :debug, optional: true do
16
- gem "rufo", "~> 0.13.0"
17
- end
18
-
19
- group :docs, optional: true do
20
- gem "redcarpet"
21
- gem "yard", "~> 0.9.26"
22
- end
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in discorb.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ group :debug, optional: true do
11
+ gem "rufo", "~> 0.13.0"
12
+ end
13
+
14
+ group :docs, optional: true do
15
+ gem "redcarpet"
16
+ gem "yard", "~> 0.9.26"
17
+ end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- discorb (0.2.1)
4
+ discorb (0.3.0)
5
5
  async
6
6
  async-http
7
7
  async-websocket
@@ -10,7 +10,7 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- async (1.30.0)
13
+ async (1.30.1)
14
14
  console (~> 1.10)
15
15
  nio4r (~> 2.3)
16
16
  timers (~> 4.1)
@@ -34,11 +34,11 @@ GEM
34
34
  fiber-local (1.0.0)
35
35
  mime-types (3.3.1)
36
36
  mime-types-data (~> 3.2015)
37
- mime-types-data (3.2021.0704)
38
- nio4r (2.5.7)
37
+ mime-types-data (3.2021.0901)
38
+ nio4r (2.5.8)
39
39
  protocol-hpack (1.4.2)
40
40
  protocol-http (0.22.5)
41
- protocol-http1 (0.14.1)
41
+ protocol-http1 (0.14.2)
42
42
  protocol-http (~> 0.22)
43
43
  protocol-http2 (0.14.2)
44
44
  protocol-hpack (~> 1.4)
@@ -56,10 +56,7 @@ PLATFORMS
56
56
  x86-mingw32
57
57
 
58
58
  DEPENDENCIES
59
- async
60
- async-websocket
61
59
  discorb!
62
- mime-types (~> 3.3)
63
60
  rake (~> 13.0)
64
61
  redcarpet
65
62
  rufo (~> 0.13.0)
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # discorb
2
- [![rubydoc](https://img.shields.io/badge/Document-rubydoc.info-blue.svg)](https://rubydoc.info/gems/discorb)
2
+ [![Document](https://img.shields.io/badge/Document-discord--lib.github.io-blue.svg)](https://discorb-lib.github.io/)
3
3
  [![Gem](https://img.shields.io/gem/dt/discorb?logo=rubygems&logoColor=fff)](https://rubygems.org/gems/discorb)
4
4
  [![Gem](https://img.shields.io/gem/v/discorb?logo=rubygems&logoColor=fff)](https://rubygems.org/gems/discorb)
5
5
  [![Discord](https://img.shields.io/discord/863581274916913193?logo=discord&logoColor=fff&color=5865f2&label=Discord)](https://discord.gg/hCP6zq8Vpj)
data/Rakefile CHANGED
@@ -1,46 +1,159 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- task default: %i[]
5
-
6
- task :emoji_table do
7
- require_relative "lib/discorb"
8
-
9
- res = {}
10
- Discorb::EmojiTable::DISCORD_TO_UNICODE.each do |discord, unicode|
11
- res[unicode] ||= []
12
- res[unicode] << discord
13
- end
14
-
15
- res_text = +""
16
- res.each do |unicode, discord|
17
- res_text << %(#{unicode.unpack("C*").pack("C*").inspect} => %w[#{discord.join(" ")}],\n)
18
- end
19
-
20
- table_script = File.read("lib/discorb/emoji_table.rb")
21
-
22
- table_script.gsub!(/(?<=UNICODE_TO_DISCORD = {\n)[\s\S]+(?=}\.freeze)/, res_text)
23
-
24
- File.open("lib/discorb/emoji_table.rb", "w") do |f|
25
- f.print(table_script)
26
- end
27
- `rubocop -A lib/discorb/emoji_table.rb`
28
- puts "Successfully made emoji_table.rb"
29
- end
30
-
31
- task :format do
32
- Dir.glob("**/*.rb").each do |file|
33
- next if file.start_with?("vendor")
34
-
35
- puts "Formatting #{file}"
36
- `rufo ./#{file}`
37
- content = ""
38
- File.open(file, "rb") do |f|
39
- content = f.read
40
- end
41
- content.gsub!("\r\n", "\n")
42
- File.open(file, "wb") do |f|
43
- f.print(content)
44
- end
45
- end
46
- end
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
5
+
6
+ def get_version
7
+ require_relative "lib/discorb/common"
8
+ latest_commit = `git log --oneline`.force_encoding("utf-8").split("\n")[0]
9
+ version = Discorb::VERSION
10
+ unless latest_commit.downcase.include?("update version")
11
+ version += "-dev"
12
+ end
13
+ version
14
+ end
15
+
16
+ def gputs(text)
17
+ puts "\e[90m#{text}\e[m"
18
+ end
19
+
20
+ def sputs(text)
21
+ puts "\e[92m#{text}\e[m"
22
+ end
23
+
24
+ task :emoji_table do
25
+ require_relative "lib/discorb"
26
+
27
+ gputs "Building emoji_table.rb"
28
+ res = {}
29
+ Discorb::EmojiTable::DISCORD_TO_UNICODE.each do |discord, unicode|
30
+ res[unicode] ||= []
31
+ res[unicode] << discord
32
+ end
33
+
34
+ res_text = +""
35
+ res.each do |unicode, discord|
36
+ res_text << %(#{unicode.unpack("C*").pack("C*").inspect} => %w[#{discord.join(" ")}],\n)
37
+ end
38
+
39
+ table_script = File.read("lib/discorb/emoji_table.rb")
40
+
41
+ table_script.gsub!(/(?<=UNICODE_TO_DISCORD = {\n)[\s\S]+(?=}\.freeze)/, res_text)
42
+
43
+ File.open("lib/discorb/emoji_table.rb", "w") do |f|
44
+ f.print(table_script)
45
+ end
46
+ `rufo lib/discorb/emoji_table.rb`
47
+ sputs "Successfully made emoji_table.rb"
48
+ end
49
+
50
+ task :format do
51
+ Dir.glob("**/*.rb").each do |file|
52
+ next if file.start_with?("vendor")
53
+
54
+ gputs "Formatting #{file}"
55
+ `rufo ./#{file}`
56
+ content = ""
57
+ File.open(file, "rb") do |f|
58
+ content = f.read
59
+ end
60
+ content.gsub!("\r\n", "\n")
61
+ File.open(file, "wb") do |f|
62
+ f.print(content)
63
+ end
64
+ end
65
+ end
66
+ namespace :document do
67
+ version = get_version
68
+ task :yard do
69
+ sh "yardoc -o doc/#{version}"
70
+ end
71
+ namespace :replace do
72
+ require "fileutils"
73
+ task :css do
74
+ gputs "Replacing css"
75
+ Dir.glob("template-replace/files/**/*.*")
76
+ .map { |f| f.delete_prefix("template-replace/files") }.each do |file|
77
+ FileUtils.cp("template-replace/files" + file, "doc/#{version}/#{file}")
78
+ end
79
+ sputs "Successfully replaced css"
80
+ end
81
+ task :html do
82
+ require_relative "template-replace/scripts/sidebar.rb"
83
+ require_relative "template-replace/scripts/version.rb"
84
+ require_relative "template-replace/scripts/index.rb"
85
+ require_relative "template-replace/scripts/yard_replace.rb"
86
+ gputs "Resetting changes"
87
+ Dir.glob("doc/#{version}/**/*.html") do |f|
88
+ next if (m = f.match(/[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?/)) && m[0] != version
89
+
90
+ content = File.read(f)
91
+ content.gsub!(/<!--od-->[\s\S]*<!--eod-->/, "")
92
+ File.write(f, content)
93
+ end
94
+ gputs "Adding version tab"
95
+ %w[file_list class_list method_list].each do |f|
96
+ replace_sidebar("doc/#{version}/#{f}.html")
97
+ end
98
+
99
+ gputs "Building version tab"
100
+ build_version_sidebar("doc/#{version}")
101
+ gputs "Replacing _index.html"
102
+ replace_index("doc/#{version}", version)
103
+ gputs "Replacing YARD credits"
104
+ yard_replace("doc/#{version}", version)
105
+ gputs "Successfully replaced htmls"
106
+ end
107
+ task :eol do
108
+ gputs "Replacing CRLF with LF"
109
+ Dir.glob("doc/**/*.*") do |file|
110
+ next unless File.file?(file)
111
+
112
+ content = ""
113
+ File.open(file, "rb") do |f|
114
+ content = f.read
115
+ end
116
+ content.gsub!("\r\n", "\n")
117
+ File.open(file, "wb") do |f|
118
+ f.print(content)
119
+ end
120
+ end
121
+ sputs "Successfully replaced CRLF with LF"
122
+ end
123
+ end
124
+ task :replace => %i[replace:css replace:html replace:eol]
125
+ task :build_all do
126
+ require "fileutils"
127
+ gputs "Building all versions"
128
+ FileUtils.cp_r("./template-replace/.", "./tmp-template-replace")
129
+ tags = `git tag`.force_encoding("utf-8").split("\n")
130
+ tags.each do |tag|
131
+ sh "git checkout #{tag} -f"
132
+ gputs "Building #{tag}"
133
+ FileUtils.cp_r("./tmp-template-replace/.", "./template-replace")
134
+ version = tag.delete_prefix("v")
135
+ Rake::Task["document:yard"].execute
136
+ Rake::Task["document:replace:html"].execute
137
+ Rake::Task["document:replace:css"].execute
138
+ Rake::Task["document:replace:eol"].execute
139
+ end
140
+ version = "."
141
+ Rake::Task["document:yard"].execute
142
+ Rake::Task["document:replace:html"].execute
143
+ Rake::Task["document:replace:css"].execute
144
+ Rake::Task["document:replace:eol"].execute
145
+ sh "git switch main -f"
146
+ sputs "Successfully built all versions"
147
+ end
148
+ task :push do
149
+ gputs "Pushing documents"
150
+ Dir.chdir("doc") do
151
+ sh "git add ."
152
+ sh "git commit -m \"Update: Update document\""
153
+ sh "git push -f"
154
+ end
155
+ sputs "Successfully pushed documents"
156
+ end
157
+ end
158
+
159
+ task :document => %i[document:yard document:replace]
data/crowdin.yml ADDED
@@ -0,0 +1,3 @@
1
+ files:
2
+ - source: /po/yard.pot
3
+ translation: /po/%two_letters_code%.po
data/discorb.gemspec CHANGED
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.metadata["homepage_uri"] = spec.homepage
19
19
  spec.metadata["source_code_uri"] = "https://github.com/discorb-lib/discorb"
20
20
  spec.metadata["changelog_uri"] = "https://github.com/discorb-lib/discorb/blob/main/Changelog.md"
21
+ spec.metadata["documentation_uri"] = "https://discorb-lib.github.io"
21
22
 
22
23
  # Specify which files should be added to the gem when it is released.
23
24
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -10,7 +10,7 @@ From: [Discord API docs](https://discord.com/developers/docs/interactions/applic
10
10
 
11
11
  ## How do I register an application command?
12
12
 
13
- Use {Discorb::Command::Handler#slash}, {Discorb::Command::Handler#group} for slash commands, {Discorb::Command::Handler#user_command} for user menu commands, and {Discorb::Command::Handler#message_command} for message menu commands.
13
+ Use {Discorb::Command::Handler.slash}, {Discorb::Command::Handler.slash_group} for slash commands, {Discorb::Command::Handler.user_command} for user menu commands, and {Discorb::Command::Handler.message_command} for message menu commands.
14
14
 
15
15
  ### Note
16
16
 
@@ -69,7 +69,7 @@ In `options`, hash should be like this:
69
69
  {
70
70
  "vocaloid" => {
71
71
  required: true,
72
- description: "The vocaloid which you like."
72
+ description: "The vocaloid which you like.",
73
73
  type: :string,
74
74
  choices: {
75
75
  "Hatsune Miku" => "miku",
@@ -125,7 +125,7 @@ group.slash("bump_alert", "Whether bot should notify DISBOARD bump.", {
125
125
  end
126
126
  ```
127
127
 
128
- You can make subcommand group by using {Discorb::Command::GroupCommand#group}.
128
+ You can make subcommand group by using {Discorb::Command::Command::GroupCommand#group}.
129
129
 
130
130
  ```ruby
131
131
  group = client.slash_group("permission", "Set/Get command permissions.")
@@ -211,7 +211,7 @@ client.user_command("hello") do |interaction, user|
211
211
  interaction.post("Hello, #{user.name}!")
212
212
  end
213
213
  ```
214
- {Discorb::Command::Handler#user_command} takes 3 arguments:
214
+ {Discorb::Command::Handler.user_command} takes 3 arguments:
215
215
 
216
216
  | Parameter | Description |
217
217
  | --- | --- |
@@ -235,7 +235,7 @@ client.message_command("Bookmark") do |interaction, message|
235
235
  end
236
236
  ```
237
237
 
238
- {Discorb::Command::Handler#message_command} takes 3 arguments:
238
+ {Discorb::Command::Handler.message_command} takes 3 arguments:
239
239
 
240
240
  | Parameter | Description |
241
241
  | --- | --- |
@@ -248,4 +248,4 @@ end
248
248
  | Parameter | Description |
249
249
  | --- | --- |
250
250
  | `interaction` | The interaction object. |
251
- | `message` | The message object. |
251
+ | `message` | The message object. |
data/docs/cli/init.md ADDED
@@ -0,0 +1,55 @@
1
+ # @title CLI: discorb init
2
+
3
+ # discorb init
4
+
5
+ This command will create a new project in the directory.
6
+
7
+ ## Usage
8
+
9
+ ```bash
10
+ discorb init [options] [dir]
11
+ ```
12
+
13
+ ## Options
14
+
15
+ ### `dir`
16
+
17
+ The directory to create the project in.
18
+ Defaults to the current directory.
19
+ If the directory exists and is not empty, an error is returned.
20
+ You can use `--force` to overwrite an existing directory.
21
+
22
+ ### `--[no-]bundle`
23
+
24
+ Whether to use bundle.
25
+ If true, the command will create Gemfile and execute `bundle install`.
26
+ Default to true.
27
+
28
+ ### `--[no-]git`
29
+
30
+ Whether to initialize git.
31
+ If true, the command will initialize git and commit the initial files with commit message `Initial commit`.
32
+ Use `git commit --amend -m "..."` to change the commit message.
33
+ Default to true.
34
+
35
+ ### `-t`, `--token`
36
+
37
+ The name of token environment variable.
38
+ Default to TOKEN.
39
+
40
+ ### `-f`, `--force`
41
+
42
+ Whether to overwrite an existing directory.
43
+ Default to false.
44
+
45
+ ## File structure
46
+
47
+ The following files will be created:
48
+
49
+ | File | Description |
50
+ | ---- | ----------- |
51
+ | `.env` | Environment variables. |
52
+ | `.gitignore` | Git ignore file. Won't be created if `--git` is false. |
53
+ | `Gemfile` | Gemfile. Won't be created if `--bundle` is false. |
54
+ | `Gemfile.lock` | Gemfile lock file. Won't be created if `--bundle` is false. |
55
+ | `main.rb` | Main script. |