onyxcord 3.2.2 → 3.2.4
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/lib/onyxcord/core/bot/runtime.rb +4 -0
- data/lib/onyxcord/core/version.rb +1 -1
- data/lib/onyxcord/gateway/client.rb +3 -1
- data/lib/onyxcord/webhooks/modal.rb +44 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c94582fa63841a78c5b713cc29f26d291c91bb2bfeefedf9c411926cdfc3887f
|
|
4
|
+
data.tar.gz: 7cae417909158a1770526f9536934e446a34f593d48d2e2a4a1e906ea300b798
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8f16620764772170815fdb1d972dfc93aa2cb1be6faa6c557a7820813f4f9bba8cdcf227cd63277243ca05c9ecb32da90ddd49a6e2e1318fe919a41c1cf06f44
|
|
7
|
+
data.tar.gz: 3aa37e6eaf9852859dba4aa000c520ed7a4d230931a64f09039ed88016aa33b181de6a4848fe8f378d92f789db1911cb91d496e1f49134ebbdbb8b55b1623658
|
|
@@ -17,7 +17,7 @@ module OnyxCord
|
|
|
17
17
|
FATAL_CLOSE_CODES = [4003, 4004, 4011, 4014].freeze
|
|
18
18
|
|
|
19
19
|
attr_accessor :check_heartbeat_acks
|
|
20
|
-
attr_reader :intents
|
|
20
|
+
attr_reader :intents, :latency
|
|
21
21
|
|
|
22
22
|
def initialize(bot, token, shard_key = nil, compress_mode = :stream, intents = ALL_INTENTS)
|
|
23
23
|
@token = token
|
|
@@ -108,6 +108,7 @@ module OnyxCord
|
|
|
108
108
|
end
|
|
109
109
|
|
|
110
110
|
def send_heartbeat(sequence)
|
|
111
|
+
@last_heartbeat_sent_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
111
112
|
send_packet(Internal::Gateway::Opcodes::HEARTBEAT, sequence)
|
|
112
113
|
end
|
|
113
114
|
|
|
@@ -402,6 +403,7 @@ module OnyxCord
|
|
|
402
403
|
LOGGER.debug("Heartbeat ACK: #{packet.inspect}")
|
|
403
404
|
return unless @check_heartbeat_acks
|
|
404
405
|
|
|
406
|
+
@latency = Process.clock_gettime(Process::CLOCK_MONOTONIC) - @last_heartbeat_sent_at if @last_heartbeat_sent_at
|
|
405
407
|
@last_heartbeat_acked = true
|
|
406
408
|
@missed_heartbeat_acks = 0
|
|
407
409
|
end
|
|
@@ -39,9 +39,53 @@ class OnyxCord::Webhooks::Modal
|
|
|
39
39
|
@components << LabelBuilder.new(...)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
+
# Add a legacy action row to the modal.
|
|
43
|
+
def row(id: nil)
|
|
44
|
+
@components << LegacyRowBuilder.new(id: id) { |row| yield row }
|
|
45
|
+
end
|
|
46
|
+
|
|
42
47
|
# Add a text display component to the view.
|
|
43
48
|
# @see Webhooks::View::TextDisplayBuilder#initialize
|
|
44
49
|
def text_display(...)
|
|
45
50
|
@components << OnyxCord::Webhooks::View::TextDisplayBuilder.new(...)
|
|
46
51
|
end
|
|
52
|
+
|
|
53
|
+
class LegacyRowBuilder
|
|
54
|
+
def initialize(id: nil)
|
|
55
|
+
@id = id
|
|
56
|
+
@components = []
|
|
57
|
+
|
|
58
|
+
yield self if block_given?
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def text_input(style:, custom_id:, id: nil, min_length: nil, max_length: nil, required: nil, value: nil, placeholder: nil, label: nil)
|
|
62
|
+
@components << {
|
|
63
|
+
type: COMPONENT_TYPES[:text_input],
|
|
64
|
+
custom_id: custom_id,
|
|
65
|
+
id: id,
|
|
66
|
+
label: label,
|
|
67
|
+
style: LabelBuilder::TEXT_INPUT_STYLES[style] || style,
|
|
68
|
+
min_length: min_length,
|
|
69
|
+
max_length: max_length,
|
|
70
|
+
required: required,
|
|
71
|
+
value: value,
|
|
72
|
+
placeholder: placeholder
|
|
73
|
+
}.compact
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def file_upload(custom_id:, id: nil, min_values: nil, max_values: nil, required: nil)
|
|
77
|
+
@components << {
|
|
78
|
+
type: COMPONENT_TYPES[:file_upload],
|
|
79
|
+
custom_id: custom_id,
|
|
80
|
+
id: id,
|
|
81
|
+
min_values: min_values,
|
|
82
|
+
max_values: max_values,
|
|
83
|
+
required: required
|
|
84
|
+
}.compact
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def to_h
|
|
88
|
+
{ type: COMPONENT_TYPES[:action_row], id: @id, components: @components }.compact
|
|
89
|
+
end
|
|
90
|
+
end
|
|
47
91
|
end
|