discorb 0.9.4 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- tmp_components = []
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-monospace);
554
+ p.signature, h3.signature, p.signature tt, h3.signature tt{
555
+ font-family: var(--monospace-font);
555
556
  }
@@ -0,0 +1,7 @@
1
+ def replace_arrow(dir)
2
+ Dir.glob("#{dir}/**/*.html") do |file|
3
+ content = File.read(file)
4
+ content.gsub!(" &#x21d2; ", " -&gt; ")
5
+ File.write(file, content, mode: "wb")
6
+ end
7
+ end
@@ -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
- version = tag.delete_prefix("v")
10
+ tag_version = tag.delete_prefix("v")
11
11
  cls = i % 2 == 0 ? "even" : "odd"
12
- if version == "."
12
+ if tag_version == version
13
13
  cls += " current"
14
14
  end
15
- res += template.gsub("!version!", version).gsub("!path!", "../" + version).gsub("!class!", cls).gsub("!sha!", sha)
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 += template.gsub("!version!", "main").gsub("!path!", "../main").gsub("!class!", cls).gsub("!sha!", "(Latest on GitHub)")
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.9.4
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-09-26 00:00:00.000000000 Z
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