onyxcord 1.1.6 → 1.1.8
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/CHANGELOG.md +27 -0
- data/README.md +225 -158
- data/lib/onyxcord/data/component.rb +14 -0
- data/lib/onyxcord/version.rb +1 -1
- data/onyxcord-webhooks.gemspec +1 -1
- data/onyxcord.gemspec +1 -1
- metadata +5 -7
- data/relator.md +0 -298
- data/relatorio2.md +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 07ea78b3a647f1f03a640e750eef4e5a99595f6afa66ce9be842d012c5e8e2c1
|
|
4
|
+
data.tar.gz: '08f1edd1b05510983d80766f627db7372edb8f3bce6234ba9cb4d669e9cf2070'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '092c91e1b949b091079169f2977c44745fea551a93e2cc3d065df2b9c51b534cbb027a01519d781dfc0fe2f783c360eecccee29d46b4f0bb28cd99350bde56cf'
|
|
7
|
+
data.tar.gz: 076604ea2c7a9a6a0c9303fedfbd5e1cac58cb11cbc741d88afff80a838f80da5637a292b494a6d84ae63da4ce5fc435c8eb3548dcb833961dff588ff6b24974
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.1.8 - 2026-06-28
|
|
4
|
+
|
|
5
|
+
### Correcoes
|
|
6
|
+
|
|
7
|
+
- `Components::Label` agora delega `custom_id`, `value` e `values` para o componente interativo interno, mantendo compatibilidade com codigo legado de modal que itera por `event.components`.
|
|
8
|
+
- Modais modernos continuam preservando `label`, `description` e `component`, enquanto `event.value(custom_id)`, `event.values(custom_id)` e acesso direto em `event.components` funcionam de forma consistente.
|
|
9
|
+
|
|
10
|
+
### Validacao
|
|
11
|
+
|
|
12
|
+
- `bundle exec rspec spec/components_v2_spec.rb`: sucesso.
|
|
13
|
+
- `ruby -c lib/onyxcord/data/component.rb`: sucesso.
|
|
14
|
+
- `ruby -c spec/components_v2_spec.rb`: sucesso.
|
|
15
|
+
- `gem build onyxcord.gemspec`: sucesso.
|
|
16
|
+
- `gem build onyxcord-webhooks.gemspec`: sucesso.
|
|
17
|
+
|
|
18
|
+
## 1.1.7 - 2026-06-28
|
|
19
|
+
|
|
20
|
+
### Melhorias
|
|
21
|
+
|
|
22
|
+
- Atualizada a descricao publicada no RubyGems para mostrar o convite da comunidade Discord: `https://discord.gg/Jy2tpCUtzM`.
|
|
23
|
+
- README mantem as secoes em ingles, portugues e espanhol com o link da comunidade.
|
|
24
|
+
|
|
25
|
+
### Validacao
|
|
26
|
+
|
|
27
|
+
- `ruby -c onyxcord.gemspec`: sucesso.
|
|
28
|
+
- `ruby -c onyxcord-webhooks.gemspec`: sucesso.
|
|
29
|
+
|
|
3
30
|
## 1.1.6 - 2026-06-28
|
|
4
31
|
|
|
5
32
|
### Melhorias
|
data/README.md
CHANGED
|
@@ -3,51 +3,51 @@
|
|
|
3
3
|
[](https://rubygems.org/gems/onyxcord)
|
|
4
4
|
[](https://rubygems.org/gems/onyxcord)
|
|
5
5
|
|
|
6
|
-
OnyxCord
|
|
6
|
+
OnyxCord is a Ruby library for Discord bots, interactions, webhooks, modern modals, and Components V2.
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Community Discord: https://discord.gg/Jy2tpCUtzM
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Languages: [English](#english) | [Portugues](#portugues) | [Espanol](#espanol)
|
|
11
|
+
|
|
12
|
+
## English
|
|
13
|
+
|
|
14
|
+
OnyxCord is a Ruby implementation of the Discord API based on `discordrb`, updated with a lighter raw-first core, modern modal components, webhook helpers, and Discord Components V2 support.
|
|
11
15
|
|
|
12
16
|
```txt
|
|
13
|
-
|
|
17
|
+
Simple to start, deep enough to control.
|
|
14
18
|
```
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
### Highlights
|
|
17
21
|
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
- Components V2
|
|
22
|
-
-
|
|
23
|
-
- Webhooks
|
|
24
|
-
-
|
|
22
|
+
- Friendly Ruby API for Discord bots.
|
|
23
|
+
- Traditional object events for productivity.
|
|
24
|
+
- Raw gateway events for performance and lower allocation.
|
|
25
|
+
- Components V2 support with `Text Display`, `Container`, `Section`, `Media Gallery`, `File`, `Separator`, and `Thumbnail`.
|
|
26
|
+
- Modern modal components, including `Label`, `Text Display`, modal selects, file upload, radio group, checkbox group, and checkbox.
|
|
27
|
+
- Webhooks with embeds, files, and components.
|
|
28
|
+
- Runtime helpers, rate limiting, and event execution designed for modern OnyxCord bots.
|
|
25
29
|
|
|
26
|
-
|
|
30
|
+
### Installation
|
|
27
31
|
|
|
28
|
-
|
|
32
|
+
With Bundler:
|
|
29
33
|
|
|
30
34
|
```ruby
|
|
31
35
|
gem 'onyxcord'
|
|
32
36
|
```
|
|
33
37
|
|
|
34
|
-
|
|
38
|
+
Then:
|
|
35
39
|
|
|
36
40
|
```sh
|
|
37
41
|
bundle install
|
|
38
42
|
```
|
|
39
43
|
|
|
40
|
-
|
|
44
|
+
Or install directly:
|
|
41
45
|
|
|
42
46
|
```sh
|
|
43
47
|
gem install onyxcord
|
|
44
48
|
```
|
|
45
49
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
## Primeiro bot
|
|
49
|
-
|
|
50
|
-
Crie um arquivo `bot.rb`:
|
|
50
|
+
### First Bot
|
|
51
51
|
|
|
52
52
|
```ruby
|
|
53
53
|
require 'onyxcord'
|
|
@@ -69,126 +69,136 @@ end
|
|
|
69
69
|
bot.run
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
### Components V2
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
```
|
|
74
|
+
OnyxCord automatically applies the `IS_COMPONENTS_V2` flag when you use V2 components. You can also enable it explicitly with `components_v2: true`.
|
|
75
|
+
|
|
76
|
+
```ruby
|
|
77
|
+
bot.message(content: '!panel') do |event|
|
|
78
|
+
event.send_message!(content: nil, components_v2: true) do |_builder, view|
|
|
79
|
+
view.text_display(content: '## OnyxCord Panel')
|
|
80
|
+
view.text_display(content: 'Choose an action below.')
|
|
77
81
|
|
|
78
|
-
|
|
82
|
+
view.row do |row|
|
|
83
|
+
row.button(style: :primary, label: 'Open', custom_id: 'open_panel')
|
|
84
|
+
row.button(style: :secondary, label: 'Help', custom_id: 'help_panel')
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
```
|
|
79
89
|
|
|
80
|
-
|
|
90
|
+
### Modern Modals
|
|
81
91
|
|
|
82
92
|
```ruby
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
93
|
+
bot.application_command(:feedback) do |event|
|
|
94
|
+
event.show_modal(title: 'Feedback', custom_id: 'feedback_modal') do |modal|
|
|
95
|
+
modal.label(label: 'Message') do |label|
|
|
96
|
+
label.text_input(
|
|
97
|
+
style: :paragraph,
|
|
98
|
+
custom_id: 'message',
|
|
99
|
+
required: true,
|
|
100
|
+
placeholder: 'Tell us what you think...'
|
|
101
|
+
)
|
|
102
|
+
end
|
|
90
103
|
|
|
91
|
-
|
|
92
|
-
|
|
104
|
+
modal.label(label: 'Category') do |label|
|
|
105
|
+
label.string_select(custom_id: 'category', required: true) do |menu|
|
|
106
|
+
menu.option(label: 'Bug', value: 'bug')
|
|
107
|
+
menu.option(label: 'Idea', value: 'idea')
|
|
108
|
+
menu.option(label: 'Other', value: 'other')
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
93
112
|
end
|
|
113
|
+
```
|
|
94
114
|
|
|
95
|
-
|
|
96
|
-
puts "evento: #{payload['t']}"
|
|
97
|
-
end
|
|
115
|
+
### Community
|
|
98
116
|
|
|
99
|
-
|
|
100
|
-
puts "op: #{payload['op']}"
|
|
101
|
-
end
|
|
117
|
+
Join the Discord server for support, updates, examples, and feedback: https://discord.gg/Jy2tpCUtzM
|
|
102
118
|
|
|
103
|
-
|
|
119
|
+
## Portugues
|
|
120
|
+
|
|
121
|
+
OnyxCord e uma biblioteca Ruby para criar bots, integracoes, webhooks e experiencias interativas no Discord.
|
|
122
|
+
|
|
123
|
+
O projeto foi feito com base no `discordrb`, respeitando a base que tornou bots em Ruby simples de comecar, mas trazendo uma direcao nova para a comunidade: core mais leve, modo raw-first, suporte aos novos componentes de modal e Components V2 do Discord.
|
|
124
|
+
|
|
125
|
+
```txt
|
|
126
|
+
Simples para comecar, profundo para controlar.
|
|
104
127
|
```
|
|
105
128
|
|
|
106
|
-
|
|
107
|
-
|
|
129
|
+
### Destaques
|
|
130
|
+
|
|
131
|
+
- API Ruby amigavel para bots do Discord.
|
|
132
|
+
- Eventos tradicionais com objetos para quem quer produtividade.
|
|
133
|
+
- Eventos raw para quem quer performance e menos alocacao.
|
|
134
|
+
- Components V2 com `Text Display`, `Container`, `Section`, `Media Gallery`, `File`, `Separator` e `Thumbnail`.
|
|
135
|
+
- Novos componentes de modal, incluindo `Label`, `Text Display`, selects em modal, upload, radio group, checkbox group e checkbox.
|
|
136
|
+
- Webhooks com embeds, arquivos e componentes.
|
|
137
|
+
- Rate limiter e executor de eventos preparados para o core moderno do OnyxCord.
|
|
108
138
|
|
|
109
|
-
|
|
139
|
+
### Instalacao
|
|
110
140
|
|
|
111
|
-
|
|
141
|
+
Com Bundler:
|
|
112
142
|
|
|
113
143
|
```ruby
|
|
114
|
-
|
|
115
|
-
config.event_workers = 4
|
|
116
|
-
config.event_queue_size = 1_000
|
|
117
|
-
end
|
|
144
|
+
gem 'onyxcord'
|
|
118
145
|
```
|
|
119
146
|
|
|
120
|
-
|
|
147
|
+
Depois:
|
|
148
|
+
|
|
149
|
+
```sh
|
|
150
|
+
bundle install
|
|
151
|
+
```
|
|
121
152
|
|
|
122
|
-
|
|
153
|
+
Ou direto pelo RubyGems:
|
|
123
154
|
|
|
124
|
-
|
|
155
|
+
```sh
|
|
156
|
+
gem install onyxcord
|
|
157
|
+
```
|
|
125
158
|
|
|
126
|
-
|
|
159
|
+
### Primeiro Bot
|
|
127
160
|
|
|
128
161
|
```ruby
|
|
129
|
-
|
|
130
|
-
event.send_message!(content: nil, components_v2: true) do |_builder, view|
|
|
131
|
-
view.text_display(content: '## Painel OnyxCord')
|
|
132
|
-
view.text_display(content: 'Escolha uma ação abaixo.')
|
|
162
|
+
require 'onyxcord'
|
|
133
163
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
)
|
|
164
|
+
bot = OnyxCord::Bot.new(
|
|
165
|
+
token: ENV.fetch('DISCORD_TOKEN'),
|
|
166
|
+
intents: %i[servers server_messages direct_messages message_content],
|
|
167
|
+
mode: :hybrid
|
|
168
|
+
)
|
|
140
169
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
label: 'Ajuda',
|
|
144
|
-
custom_id: 'help_panel'
|
|
145
|
-
)
|
|
146
|
-
end
|
|
147
|
-
end
|
|
170
|
+
bot.message(content: 'ping') do |event|
|
|
171
|
+
event.respond!(content: 'pong')
|
|
148
172
|
end
|
|
149
173
|
|
|
150
|
-
bot.
|
|
151
|
-
event.respond(content: '
|
|
174
|
+
bot.application_command(:ping) do |event|
|
|
175
|
+
event.respond(content: 'Pong via Slash Command!')
|
|
152
176
|
end
|
|
177
|
+
|
|
178
|
+
bot.run
|
|
153
179
|
```
|
|
154
180
|
|
|
155
|
-
|
|
181
|
+
### Components V2
|
|
156
182
|
|
|
157
|
-
|
|
183
|
+
O OnyxCord aplica automaticamente a flag `IS_COMPONENTS_V2` quando voce usa componentes V2. Voce tambem pode deixar explicito com `components_v2: true`.
|
|
158
184
|
|
|
159
185
|
```ruby
|
|
160
|
-
bot.message(content: '!
|
|
161
|
-
event.send_message!(content: nil) do |_builder, view|
|
|
162
|
-
view.
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
section.button(
|
|
169
|
-
style: :success,
|
|
170
|
-
label: 'Atualizar',
|
|
171
|
-
custom_id: 'refresh_status'
|
|
172
|
-
)
|
|
173
|
-
end
|
|
186
|
+
bot.message(content: '!painel') do |event|
|
|
187
|
+
event.send_message!(content: nil, components_v2: true) do |_builder, view|
|
|
188
|
+
view.text_display(content: '## Painel OnyxCord')
|
|
189
|
+
view.text_display(content: 'Escolha uma acao abaixo.')
|
|
190
|
+
|
|
191
|
+
view.row do |row|
|
|
192
|
+
row.button(style: :primary, label: 'Abrir', custom_id: 'open_panel')
|
|
193
|
+
row.button(style: :secondary, label: 'Ajuda', custom_id: 'help_panel')
|
|
174
194
|
end
|
|
175
195
|
end
|
|
176
196
|
end
|
|
177
197
|
```
|
|
178
198
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
## Modais modernos
|
|
182
|
-
|
|
183
|
-
O OnyxCord também suporta os componentes novos de modal:
|
|
199
|
+
### Modais Modernos
|
|
184
200
|
|
|
185
201
|
```ruby
|
|
186
|
-
bot.register_application_command(
|
|
187
|
-
:feedback,
|
|
188
|
-
'Enviar feedback',
|
|
189
|
-
server_id: ENV.fetch('DISCORD_SERVER_ID')
|
|
190
|
-
)
|
|
191
|
-
|
|
192
202
|
bot.application_command(:feedback) do |event|
|
|
193
203
|
event.show_modal(title: 'Feedback', custom_id: 'feedback_modal') do |modal|
|
|
194
204
|
modal.label(label: 'Mensagem') do |label|
|
|
@@ -196,7 +206,7 @@ bot.application_command(:feedback) do |event|
|
|
|
196
206
|
style: :paragraph,
|
|
197
207
|
custom_id: 'message',
|
|
198
208
|
required: true,
|
|
199
|
-
placeholder: 'Conte o que
|
|
209
|
+
placeholder: 'Conte o que voce achou...'
|
|
200
210
|
)
|
|
201
211
|
end
|
|
202
212
|
|
|
@@ -207,112 +217,169 @@ bot.application_command(:feedback) do |event|
|
|
|
207
217
|
menu.option(label: 'Outro', value: 'other')
|
|
208
218
|
end
|
|
209
219
|
end
|
|
210
|
-
|
|
211
|
-
modal.text_display(content: 'Obrigado por ajudar a melhorar a comunidade.')
|
|
212
220
|
end
|
|
213
221
|
end
|
|
222
|
+
```
|
|
214
223
|
|
|
215
|
-
|
|
216
|
-
categoria = event.values('category')&.first
|
|
217
|
-
mensagem = event.value('message')
|
|
224
|
+
### Comunidade
|
|
218
225
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
226
|
+
Entre no servidor do Discord para suporte, atualizacoes, exemplos e feedback: https://discord.gg/Jy2tpCUtzM
|
|
227
|
+
|
|
228
|
+
## Espanol
|
|
229
|
+
|
|
230
|
+
OnyxCord es una biblioteca Ruby para crear bots, integraciones, webhooks y experiencias interactivas en Discord.
|
|
231
|
+
|
|
232
|
+
El proyecto esta basado en `discordrb`, manteniendo la idea que hizo simples los bots en Ruby, pero con una direccion moderna para la comunidad: nucleo mas ligero, modo raw-first, componentes modernos de modal y soporte para Components V2 de Discord.
|
|
233
|
+
|
|
234
|
+
```txt
|
|
235
|
+
Simple para empezar, profundo para controlar.
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Caracteristicas
|
|
239
|
+
|
|
240
|
+
- API Ruby amigable para bots de Discord.
|
|
241
|
+
- Eventos tradicionales con objetos para productividad.
|
|
242
|
+
- Eventos raw para rendimiento y menos asignaciones.
|
|
243
|
+
- Components V2 con `Text Display`, `Container`, `Section`, `Media Gallery`, `File`, `Separator` y `Thumbnail`.
|
|
244
|
+
- Componentes modernos de modal, incluyendo `Label`, `Text Display`, selects en modal, subida de archivos, radio group, checkbox group y checkbox.
|
|
245
|
+
- Webhooks con embeds, archivos y componentes.
|
|
246
|
+
- Rate limiter y executor de eventos preparados para el core moderno de OnyxCord.
|
|
247
|
+
|
|
248
|
+
### Instalacion
|
|
249
|
+
|
|
250
|
+
Con Bundler:
|
|
251
|
+
|
|
252
|
+
```ruby
|
|
253
|
+
gem 'onyxcord'
|
|
224
254
|
```
|
|
225
255
|
|
|
226
|
-
|
|
256
|
+
Despues:
|
|
227
257
|
|
|
228
|
-
|
|
258
|
+
```sh
|
|
259
|
+
bundle install
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
O directamente con RubyGems:
|
|
263
|
+
|
|
264
|
+
```sh
|
|
265
|
+
gem install onyxcord
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Primer Bot
|
|
229
269
|
|
|
230
270
|
```ruby
|
|
231
|
-
require 'onyxcord
|
|
271
|
+
require 'onyxcord'
|
|
232
272
|
|
|
233
|
-
|
|
234
|
-
|
|
273
|
+
bot = OnyxCord::Bot.new(
|
|
274
|
+
token: ENV.fetch('DISCORD_TOKEN'),
|
|
275
|
+
intents: %i[servers server_messages direct_messages message_content],
|
|
276
|
+
mode: :hybrid
|
|
235
277
|
)
|
|
236
278
|
|
|
237
|
-
|
|
238
|
-
|
|
279
|
+
bot.message(content: 'ping') do |event|
|
|
280
|
+
event.respond!(content: 'pong')
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
bot.application_command(:ping) do |event|
|
|
284
|
+
event.respond(content: 'Pong via Slash Command!')
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
bot.run
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Components V2
|
|
239
291
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
292
|
+
OnyxCord aplica automaticamente la flag `IS_COMPONENTS_V2` cuando usas componentes V2. Tambien puedes activarla de forma explicita con `components_v2: true`.
|
|
293
|
+
|
|
294
|
+
```ruby
|
|
295
|
+
bot.message(content: '!panel') do |event|
|
|
296
|
+
event.send_message!(content: nil, components_v2: true) do |_builder, view|
|
|
297
|
+
view.text_display(content: '## Panel OnyxCord')
|
|
298
|
+
view.text_display(content: 'Elige una accion abajo.')
|
|
299
|
+
|
|
300
|
+
view.row do |row|
|
|
301
|
+
row.button(style: :primary, label: 'Abrir', custom_id: 'open_panel')
|
|
302
|
+
row.button(style: :secondary, label: 'Ayuda', custom_id: 'help_panel')
|
|
303
|
+
end
|
|
244
304
|
end
|
|
245
305
|
end
|
|
246
306
|
```
|
|
247
307
|
|
|
248
|
-
|
|
308
|
+
### Modales Modernos
|
|
249
309
|
|
|
250
310
|
```ruby
|
|
251
|
-
|
|
252
|
-
|
|
311
|
+
bot.application_command(:feedback) do |event|
|
|
312
|
+
event.show_modal(title: 'Feedback', custom_id: 'feedback_modal') do |modal|
|
|
313
|
+
modal.label(label: 'Mensaje') do |label|
|
|
314
|
+
label.text_input(
|
|
315
|
+
style: :paragraph,
|
|
316
|
+
custom_id: 'message',
|
|
317
|
+
required: true,
|
|
318
|
+
placeholder: 'Cuentanos que piensas...'
|
|
319
|
+
)
|
|
320
|
+
end
|
|
253
321
|
|
|
254
|
-
|
|
255
|
-
|
|
322
|
+
modal.label(label: 'Categoria') do |label|
|
|
323
|
+
label.string_select(custom_id: 'category', required: true) do |menu|
|
|
324
|
+
menu.option(label: 'Bug', value: 'bug')
|
|
325
|
+
menu.option(label: 'Idea', value: 'idea')
|
|
326
|
+
menu.option(label: 'Otro', value: 'other')
|
|
327
|
+
end
|
|
328
|
+
end
|
|
329
|
+
end
|
|
256
330
|
end
|
|
257
331
|
```
|
|
258
332
|
|
|
259
|
-
|
|
333
|
+
### Comunidad
|
|
260
334
|
|
|
261
|
-
|
|
335
|
+
Unete al servidor de Discord para soporte, actualizaciones, ejemplos y feedback: https://discord.gg/Jy2tpCUtzM
|
|
262
336
|
|
|
263
|
-
|
|
337
|
+
## Dependencies
|
|
264
338
|
|
|
265
|
-
|
|
266
|
-
- Bundler recomendado.
|
|
267
|
-
- Build tools para extensões nativas, principalmente no Windows.
|
|
339
|
+
For normal bots:
|
|
268
340
|
|
|
269
|
-
|
|
341
|
+
- Ruby 3.3 or newer.
|
|
342
|
+
- Bundler is recommended.
|
|
343
|
+
- Build tools for native extensions, especially on Windows.
|
|
344
|
+
|
|
345
|
+
For voice features:
|
|
270
346
|
|
|
271
347
|
- `libsodium`
|
|
272
348
|
- `libopus`
|
|
273
349
|
- `FFmpeg`
|
|
274
350
|
|
|
275
|
-
|
|
351
|
+
Voice dependencies are only needed when your bot joins voice channels, plays audio, or works with voice packets. Text bots, commands, interactions, modals, webhooks, and Components V2 do not need `libsodium`.
|
|
276
352
|
|
|
277
|
-
##
|
|
353
|
+
## Examples
|
|
278
354
|
|
|
279
|
-
|
|
355
|
+
The `examples/` directory contains ready-to-use examples:
|
|
280
356
|
|
|
281
|
-
- `ping.rb`:
|
|
282
|
-
- `commands.rb`:
|
|
357
|
+
- `ping.rb`: simple ping/pong bot.
|
|
358
|
+
- `commands.rb`: classic commands.
|
|
283
359
|
- `slash_commands.rb`: slash commands.
|
|
284
360
|
- `components.rb`: Components V2.
|
|
285
|
-
- `modals.rb`:
|
|
286
|
-
- `select_menus.rb`: menus
|
|
361
|
+
- `modals.rb`: modern modals.
|
|
362
|
+
- `select_menus.rb`: select menus.
|
|
287
363
|
- `webhooks.rb`: webhooks.
|
|
288
|
-
- `voice_send.rb`:
|
|
289
|
-
|
|
290
|
-
## Desenvolvimento
|
|
364
|
+
- `voice_send.rb`: voice sending.
|
|
291
365
|
|
|
292
|
-
|
|
366
|
+
## Development
|
|
293
367
|
|
|
294
368
|
```sh
|
|
295
369
|
bundle install
|
|
296
370
|
bundle exec rspec spec
|
|
297
371
|
```
|
|
298
372
|
|
|
299
|
-
|
|
373
|
+
If `libsodium` is not installed, voice tests may fail. To test the rest:
|
|
300
374
|
|
|
301
375
|
```sh
|
|
302
376
|
bundle exec rspec $(find spec -name '*_spec.rb' ! -name 'sodium_spec.rb' | sort)
|
|
303
377
|
```
|
|
304
378
|
|
|
305
|
-
##
|
|
306
|
-
|
|
307
|
-
OnyxCord foi criado a partir da base do `discordrb`, uma biblioteca Ruby importante para a comunidade de bots no Discord.
|
|
308
|
-
|
|
309
|
-
Este projeto continua essa ideia com uma proposta atualizada:
|
|
379
|
+
## Credits
|
|
310
380
|
|
|
311
|
-
|
|
312
|
-
- modernizar o core;
|
|
313
|
-
- adicionar suporte aos novos componentes do Discord;
|
|
314
|
-
- entregar uma base aberta para a comunidade evoluir.
|
|
381
|
+
OnyxCord was created from the foundation of `discordrb`, an important Ruby library for the Discord bot community.
|
|
315
382
|
|
|
316
|
-
##
|
|
383
|
+
## License
|
|
317
384
|
|
|
318
|
-
|
|
385
|
+
Open source under the MIT license.
|
|
@@ -485,6 +485,14 @@ module OnyxCord
|
|
|
485
485
|
|
|
486
486
|
# A parent component for interactive modal components.
|
|
487
487
|
class Label
|
|
488
|
+
# Methods from the wrapped interactive component that should remain
|
|
489
|
+
# available for legacy modal code that iterates over event.components.
|
|
490
|
+
DELEGATED_COMPONENT_METHODS = %i[
|
|
491
|
+
custom_id
|
|
492
|
+
value
|
|
493
|
+
values
|
|
494
|
+
].freeze
|
|
495
|
+
|
|
488
496
|
# @return [Integer] the numeric identifier of the label.
|
|
489
497
|
attr_reader :id
|
|
490
498
|
|
|
@@ -505,6 +513,12 @@ module OnyxCord
|
|
|
505
513
|
@description = data['description']
|
|
506
514
|
@component = Components.from_data(data['component'], @bot)
|
|
507
515
|
end
|
|
516
|
+
|
|
517
|
+
DELEGATED_COMPONENT_METHODS.each do |name|
|
|
518
|
+
define_method(name) do
|
|
519
|
+
@component.public_send(name) if @component.respond_to?(name)
|
|
520
|
+
end
|
|
521
|
+
end
|
|
508
522
|
end
|
|
509
523
|
|
|
510
524
|
# A surface that allows users to upload files in a modal.
|
data/lib/onyxcord/version.rb
CHANGED
data/onyxcord-webhooks.gemspec
CHANGED
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
|
9
9
|
spec.email = ['gustavosilva8kt@gmail.com']
|
|
10
10
|
|
|
11
11
|
spec.summary = 'Webhook client for onyxcord'
|
|
12
|
-
spec.description = "
|
|
12
|
+
spec.description = "Webhook client for OnyxCord with Components V2 support and community support: https://discord.gg/Jy2tpCUtzM."
|
|
13
13
|
spec.homepage = 'https://github.com/kruldevb/OnyxCord'
|
|
14
14
|
spec.license = 'MIT'
|
|
15
15
|
|
data/onyxcord.gemspec
CHANGED
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
|
10
10
|
spec.email = ['gustavosilva8kt@gmail.com']
|
|
11
11
|
|
|
12
12
|
spec.summary = 'Discord API for Ruby with Components V2 support'
|
|
13
|
-
spec.description = '
|
|
13
|
+
spec.description = 'OnyxCord is a Ruby Discord API library with Components V2, modern modals, raw-first events, and community support: https://discord.gg/Jy2tpCUtzM.'
|
|
14
14
|
spec.homepage = 'https://github.com/kruldevb/OnyxCord'
|
|
15
15
|
spec.license = 'MIT'
|
|
16
16
|
|
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: 1.1.
|
|
4
|
+
version: 1.1.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gustavo Silva
|
|
@@ -109,14 +109,14 @@ dependencies:
|
|
|
109
109
|
requirements:
|
|
110
110
|
- - "~>"
|
|
111
111
|
- !ruby/object:Gem::Version
|
|
112
|
-
version: 1.1.
|
|
112
|
+
version: 1.1.8
|
|
113
113
|
type: :runtime
|
|
114
114
|
prerelease: false
|
|
115
115
|
version_requirements: !ruby/object:Gem::Requirement
|
|
116
116
|
requirements:
|
|
117
117
|
- - "~>"
|
|
118
118
|
- !ruby/object:Gem::Version
|
|
119
|
-
version: 1.1.
|
|
119
|
+
version: 1.1.8
|
|
120
120
|
- !ruby/object:Gem::Dependency
|
|
121
121
|
name: bundler
|
|
122
122
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -277,8 +277,8 @@ dependencies:
|
|
|
277
277
|
- - "~>"
|
|
278
278
|
- !ruby/object:Gem::Version
|
|
279
279
|
version: 0.9.37
|
|
280
|
-
description:
|
|
281
|
-
|
|
280
|
+
description: 'OnyxCord is a Ruby Discord API library with Components V2, modern modals,
|
|
281
|
+
raw-first events, and community support: https://discord.gg/Jy2tpCUtzM.'
|
|
282
282
|
email:
|
|
283
283
|
- gustavosilva8kt@gmail.com
|
|
284
284
|
executables: []
|
|
@@ -416,8 +416,6 @@ files:
|
|
|
416
416
|
- lib/onyxcord/websocket.rb
|
|
417
417
|
- onyxcord-webhooks.gemspec
|
|
418
418
|
- onyxcord.gemspec
|
|
419
|
-
- relator.md
|
|
420
|
-
- relatorio2.md
|
|
421
419
|
homepage: https://github.com/kruldevb/OnyxCord
|
|
422
420
|
licenses:
|
|
423
421
|
- MIT
|
data/relator.md
DELETED
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
# Relatorio geral da OnyxCord
|
|
2
|
-
|
|
3
|
-
Data da analise: 2026-06-23
|
|
4
|
-
|
|
5
|
-
Escopo analisado:
|
|
6
|
-
- Gem Ruby `onyxcord` e `onyxcord-webhooks`.
|
|
7
|
-
- Areas principais: REST API, gateway WebSocket, cache, executor de eventos, comandos/interactions, voice e webhooks.
|
|
8
|
-
- Teste executado: `bundle exec rspec`.
|
|
9
|
-
|
|
10
|
-
Resultado da validacao atual:
|
|
11
|
-
- `bundle exec rspec`: 456 exemplos, 0 falhas, 3 pendentes.
|
|
12
|
-
- Cobertura reportada pelo SimpleCov: 60,84% de linhas.
|
|
13
|
-
- `gem build onyxcord.gemspec`: sucesso, gerou `onyxcord-1.1.2.gem`.
|
|
14
|
-
- `gem build onyxcord-webhooks.gemspec`: sucesso, gerou `onyxcord-webhooks-1.1.2.gem`.
|
|
15
|
-
|
|
16
|
-
Status das correcoes aplicadas:
|
|
17
|
-
- Corrigido retry REST `202` preservando route e major parameter.
|
|
18
|
-
- Application commands agora executam pelo `EventExecutor`, sem `Thread.new` direto nesse caminho.
|
|
19
|
-
- Adicionado `event_queue_size` com `SizedQueue` opcional.
|
|
20
|
-
- Adicionados `runtime_stats`, `cache_stats`, `prune_cache!` e `OnyxCord::API.rate_limiter_stats`.
|
|
21
|
-
- Rate limiter REST agora tem `stats`, `prune!` e limpeza automatica de bookkeeping antigo.
|
|
22
|
-
- Voice fecha melhor recursos de UDP/WebSocket/thread, e `play_dca` usa `File.open` com bloco.
|
|
23
|
-
- Dependencias principais receberam upper bounds conservadores.
|
|
24
|
-
- Warning de spec em `spec/bot_spec.rb:114` foi corrigido.
|
|
25
|
-
|
|
26
|
-
## Resumo executivo
|
|
27
|
-
|
|
28
|
-
A lib ja tem algumas decisoes boas para performance:
|
|
29
|
-
- O modo padrao do bot agora e `hybrid`, equilibrando handlers raw com eventos em objeto.
|
|
30
|
-
- O cache padrao global esta em `:none`, o que ajuda a reduzir RAM para bots pequenos.
|
|
31
|
-
- Ja existe `EventExecutor::Pool`, evitando uma thread nova para cada evento comum.
|
|
32
|
-
- O rate limiter REST ja centraliza buckets, global limit e `retry_after`.
|
|
33
|
-
- O gateway usa zlib stream, economizando trafego e CPU em payloads grandes.
|
|
34
|
-
|
|
35
|
-
Os maiores ganhos agora estao em 5 frentes:
|
|
36
|
-
1. Eliminar threads soltas em interactions e waits.
|
|
37
|
-
2. Colocar limite/backpressure no executor de eventos.
|
|
38
|
-
3. Colocar estrategia de limite/limpeza nos caches e nos mapas do rate limiter.
|
|
39
|
-
4. Corrigir um bug provavel no retry de resposta REST `202`.
|
|
40
|
-
5. Fechar recursos de voz/arquivos/sockets de forma garantida.
|
|
41
|
-
|
|
42
|
-
## Prioridade alta
|
|
43
|
-
|
|
44
|
-
### 1. Corrigir retry de REST `202` em `OnyxCord::API.request`
|
|
45
|
-
|
|
46
|
-
Arquivo: `lib/onyxcord/api.rb:141-154`
|
|
47
|
-
|
|
48
|
-
Problema:
|
|
49
|
-
- Quando Discord retorna `202` com codigo `110000`, o metodo tenta repetir a request.
|
|
50
|
-
- A chamada atual usa `return request(*key, type, *attributes)`.
|
|
51
|
-
- Na maior parte da API, `key` e um `Symbol`, entao `*key` tende a quebrar com `TypeError` ou chamar `request` com parametros errados.
|
|
52
|
-
|
|
53
|
-
Impacto:
|
|
54
|
-
- Endpoints baseados em Elasticsearch podem falhar justamente no fluxo em que deveriam aguardar e tentar de novo.
|
|
55
|
-
|
|
56
|
-
Sugestao:
|
|
57
|
-
- Trocar para `return request(key, major_parameter, type, *attributes)`.
|
|
58
|
-
- Adicionar spec cobrindo response `202` com `retry_after`.
|
|
59
|
-
|
|
60
|
-
### 2. Application commands criam `Thread.new` fora do executor
|
|
61
|
-
|
|
62
|
-
Arquivo: `lib/onyxcord/bot.rb:1679-1704`
|
|
63
|
-
|
|
64
|
-
Problema:
|
|
65
|
-
- O fluxo de `INTERACTION_CREATE` para command cria uma thread direta por comando.
|
|
66
|
-
- Isso ignora `EventExecutor::Pool`, ignora `event_workers` e remove qualquer controle de concorrencia.
|
|
67
|
-
- Tambem ha logs temporarios com prefixo `>>>` em caminho quente.
|
|
68
|
-
- O rescue usa `rescue Exception`, que captura sinais de sistema e saidas do processo.
|
|
69
|
-
|
|
70
|
-
Impacto:
|
|
71
|
-
- Em pico de interactions, o processo pode criar muitas threads, consumindo RAM e escalonamento de CPU.
|
|
72
|
-
- Logs verbosos em production aumentam I/O e custo de CPU.
|
|
73
|
-
|
|
74
|
-
Sugestao:
|
|
75
|
-
- Executar handler via `@event_executor.post`.
|
|
76
|
-
- Usar `rescue StandardError`.
|
|
77
|
-
- Trocar logs `info` temporarios por `debug` ou remover.
|
|
78
|
-
- Nomear a thread dentro do bloco do executor, como ja acontece em `call_event`.
|
|
79
|
-
|
|
80
|
-
### 3. Fila de eventos sem limite
|
|
81
|
-
|
|
82
|
-
Arquivo: `lib/onyxcord/event_executor.rb:28-42`
|
|
83
|
-
|
|
84
|
-
Problema:
|
|
85
|
-
- `Queue.new` e ilimitada.
|
|
86
|
-
- Se os handlers forem mais lentos que os eventos recebidos, a fila cresce sem backpressure.
|
|
87
|
-
|
|
88
|
-
Impacto:
|
|
89
|
-
- Pode virar crescimento progressivo de RAM em servidores grandes ou bots com handlers pesados.
|
|
90
|
-
|
|
91
|
-
Sugestao:
|
|
92
|
-
- Adicionar opcao `event_queue_size`, usando `SizedQueue`.
|
|
93
|
-
- Expor comportamento configuravel: bloquear, rejeitar com log, ou executar inline em emergencia.
|
|
94
|
-
- Medir tamanho da fila em debug/telemetria.
|
|
95
|
-
|
|
96
|
-
## Prioridade media
|
|
97
|
-
|
|
98
|
-
### 4. Rate limiter guarda mutexes e buckets para sempre
|
|
99
|
-
|
|
100
|
-
Arquivo: `lib/onyxcord/rate_limiter/rest.rb:10-47`
|
|
101
|
-
|
|
102
|
-
Problema:
|
|
103
|
-
- `@route_buckets` e `@bucket_mutexes` crescem conforme novas rotas/major parameters aparecem.
|
|
104
|
-
- Para bots que tocam muitos canais, guilds, mensagens ou webhooks, isso pode acumular.
|
|
105
|
-
|
|
106
|
-
Impacto:
|
|
107
|
-
- RAM pequena por item, mas permanente.
|
|
108
|
-
|
|
109
|
-
Sugestao:
|
|
110
|
-
- Guardar `last_used_at` por bucket e limpar entradas antigas.
|
|
111
|
-
- Alternativa simples: limitar por LRU.
|
|
112
|
-
- Adicionar metodo `prune!` chamado ocasionalmente em `record_response`.
|
|
113
|
-
|
|
114
|
-
### 5. Cache full pode crescer sem limite
|
|
115
|
-
|
|
116
|
-
Arquivo: `lib/onyxcord/cache.rb:16-29`
|
|
117
|
-
|
|
118
|
-
Problema:
|
|
119
|
-
- Caches de users, channels, pm_channels, thread_members e server_previews sao Hashes sem TTL/max size.
|
|
120
|
-
- O default global e `:none`, mas quem usa `:full` pode segurar muitos objetos.
|
|
121
|
-
|
|
122
|
-
Impacto:
|
|
123
|
-
- Em bots grandes, memoria cresce com o tempo e dificilmente volta.
|
|
124
|
-
|
|
125
|
-
Sugestao:
|
|
126
|
-
- Manter `:none` como default.
|
|
127
|
-
- Adicionar opcoes por cache: `max_users`, `max_channels`, `max_messages`, `ttl`.
|
|
128
|
-
- Oferecer `bot.prune_cache!` e `bot.cache_stats`.
|
|
129
|
-
- Considerar guardar payload cru em modo leve, criando objeto sob demanda.
|
|
130
|
-
|
|
131
|
-
### 6. `request_chunks` cria buckets por guild sem limpeza
|
|
132
|
-
|
|
133
|
-
Arquivo: `lib/onyxcord/cache.rb:235-253`
|
|
134
|
-
|
|
135
|
-
Problema:
|
|
136
|
-
- `@request_members_rl[id]` guarda mutex/time por guild e nunca remove.
|
|
137
|
-
|
|
138
|
-
Impacto:
|
|
139
|
-
- Baixo por guild, mas permanente em bots que entram/saem de muitos servidores.
|
|
140
|
-
|
|
141
|
-
Sugestao:
|
|
142
|
-
- Remover no evento de saida de guild.
|
|
143
|
-
- Limpar buckets nao usados ha alguns minutos/horas.
|
|
144
|
-
|
|
145
|
-
### 7. Voice pode deixar arquivo aberto em `play_dca`
|
|
146
|
-
|
|
147
|
-
Arquivo: `lib/onyxcord/voice/voice_bot.rb:264-299`
|
|
148
|
-
|
|
149
|
-
Problema:
|
|
150
|
-
- `File.open(file)` nao usa bloco nem `ensure`.
|
|
151
|
-
- Se erro ocorrer durante validacao ou playback, o descritor pode ficar aberto.
|
|
152
|
-
|
|
153
|
-
Impacto:
|
|
154
|
-
- Vazamento de file descriptor em uso repetido de voz.
|
|
155
|
-
|
|
156
|
-
Sugestao:
|
|
157
|
-
- Usar `File.open(file) do |input_stream| ... end` ou `ensure input_stream&.close`.
|
|
158
|
-
|
|
159
|
-
### 8. Voice WebSocket nao fecha/junta thread explicitamente
|
|
160
|
-
|
|
161
|
-
Arquivo: `lib/onyxcord/voice/network.rb:321-344`
|
|
162
|
-
|
|
163
|
-
Problema:
|
|
164
|
-
- `destroy` apenas seta `@heartbeat_running = false`.
|
|
165
|
-
- Nao fecha o WebSocket, nao fecha UDP e nao faz join da thread.
|
|
166
|
-
|
|
167
|
-
Impacto:
|
|
168
|
-
- Possivel sobra de thread/socket em reconexoes ou destroy repetido.
|
|
169
|
-
|
|
170
|
-
Sugestao:
|
|
171
|
-
- Implementar close de `@client`, close de UDP socket e `@thread.join` com timeout curto.
|
|
172
|
-
- Adicionar spec com fake socket/client garantindo cleanup.
|
|
173
|
-
|
|
174
|
-
### 9. Busy wait com `sleep` em pontos sensiveis
|
|
175
|
-
|
|
176
|
-
Arquivos:
|
|
177
|
-
- `lib/onyxcord/voice/network.rb:338`
|
|
178
|
-
- `lib/onyxcord/voice/voice_bot.rb:315`
|
|
179
|
-
- `lib/onyxcord/bot.rb:413`
|
|
180
|
-
|
|
181
|
-
Problema:
|
|
182
|
-
- Loops `sleep until` e `sleep while` sao simples, mas acordam periodicamente sem evento real.
|
|
183
|
-
|
|
184
|
-
Impacto:
|
|
185
|
-
- Baixo em poucos bots, mas piora com muitas conexoes/threads.
|
|
186
|
-
|
|
187
|
-
Sugestao:
|
|
188
|
-
- Usar `ConditionVariable` para readiness/pausa.
|
|
189
|
-
- Para voice playback, manter cuidado para nao prejudicar o timing de audio.
|
|
190
|
-
|
|
191
|
-
## Prioridade baixa / limpeza
|
|
192
|
-
|
|
193
|
-
### 10. Webhooks nao usam o rate limiter central
|
|
194
|
-
|
|
195
|
-
Arquivo: `lib/onyxcord/webhooks/client.rb`
|
|
196
|
-
|
|
197
|
-
Problema:
|
|
198
|
-
- Chamadas usam `RestClient.post/patch/delete` direto.
|
|
199
|
-
- Isso e simples, mas nao aproveita `OnyxCord::RateLimiter::Rest`.
|
|
200
|
-
|
|
201
|
-
Impacto:
|
|
202
|
-
- Clientes de webhook intensivos podem bater 429 com menos controle.
|
|
203
|
-
|
|
204
|
-
Sugestao:
|
|
205
|
-
- Criar transport compartilhado leve para webhooks.
|
|
206
|
-
- Ou criar um rate limiter dedicado por webhook URL.
|
|
207
|
-
|
|
208
|
-
### 11. Dependencias abertas demais
|
|
209
|
-
|
|
210
|
-
Arquivos:
|
|
211
|
-
- `onyxcord.gemspec`
|
|
212
|
-
- `onyxcord-webhooks.gemspec`
|
|
213
|
-
|
|
214
|
-
Problema:
|
|
215
|
-
- Algumas dependencias permitem qualquer versao acima do minimo, como `rest-client >= 2.0.0`, `websocket-client-simple >= 0.9.0`, `ffi >= 1.9.24` e `opus-ruby` sem limite.
|
|
216
|
-
|
|
217
|
-
Impacto:
|
|
218
|
-
- Atualizacao futura pode quebrar performance ou compatibilidade.
|
|
219
|
-
|
|
220
|
-
Sugestao:
|
|
221
|
-
- Definir upper bounds conservadores, por exemplo `< 3` quando fizer sentido.
|
|
222
|
-
- Rodar CI com Ruby 3.3 e 3.4 se a gem prometer suporte moderno.
|
|
223
|
-
|
|
224
|
-
### 12. Arquivo `bot.rb` esta grande demais
|
|
225
|
-
|
|
226
|
-
Arquivo: `lib/onyxcord/bot.rb` tem cerca de 1971 linhas.
|
|
227
|
-
|
|
228
|
-
Problema:
|
|
229
|
-
- O arquivo mistura boot, REST helpers, dispatch, cache orchestration, interactions, voice e commands.
|
|
230
|
-
|
|
231
|
-
Impacto:
|
|
232
|
-
- Dificulta otimizar sem regressao.
|
|
233
|
-
|
|
234
|
-
Sugestao:
|
|
235
|
-
- Extrair aos poucos:
|
|
236
|
-
- `Bot::Interactions`
|
|
237
|
-
- `Bot::Dispatch`
|
|
238
|
-
- `Bot::Voice`
|
|
239
|
-
- `Bot::ApplicationCommands`
|
|
240
|
-
- Fazer isso depois das correcoes de runtime, para nao misturar refactor com bugfix.
|
|
241
|
-
|
|
242
|
-
## Otimizacoes praticas sugeridas
|
|
243
|
-
|
|
244
|
-
### Perfil leve recomendado para usuarios
|
|
245
|
-
|
|
246
|
-
Documentar no README um preset para bots pequenos:
|
|
247
|
-
|
|
248
|
-
```ruby
|
|
249
|
-
OnyxCord.configure do |config|
|
|
250
|
-
config.mode = :raw
|
|
251
|
-
config.cache = :none
|
|
252
|
-
config.event_executor = :pool
|
|
253
|
-
config.event_workers = 2
|
|
254
|
-
end
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
Para bots medios:
|
|
258
|
-
|
|
259
|
-
```ruby
|
|
260
|
-
OnyxCord.configure do |config|
|
|
261
|
-
config.mode = :hybrid
|
|
262
|
-
config.cache = :minimal
|
|
263
|
-
config.event_workers = 4
|
|
264
|
-
end
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
### Medir antes/depois
|
|
268
|
-
|
|
269
|
-
Criar specs/benchmarks simples para:
|
|
270
|
-
- `INTERACTION_CREATE` com 1000 commands simulados.
|
|
271
|
-
- `MESSAGE_CREATE` em modo `raw`, `hybrid` e `object`.
|
|
272
|
-
- crescimento de `@users`, `@channels`, `@thread_members`.
|
|
273
|
-
- fila do executor quando handler dorme 50ms.
|
|
274
|
-
|
|
275
|
-
### Instrumentacao leve
|
|
276
|
-
|
|
277
|
-
Adicionar metodos opcionais:
|
|
278
|
-
- `bot.runtime_stats`
|
|
279
|
-
- `bot.cache_stats`
|
|
280
|
-
- `bot.event_queue_size`
|
|
281
|
-
- `OnyxCord::API.rate_limiter_stats`
|
|
282
|
-
|
|
283
|
-
Isso ajuda a diagnosticar RAM e lentidao sem profiler externo.
|
|
284
|
-
|
|
285
|
-
## Plano de acao recomendado
|
|
286
|
-
|
|
287
|
-
1. Corrigir `API.request` no retry `202` e adicionar spec.
|
|
288
|
-
2. Remover threads soltas dos application commands e usar `@event_executor`.
|
|
289
|
-
3. Remover logs `>>>` ou rebaixar para `debug`.
|
|
290
|
-
4. Trocar `Queue` por `SizedQueue` configuravel.
|
|
291
|
-
5. Adicionar `cache_stats` e `prune_cache!`.
|
|
292
|
-
6. Fechar corretamente recursos de voice (`File.open`, UDP, WS, thread).
|
|
293
|
-
7. Adicionar limpeza/LRU no rate limiter REST.
|
|
294
|
-
8. Depois disso, refatorar `bot.rb` em modulos menores.
|
|
295
|
-
|
|
296
|
-
## Conclusao
|
|
297
|
-
|
|
298
|
-
A OnyxCord ja esta no caminho certo para ser pratica no modo padrao `hybrid` e ainda leve quando o usuario escolher `raw` com cache `:none`. O maior risco atual nao e um unico algoritmo pesado, e sim crescimento sem limite: threads por interaction, fila ilimitada, caches sem TTL e mapas internos que nao expiram. Corrigir esses pontos deve reduzir RAM em carga real, deixar o bot mais previsivel em pico e facilitar otimizar depois sem mexer na API publica.
|
data/relatorio2.md
DELETED
|
File without changes
|