discorb 0.2.3 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1381542f36d691bc8c16bbca477f7dbc034d18d4308c6e51689e02d766af9fac
4
- data.tar.gz: 611e01c698fbb0c19f7a37cad66faddf5dfbba860b59dc2a140c3a3b7d85dd9e
3
+ metadata.gz: 48ed0b82cf398970b54454d1d41f60e8fdf55fb6d5499f1e55a54769d61bc954
4
+ data.tar.gz: 5aae36deb140de42e2ff94249f61aa346856682ae27de444eb2aadc8a0b29591
5
5
  SHA512:
6
- metadata.gz: eab30f2c135c3a1dd63fc36cea26df4035f57da50e96fbc52e74d207248599dd0d50d7df9379bf20b906b128aa3e7abd47f637c7cd56662a991c7feb7cd7944e
7
- data.tar.gz: e9b03bd76e066037ef98480c9952bbfe6a0d7d039199e5d2a804bac49e550d03b74c1596847e485f2ba13b935012c80fb39a356df21f0d154b981f705807a113
6
+ metadata.gz: 3cc6e43128c370e30e6d16b6a19ec88be33a848e56a112981a6f272146d3506222f2240d55edb359e2d1d60f64b002841e37de5b52aa5142d837bddf75afcf5f
7
+ data.tar.gz: 3cf2390626afa7eb22ac3d906e9915ba2e4cee75e40a3d6dc9bbf25b5d00db0bd693ae2c7d1798a8811ea2c57475ab90e9825ffb3ceb762e415167a80bb9f192
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
@@ -64,4 +64,13 @@
64
64
 
65
65
  ## 0.2.3
66
66
 
67
- - Fix: Fix critical error
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,17 +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
- 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
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.3)
4
+ discorb (0.3.1)
5
5
  async
6
6
  async-http
7
7
  async-websocket
