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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 37831cee5e469b515d61360bfe1f6ad947c02a94adc801d4fef29118118b66f4
4
- data.tar.gz: 52f92ddc708cb3d8237a637191357ddf6a29a9743f5f28faf84eb092aa0616ed
3
+ metadata.gz: c94582fa63841a78c5b713cc29f26d291c91bb2bfeefedf9c411926cdfc3887f
4
+ data.tar.gz: 7cae417909158a1770526f9536934e446a34f593d48d2e2a4a1e906ea300b798
5
5
  SHA512:
6
- metadata.gz: 6b16e3f8ec311f6aab31d4fc650b34c7386da6b19604d61f0d852861f9a8092881ac007a9321ee596090b433edcb08e80888cfa046cfa3406ece9136d8752f0e
7
- data.tar.gz: 3535bf3a10491e262f920db6f71f8d2a7678ce5cdd3c57e60f954fe790d63bb38e65854e31b8fac98880acb27bb9b126d96f27d4e653131b05ed2233a69155af
6
+ metadata.gz: 8f16620764772170815fdb1d972dfc93aa2cb1be6faa6c557a7820813f4f9bba8cdcf227cd63277243ca05c9ecb32da90ddd49a6e2e1318fe919a41c1cf06f44
7
+ data.tar.gz: 3aa37e6eaf9852859dba4aa000c520ed7a4d230931a64f09039ed88016aa33b181de6a4848fe8f378d92f789db1911cb91d496e1f49134ebbdbb8b55b1623658
@@ -45,6 +45,10 @@ module OnyxCord
45
45
  @gateway.open?
46
46
  end
47
47
 
48
+ def latency
49
+ @gateway.latency
50
+ end
51
+
48
52
  # Sets debug mode. If debug mode is on, many things will be outputted to STDOUT.
49
53
  def debug=(new_debug)
50
54
  LOGGER.debug = new_debug
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OnyxCord
4
- VERSION = '3.2.2'
4
+ VERSION = '3.2.4'
5
5
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onyxcord
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.2
4
+ version: 3.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gustavo Silva