discorb 0.9.4 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +304 -254
- data/README.md +5 -5
- data/Rakefile +3 -0
- data/docs/application_command.md +8 -7
- data/docs/cli/run.md +5 -1
- data/docs/extension.md +16 -22
- data/docs/license.md +5 -1
- data/examples/extension/main.rb +1 -1
- data/examples/extension/message_expander.rb +4 -6
- data/lib/discorb/app_command.rb +4 -2
- data/lib/discorb/client.rb +32 -22
- data/lib/discorb/common.rb +4 -23
- data/lib/discorb/components.rb +29 -1
- data/lib/discorb/exe/run.rb +20 -3
- data/lib/discorb/extend.rb +21 -0
- data/lib/discorb/extension.rb +60 -47
- data/lib/discorb/file.rb +18 -0
- data/lib/discorb/interaction.rb +23 -19
- data/lib/discorb/message.rb +4 -4
- data/lib/discorb/modules.rb +5 -41
- data/lib/discorb/utils.rb +0 -20
- data/template-replace/files/css/common.css +3 -2
- data/template-replace/scripts/arrow.rb +7 -0
- data/template-replace/scripts/version.rb +20 -5
- metadata +3 -2
data/lib/discorb/modules.rb
CHANGED
@@ -37,26 +37,7 @@ module Discorb
|
|
37
37
|
payload[:allowed_mentions] =
|
38
38
|
allowed_mentions ? allowed_mentions.to_hash(@client.allowed_mentions) : @client.allowed_mentions.to_hash
|
39
39
|
payload[:message_reference] = reference.to_reference if reference
|
40
|
-
if components
|
41
|
-
tmp_components = []
|
42
|
-
tmp_row = []
|
43
|
-
components.each do |c|
|
44
|
-
case c
|
45
|
-
when Array
|
46
|
-
tmp_components << tmp_row
|
47
|
-
tmp_row = []
|
48
|
-
tmp_components << c
|
49
|
-
when SelectMenu
|
50
|
-
tmp_components << tmp_row
|
51
|
-
tmp_row = []
|
52
|
-
tmp_components << [c]
|
53
|
-
else
|
54
|
-
tmp_row << c
|
55
|
-
end
|
56
|
-
end
|
57
|
-
tmp_components << tmp_row
|
58
|
-
payload[:components] = tmp_components.filter { |c| c.length.positive? }.map { |c| { type: 1, components: c.map(&:to_hash) } }
|
59
|
-
end
|
40
|
+
payload[:components] = Component.to_payload(components) if components
|
60
41
|
files = [file] if file
|
61
42
|
if files
|
62
43
|
seperator, payload = HTTP.multipart(payload, files)
|
@@ -69,6 +50,8 @@ module Discorb
|
|
69
50
|
end
|
70
51
|
end
|
71
52
|
|
53
|
+
alias send_message post
|
54
|
+
|
72
55
|
#
|
73
56
|
# Edit a message.
|
74
57
|
# @macro async
|
@@ -95,27 +78,8 @@ module Discorb
|
|
95
78
|
payload[:embeds] = tmp_embed.map(&:to_hash) if tmp_embed
|
96
79
|
payload[:allowed_mentions] =
|
97
80
|
allowed_mentions ? allowed_mentions.to_hash(@client.allowed_mentions) : @client.allowed_mentions.to_hash
|
98
|
-
if components
|
99
|
-
|
100
|
-
tmp_row = []
|
101
|
-
components.each do |c|
|
102
|
-
case c
|
103
|
-
when Array
|
104
|
-
tmp_components << tmp_row
|
105
|
-
tmp_row = []
|
106
|
-
tmp_components << c
|
107
|
-
when SelectMenu
|
108
|
-
tmp_components << tmp_row
|
109
|
-
tmp_row = []
|
110
|
-
tmp_components << [c]
|
111
|
-
else
|
112
|
-
tmp_row << c
|
113
|
-
end
|
114
|
-
end
|
115
|
-
tmp_components << tmp_row
|
116
|
-
payload[:flags] = (supress ? 1 << 2 : 0) unless flags.nil?
|
117
|
-
payload[:components] = tmp_components.filter { |c| c.length.positive? }.map { |c| { type: 1, components: c.map(&:to_hash) } }
|
118
|
-
end
|
81
|
+
payload[:components] = Component.to_payload(components) if components
|
82
|
+
payload[:flags] = (supress ? 1 << 2 : 0) unless supress.nil?
|
119
83
|
@client.http.patch("/channels/#{channel_id.wait}/messages/#{message_id}", payload).wait
|
120
84
|
end
|
121
85
|
end
|
data/lib/discorb/utils.rb
CHANGED
@@ -14,23 +14,3 @@ module Discorb
|
|
14
14
|
module_function :try
|
15
15
|
end
|
16
16
|
end
|
17
|
-
|
18
|
-
class Async::Node
|
19
|
-
def description
|
20
|
-
@object_name ||= "#{self.class}:0x#{object_id.to_s(16)}#{@transient ? ' transient' : nil}"
|
21
|
-
|
22
|
-
if @annotation
|
23
|
-
"#{@object_name} #{@annotation}"
|
24
|
-
elsif line = self.backtrace(0, 1)&.first
|
25
|
-
"#{@object_name} #{line}"
|
26
|
-
else
|
27
|
-
@object_name
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def to_s
|
32
|
-
"\#<#{self.description}>"
|
33
|
-
end
|
34
|
-
|
35
|
-
alias inspect to_s
|
36
|
-
end
|
@@ -527,6 +527,7 @@ dd pre.code {
|
|
527
527
|
padding: 9px 14px;
|
528
528
|
border-radius: 4px;
|
529
529
|
border: 1px solid var(--background-tertiary);
|
530
|
+
overflow-x: scroll;
|
530
531
|
}
|
531
532
|
|
532
533
|
#main {
|
@@ -550,6 +551,6 @@ dd pre.code {
|
|
550
551
|
display: inline !important;
|
551
552
|
}
|
552
553
|
|
553
|
-
p.signature, h3.signature{
|
554
|
-
font-family: var(--font
|
554
|
+
p.signature, h3.signature, p.signature tt, h3.signature tt{
|
555
|
+
font-family: var(--monospace-font);
|
555
556
|
}
|
@@ -4,21 +4,36 @@ def build_version_sidebar(dir, version)
|
|
4
4
|
raw.gsub!(template, "")
|
5
5
|
res = +""
|
6
6
|
i = 0
|
7
|
-
`git tag`.force_encoding("utf-8").split("\n").each.with_index do |tag|
|
7
|
+
`git tag`.force_encoding("utf-8").split("\n").reverse.each.with_index do |tag|
|
8
8
|
i += 1
|
9
9
|
sha = `git rev-parse #{tag}`.force_encoding("utf-8").strip
|
10
|
-
|
10
|
+
tag_version = tag.delete_prefix("v")
|
11
11
|
cls = i % 2 == 0 ? "even" : "odd"
|
12
|
-
if
|
12
|
+
if tag_version == version
|
13
13
|
cls += " current"
|
14
14
|
end
|
15
|
-
res += template
|
15
|
+
res += template
|
16
|
+
.gsub("!version!", tag_version)
|
17
|
+
.gsub("!path!", "/" + tag_version)
|
18
|
+
.gsub("!class!", cls)
|
19
|
+
.gsub("!sha!", sha)
|
16
20
|
end
|
17
21
|
i += 1
|
18
22
|
cls = i % 2 == 0 ? "even" : "odd"
|
19
23
|
if version == "main"
|
20
24
|
cls += " current"
|
21
25
|
end
|
22
|
-
res
|
26
|
+
res.insert 0, template
|
27
|
+
.gsub("!version!", "main")
|
28
|
+
.gsub("!path!", "/main")
|
29
|
+
.gsub("!class!", cls)
|
30
|
+
.gsub("!sha!", "Latest on GitHub")
|
31
|
+
i += 1
|
32
|
+
cls = i % 2 == 0 ? "even" : "odd"
|
33
|
+
res.insert 0, template
|
34
|
+
.gsub("!version!", "Latest")
|
35
|
+
.gsub("!path!", "/")
|
36
|
+
.gsub("!class!", cls)
|
37
|
+
.gsub("!sha!", "Latest on RubyGems")
|
23
38
|
File.write(dir + "/version_list.html", raw.gsub("<!--replace-->", res))
|
24
39
|
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.
|
4
|
+
version: 0.10.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: 2021-
|
11
|
+
date: 2021-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -181,6 +181,7 @@ files:
|
|
181
181
|
- template-replace/files/css/common.css
|
182
182
|
- template-replace/files/favicon.png
|
183
183
|
- template-replace/resources/version_list.html
|
184
|
+
- template-replace/scripts/arrow.rb
|
184
185
|
- template-replace/scripts/favicon.rb
|
185
186
|
- template-replace/scripts/index.rb
|
186
187
|
- template-replace/scripts/sidebar.rb
|