@@ -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)
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,171 @@
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
+ require_relative "lib/discorb/utils/colored_puts"
5
+ task default: %i[]
6
+
7
+ # @!visibility private
8
+ def get_version
9
+ require_relative "lib/discorb/common"
10
+ latest_commit = `git log --oneline`.force_encoding("utf-8").split("\n")[0]
11
+ version = Discorb::VERSION
12
+ unless latest_commit.downcase.include?("update version")
13
+ version += "-dev"
14
+ end
15
+ version
16
+ end
17
+
18
+ desc "Build emoji_table.rb"
19
+ task :emoji_table do
20
+ require_relative "lib/discorb"
21
+
22
+ gputs "Building emoji_table.rb"
23
+ res = {}
24
+ Discorb::EmojiTable::DISCORD_TO_UNICODE.each do |discord, unicode|
25
+ res[unicode] ||= []
26
+ res[unicode] << discord
27
+ end
28
+
29
+ res_text = +""
30
+ res.each do |unicode, discord|
31
+ res_text << %(#{unicode.unpack("C*").pack("C*").inspect} => %w[#{discord.join(" ")}],\n)
32
+ end
33
+
34
+ table_script = File.read("lib/discorb/emoji_table.rb")
35
+
36
+ table_script.gsub!(/(?<=UNICODE_TO_DISCORD = {\n)[\s\S]+(?=}\.freeze)/, res_text)
37
+
38
+ File.open("lib/discorb/emoji_table.rb", "w") do |f|
39
+ f.print(table_script)
40
+ end
41
+ `rufo lib/discorb/emoji_table.rb`
42
+ sputs "Successfully made emoji_table.rb"
43
+ end
44
+
45
+ desc "Format files"
46
+ task :format do
47
+ Dir.glob("**/*.rb").each do |file|
48
+ next if file.start_with?("vendor")
49
+
50
+ gputs "Formatting #{file}"
51
+ `rufo ./#{file}`
52
+ content = ""
53
+ File.open(file, "rb") do |f|
54
+ content = f.read
55
+ end
56
+ content.gsub!("\r\n", "\n")
57
+ File.open(file, "wb") do |f|
58
+ f.print(content)
59
+ end
60
+ end
61
+ end
62
+
63
+ desc "Generate document and replace"
64
+ namespace :document do
65
+ version = get_version
66
+
67
+ desc "Just generate document"
68
+ task :yard do
69
+ sh "yardoc -o doc/#{version}"
70
+ end
71
+
72
+ desc "Replace files"
73
+ namespace :replace do
74
+ require "fileutils"
75
+
76
+ desc "Replace CSS"
77
+ task :css do
78
+ gputs "Replacing css"
79
+ Dir.glob("template-replace/files/**/*.*")
80
+ .map { |f| f.delete_prefix("template-replace/files") }.each do |file|
81
+ FileUtils.cp("template-replace/files" + file, "doc/#{version}/#{file}")
82
+ end
83
+ sputs "Successfully replaced css"
84
+ end
85
+
86
+ desc "Replace HTML"
87
+ task :html do
88
+ require_relative "template-replace/scripts/sidebar.rb"
89
+ require_relative "template-replace/scripts/version.rb"
90
+ require_relative "template-replace/scripts/index.rb"
91
+ require_relative "template-replace/scripts/yard_replace.rb"
92
+ gputs "Resetting changes"
93
+ Dir.glob("doc/#{version}/**/*.html") do |f|
94
+ next if (m = f.match(/[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?/)) && m[0] != version
95
+
96
+ content = File.read(f)
97
+ content.gsub!(/<!--od-->[\s\S]*<!--eod-->/, "")
98
+ File.write(f, content)
99
+ end
100
+ gputs "Adding version tab"
101
+ %w[file_list class_list method_list].each do |f|
102
+ replace_sidebar("doc/#{version}/#{f}.html")
103
+ end
104
+
105
+ gputs "Building version tab"
106
+ build_version_sidebar("doc/#{version}")
107
+ gputs "Replacing _index.html"
108
+ replace_index("doc/#{version}", version)
109
+ gputs "Replacing YARD credits"
110
+ yard_replace("doc/#{version}", version)
111
+ gputs "Successfully replaced htmls"
112
+ end
113
+
114
+ desc "Replace EOL"
115
+ task :eol do
116
+ gputs "Replacing CRLF with LF"
117
+ Dir.glob("doc/**/*.*") do |file|
118
+ next unless File.file?(file)
119
+
120
+ content = ""
121
+ File.open(file, "rb") do |f|
122
+ content = f.read
123
+ end
124
+ content.gsub!("\r\n", "\n")
125
+ File.open(file, "wb") do |f|
126
+ f.print(content)
127
+ end
128
+ end
129
+ sputs "Successfully replaced CRLF with LF"
130
+ end
131
+ end
132
+ task :replace => %i[replace:css replace:html replace:eol]
133
+
134
+ desc "Build all versions"
135
+ task :build_all do
136
+ require "fileutils"
137
+ gputs "Building all versions"
138
+ FileUtils.cp_r("./template-replace/.", "./tmp-template-replace")
139
+ tags = `git tag`.force_encoding("utf-8").split("\n")
140
+ tags.each do |tag|
141
+ sh "git checkout #{tag} -f"
142
+ gputs "Building #{tag}"
143
+ FileUtils.cp_r("./tmp-template-replace/.", "./template-replace")
144
+ version = tag.delete_prefix("v")
145
+ Rake::Task["document:yard"].execute
146
+ Rake::Task["document:replace:html"].execute
147
+ Rake::Task["document:replace:css"].execute
148
+ Rake::Task["document:replace:eol"].execute
149
+ end
150
+ version = "."
151
+ Rake::Task["document:yard"].execute
152
+ Rake::Task["document:replace:html"].execute
153
+ Rake::Task["document:replace:css"].execute
154
+ Rake::Task["document:replace:eol"].execute
155
+ sh "git switch main -f"
156
+ sputs "Successfully built all versions"
157
+ end
158
+
159
+ desc "Push to discorb-lib/discorb-lib.github.io"
160
+ task :push do
161
+ gputs "Pushing documents"
162
+ Dir.chdir("doc") do
163
+ sh "git add ."
164
+ sh "git commit -m \"Update: Update document\""
165
+ sh "git push -f"
166
+ end
167
+ sputs "Successfully pushed documents"
168
+ end
169
+ end
170
+
171
+ 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. |