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 +4 -4
- data/.gitignore +2 -1
- data/.yardopts +2 -1
- data/Changelog.md +10 -1
- data/Gemfile +17 -17
- data/Gemfile.lock +4 -4
- data/README.md +1 -1
- data/Rakefile +171 -46
- data/crowdin.yml +3 -0
- data/discorb.gemspec +1 -0
- data/docs/application_command.md +6 -6
- data/docs/cli/init.md +55 -0
- data/docs/{discord_irb.md → cli/irb.md} +6 -8
- data/docs/cli.md +21 -0
- data/docs/events.md +21 -7
- data/docs/extension.md +15 -3
- data/examples/commands/inspect.rb +1 -1
- data/exe/discorb +28 -0
- data/lib/discorb/audit_logs.rb +3 -0
- data/lib/discorb/client.rb +15 -3
- data/lib/discorb/color.rb +1 -0
- data/lib/discorb/common.rb +1 -1
- data/lib/discorb/dictionary.rb +3 -0
- data/lib/discorb/embed.rb +2 -2
- data/lib/discorb/exe/init.rb +195 -0
- data/{exe/discord-irb → lib/discorb/exe/irb.rb} +2 -0
- data/lib/discorb/exe/show.rb +8 -0
- data/lib/discorb/flag.rb +3 -0
- data/lib/discorb/image.rb +1 -4
- data/lib/discorb/intents.rb +3 -0
- data/lib/discorb/interaction.rb +6 -1
- data/lib/discorb/message.rb +4 -2
- data/lib/discorb/permission.rb +6 -0
- data/lib/discorb/utils/colored_puts.rb +14 -0
- data/po/yard.pot +12452 -0
- data/template-replace/files/css/common.css +519 -0
- data/template-replace/resources/version_list.html +61 -0
- data/template-replace/scripts/index.rb +13 -0
- data/template-replace/scripts/sidebar.rb +11 -0
- data/template-replace/scripts/version.rb +12 -0
- data/template-replace/scripts/yard_replace.rb +27 -0
- metadata +20 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48ed0b82cf398970b54454d1d41f60e8fdf55fb6d5499f1e55a54769d61bc954
|
4
|
+
data.tar.gz: 5aae36deb140de42e2ff94249f61aa346856682ae27de444eb2aadc8a0b29591
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cc6e43128c370e30e6d16b6a19ec88be33a848e56a112981a6f272146d3506222f2240d55edb359e2d1d60f64b002841e37de5b52aa5142d837bddf75afcf5f
|
7
|
+
data.tar.gz: 3cf2390626afa7eb22ac3d906e9915ba2e4cee75e40a3d6dc9bbf25b5d00db0bd693ae2c7d1798a8811ea2c57475ab90e9825ffb3ceb762e415167a80bb9f192
|
data/.gitignore
CHANGED
data/.yardopts
CHANGED
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.
|
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.
|
38
|
-
nio4r (2.5.
|
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.
|
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
|
-
[](https://discorb-lib.github.io/)
|
3
3
|
[](https://rubygems.org/gems/discorb)
|
4
4
|
[](https://rubygems.org/gems/discorb)
|
5
5
|
[](https://discord.gg/hCP6zq8Vpj)
|
data/Rakefile
CHANGED
@@ -1,46 +1,171 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "bundler/gem_tasks"
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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
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.
|
data/docs/application_command.md
CHANGED
@@ -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
|
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
|
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
|
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. |
|