onyxcord 2.1.0 → 3.2.1
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/application_commands/command.rb +4 -97
- data/lib/onyxcord/application_commands/context.rb +4 -94
- data/lib/onyxcord/application_commands/option.rb +4 -75
- data/lib/onyxcord/application_commands/registry.rb +4 -45
- data/lib/onyxcord/application_commands.rb +8 -5
- data/lib/onyxcord/bot.rb +24 -1759
- data/lib/onyxcord/{cache.rb → cache/manager.rb} +16 -14
- data/lib/onyxcord/cache/stores/gateway.rb +272 -0
- data/lib/onyxcord/commands/bot/channels.rb +48 -0
- data/lib/onyxcord/commands/bot/execution.rb +174 -0
- data/lib/onyxcord/commands/bot/message_dispatch.rb +58 -0
- data/lib/onyxcord/commands/bot/permissions.rb +72 -0
- data/lib/onyxcord/commands/bot.rb +209 -0
- data/lib/onyxcord/commands/container.rb +21 -2
- data/lib/onyxcord/commands/parser.rb +30 -1
- data/lib/onyxcord/container.rb +16 -960
- data/lib/onyxcord/core/bot/application_commands.rb +210 -0
- data/lib/onyxcord/core/bot/awaits.rb +112 -0
- data/lib/onyxcord/core/bot/invites.rb +42 -0
- data/lib/onyxcord/core/bot/messaging.rb +161 -0
- data/lib/onyxcord/core/bot/oauth.rb +27 -0
- data/lib/onyxcord/core/bot/presence.rb +103 -0
- data/lib/onyxcord/core/bot/runtime.rb +183 -0
- data/lib/onyxcord/core/bot/voice.rb +69 -0
- data/lib/onyxcord/{logger.rb → core/logger.rb} +5 -0
- data/lib/onyxcord/core/version.rb +5 -0
- data/lib/onyxcord/events/await/base.rb +48 -0
- data/lib/onyxcord/events/await.rb +1 -46
- data/lib/onyxcord/events/ban/base.rb +54 -0
- data/lib/onyxcord/events/ban/remove.rb +11 -0
- data/lib/onyxcord/events/bans.rb +2 -58
- data/lib/onyxcord/events/channels/base.rb +91 -0
- data/lib/onyxcord/events/channels/delete.rb +73 -0
- data/lib/onyxcord/events/channels/pins.rb +44 -0
- data/lib/onyxcord/events/channels/recipients.rb +77 -0
- data/lib/onyxcord/events/channels.rb +4 -239
- data/lib/onyxcord/events/guilds/audit_logs.rb +79 -0
- data/lib/onyxcord/events/guilds/base.rb +97 -0
- data/lib/onyxcord/events/guilds/emoji.rb +147 -0
- data/lib/onyxcord/events/guilds.rb +3 -267
- data/lib/onyxcord/events/handlers/channels.rb +133 -0
- data/lib/onyxcord/events/handlers/core.rb +146 -0
- data/lib/onyxcord/events/handlers/guilds.rb +375 -0
- data/lib/onyxcord/events/handlers/interactions.rb +238 -0
- data/lib/onyxcord/events/handlers/lifetime.rb +71 -0
- data/lib/onyxcord/events/handlers/messages.rb +218 -0
- data/lib/onyxcord/events/handlers/presence.rb +56 -0
- data/lib/onyxcord/events/handlers/raw.rb +39 -0
- data/lib/onyxcord/events/handlers/reactions.rb +98 -0
- data/lib/onyxcord/events/handlers/scheduled_events.rb +243 -0
- data/lib/onyxcord/events/handlers/voice.rb +46 -0
- data/lib/onyxcord/events/integration/base.rb +45 -0
- data/lib/onyxcord/events/integration/create.rb +11 -0
- data/lib/onyxcord/events/integration/delete.rb +48 -0
- data/lib/onyxcord/events/integration/update.rb +11 -0
- data/lib/onyxcord/events/integrations.rb +4 -98
- data/lib/onyxcord/events/interactions/application_commands.rb +185 -0
- data/lib/onyxcord/events/interactions/autocomplete.rb +62 -0
- data/lib/onyxcord/events/interactions/base.rb +175 -0
- data/lib/onyxcord/events/interactions/components.rb +221 -0
- data/lib/onyxcord/events/interactions/permissions.rb +53 -0
- data/lib/onyxcord/events/interactions.rb +5 -622
- data/lib/onyxcord/events/invite/create.rb +79 -0
- data/lib/onyxcord/events/invite/delete.rb +55 -0
- data/lib/onyxcord/events/invites.rb +2 -125
- data/lib/onyxcord/events/lifetime/base.rb +31 -0
- data/lib/onyxcord/events/lifetime.rb +1 -29
- data/lib/onyxcord/events/member/add.rb +12 -0
- data/lib/onyxcord/events/member/base.rb +67 -0
- data/lib/onyxcord/events/member/delete.rb +21 -0
- data/lib/onyxcord/events/member/update.rb +25 -0
- data/lib/onyxcord/events/members.rb +4 -108
- data/lib/onyxcord/events/message/base.rb +295 -0
- data/lib/onyxcord/events/message/ids.rb +71 -0
- data/lib/onyxcord/events/message/mentions.rb +55 -0
- data/lib/onyxcord/events/message/updates.rb +27 -0
- data/lib/onyxcord/events/message.rb +4 -397
- data/lib/onyxcord/events/poll/add.rb +11 -0
- data/lib/onyxcord/events/poll/base.rb +106 -0
- data/lib/onyxcord/events/poll/remove.rb +11 -0
- data/lib/onyxcord/events/polls.rb +3 -116
- data/lib/onyxcord/events/presence/playing.rb +77 -0
- data/lib/onyxcord/events/presence/status.rb +60 -0
- data/lib/onyxcord/events/presence.rb +2 -129
- data/lib/onyxcord/events/raw/base.rb +74 -0
- data/lib/onyxcord/events/raw.rb +1 -72
- data/lib/onyxcord/events/reactions/base.rb +143 -0
- data/lib/onyxcord/events/reactions/clear.rb +99 -0
- data/lib/onyxcord/events/reactions.rb +2 -216
- data/lib/onyxcord/events/role/create.rb +46 -0
- data/lib/onyxcord/events/role/delete.rb +40 -0
- data/lib/onyxcord/events/role/update.rb +11 -0
- data/lib/onyxcord/events/roles.rb +3 -85
- data/lib/onyxcord/events/scheduled_events/events.rb +112 -0
- data/lib/onyxcord/events/scheduled_events/users.rb +91 -0
- data/lib/onyxcord/events/scheduled_events.rb +2 -169
- data/lib/onyxcord/events/thread/base.rb +49 -0
- data/lib/onyxcord/events/thread/members.rb +44 -0
- data/lib/onyxcord/events/thread/update.rb +18 -0
- data/lib/onyxcord/events/threads.rb +3 -98
- data/lib/onyxcord/events/typing/base.rb +73 -0
- data/lib/onyxcord/events/typing.rb +1 -71
- data/lib/onyxcord/events/voice/server_update.rb +48 -0
- data/lib/onyxcord/events/voice/state_update.rb +137 -0
- data/lib/onyxcord/events/voice_server_update.rb +2 -46
- data/lib/onyxcord/events/voice_state_update.rb +2 -135
- data/lib/onyxcord/events/webhook/update.rb +65 -0
- data/lib/onyxcord/events/webhooks.rb +1 -63
- data/lib/onyxcord/gateway/client.rb +460 -0
- data/lib/onyxcord/interactions/command.rb +120 -0
- data/lib/onyxcord/interactions/context.rb +109 -0
- data/lib/onyxcord/interactions/internal/application_command.rb +203 -0
- data/lib/onyxcord/interactions/internal/message.rb +152 -0
- data/lib/onyxcord/interactions/internal/metadata.rb +109 -0
- data/lib/onyxcord/interactions/internal/option_builder.rb +230 -0
- data/lib/onyxcord/interactions/internal/permission_builder.rb +90 -0
- data/lib/onyxcord/interactions/option.rb +88 -0
- data/lib/onyxcord/interactions/registry.rb +50 -0
- data/lib/onyxcord/interactions.rb +16 -0
- data/lib/onyxcord/internal/async_runtime.rb +32 -0
- data/lib/onyxcord/internal/event_bus.rb +591 -0
- data/lib/onyxcord/internal/event_executor.rb +155 -0
- data/lib/onyxcord/internal/gateway/opcodes.rb +22 -0
- data/lib/onyxcord/internal/gateway/session.rb +45 -0
- data/lib/onyxcord/internal/http.rb +189 -0
- data/lib/onyxcord/internal/json.rb +51 -0
- data/lib/onyxcord/{message_payload.rb → internal/message_payload.rb} +3 -3
- data/lib/onyxcord/internal/rate_limiter/async_rest.rb +151 -0
- data/lib/onyxcord/internal/rate_limiter/gateway.rb +44 -0
- data/lib/onyxcord/internal/rate_limiter/rest.rb +144 -0
- data/lib/onyxcord/internal/websocket.rb +79 -0
- data/lib/onyxcord/light/data.rb +1 -1
- data/lib/onyxcord/light/integrations.rb +1 -1
- data/lib/onyxcord/light/light_bot.rb +7 -7
- data/lib/onyxcord/{data → models}/activity.rb +2 -2
- data/lib/onyxcord/{data → models}/application.rb +3 -3
- data/lib/onyxcord/{data → models}/avatar_decoration.rb +1 -1
- data/lib/onyxcord/{data → models}/channel.rb +23 -23
- data/lib/onyxcord/{data → models}/collectibles.rb +1 -1
- data/lib/onyxcord/{data → models}/emoji.rb +1 -1
- data/lib/onyxcord/models/interaction.rb +450 -0
- data/lib/onyxcord/{data → models}/invite.rb +1 -1
- data/lib/onyxcord/{data → models}/member.rb +11 -11
- data/lib/onyxcord/{data → models}/message.rb +18 -14
- data/lib/onyxcord/{data → models}/poll.rb +2 -2
- data/lib/onyxcord/{data → models}/primary_server.rb +1 -1
- data/lib/onyxcord/{data → models}/profile.rb +4 -4
- data/lib/onyxcord/{data → models}/role.rb +6 -12
- data/lib/onyxcord/{data → models}/scheduled_event.rb +5 -5
- data/lib/onyxcord/{data → models}/server.rb +41 -41
- data/lib/onyxcord/{data → models}/server_preview.rb +2 -2
- data/lib/onyxcord/{data → models}/team.rb +1 -1
- data/lib/onyxcord/{data → models}/user.rb +5 -5
- data/lib/onyxcord/{data → models}/webhook.rb +10 -10
- data/lib/onyxcord/models.rb +57 -0
- data/lib/onyxcord/{api.rb → rest/client.rb} +23 -22
- data/lib/onyxcord/{api → rest/routes}/application.rb +79 -57
- data/lib/onyxcord/rest/routes/channel/base.rb +73 -0
- data/lib/onyxcord/rest/routes/channel/groups.rb +78 -0
- data/lib/onyxcord/rest/routes/channel/messages.rb +130 -0
- data/lib/onyxcord/rest/routes/channel/permissions.rb +73 -0
- data/lib/onyxcord/rest/routes/channel/pins.rb +45 -0
- data/lib/onyxcord/rest/routes/channel/polls.rb +32 -0
- data/lib/onyxcord/rest/routes/channel/reactions.rb +86 -0
- data/lib/onyxcord/rest/routes/channel/threads.rb +176 -0
- data/lib/onyxcord/rest/routes/channel/webhooks.rb +47 -0
- data/lib/onyxcord/rest/routes/channel.rb +12 -0
- data/lib/onyxcord/{api/interaction.rb → rest/routes/interaction/base.rb} +7 -25
- data/lib/onyxcord/rest/routes/interaction/response.rb +24 -0
- data/lib/onyxcord/rest/routes/interaction.rb +4 -0
- data/lib/onyxcord/{api → rest/routes}/invite.rb +7 -7
- data/lib/onyxcord/rest/routes/server/admin.rb +174 -0
- data/lib/onyxcord/rest/routes/server/assets.rb +25 -0
- data/lib/onyxcord/rest/routes/server/bans.rb +67 -0
- data/lib/onyxcord/rest/routes/server/base.rb +77 -0
- data/lib/onyxcord/rest/routes/server/channels.rb +58 -0
- data/lib/onyxcord/rest/routes/server/emoji.rb +48 -0
- data/lib/onyxcord/rest/routes/server/members.rb +109 -0
- data/lib/onyxcord/rest/routes/server/messages.rb +19 -0
- data/lib/onyxcord/rest/routes/server/roles.rb +156 -0
- data/lib/onyxcord/rest/routes/server/scheduled_events.rb +86 -0
- data/lib/onyxcord/rest/routes/server.rb +12 -0
- data/lib/onyxcord/{api → rest/routes}/user.rb +23 -23
- data/lib/onyxcord/{api → rest/routes}/webhook.rb +22 -22
- data/lib/onyxcord/{allowed_mentions.rb → utils/allowed_mentions.rb} +1 -1
- data/lib/onyxcord/utils/timestamp.rb +69 -0
- data/lib/onyxcord/voice/{voice_bot.rb → client.rb} +4 -4
- data/lib/onyxcord/voice/encoder.rb +1 -1
- data/lib/onyxcord/voice/network/udp.rb +135 -0
- data/lib/onyxcord/voice/network/websocket.rb +225 -0
- data/lib/onyxcord/voice/network.rb +5 -357
- data/lib/onyxcord/webhooks/builder.rb +1 -1
- data/lib/onyxcord/webhooks/client.rb +13 -13
- data/lib/onyxcord/webhooks/modal/group_builder.rb +55 -0
- data/lib/onyxcord/webhooks/modal/label_builder.rb +183 -0
- data/lib/onyxcord/webhooks/modal.rb +2 -239
- data/lib/onyxcord/webhooks/version.rb +3 -3
- data/lib/onyxcord/webhooks/view/container_builder.rb +80 -0
- data/lib/onyxcord/webhooks/view/file_builder.rb +24 -0
- data/lib/onyxcord/webhooks/view/media_gallery_builder.rb +50 -0
- data/lib/onyxcord/webhooks/view/row_builder.rb +120 -0
- data/lib/onyxcord/webhooks/view/section_builder.rb +61 -0
- data/lib/onyxcord/webhooks/view/select_menu_builder.rb +77 -0
- data/lib/onyxcord/webhooks/view/separator_builder.rb +22 -0
- data/lib/onyxcord/webhooks/view/text_display_builder.rb +20 -0
- data/lib/onyxcord/webhooks/view.rb +9 -425
- data/lib/onyxcord.rb +106 -42
- metadata +207 -92
- data/.github/CONTRIBUTING.md +0 -13
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -24
- data/.github/pull_request_template.md +0 -37
- data/.github/workflows/ci.yml +0 -78
- data/.github/workflows/codeql.yml +0 -65
- data/.github/workflows/deploy.yml +0 -54
- data/.github/workflows/release.yml +0 -51
- data/.gitignore +0 -17
- data/.markdownlint.json +0 -4
- data/.overcommit.yml +0 -7
- data/.rspec +0 -2
- data/.rubocop.yml +0 -129
- data/.yardopts +0 -1
- data/CHANGELOG.md +0 -257
- data/Gemfile +0 -6
- data/LICENSE.txt +0 -21
- data/README.md +0 -448
- data/Rakefile +0 -13
- data/lib/onyxcord/api/channel.rb +0 -703
- data/lib/onyxcord/api/server.rb +0 -775
- data/lib/onyxcord/async/runtime.rb +0 -30
- data/lib/onyxcord/commands/command_bot.rb +0 -505
- data/lib/onyxcord/data/interaction.rb +0 -1151
- data/lib/onyxcord/data.rb +0 -57
- data/lib/onyxcord/event_executor.rb +0 -153
- data/lib/onyxcord/gateway.rb +0 -505
- data/lib/onyxcord/http.rb +0 -186
- data/lib/onyxcord/json.rb +0 -49
- data/lib/onyxcord/rate_limiter/async_rest.rb +0 -150
- data/lib/onyxcord/rate_limiter/gateway.rb +0 -42
- data/lib/onyxcord/rate_limiter/rest.rb +0 -142
- data/lib/onyxcord/version.rb +0 -7
- data/lib/onyxcord/websocket.rb +0 -77
- data/onyxcord.gemspec +0 -63
- /data/lib/onyxcord/{configuration.rb → core/configuration.rb} +0 -0
- /data/lib/onyxcord/{errors.rb → core/errors.rb} +0 -0
- /data/lib/onyxcord/{upload.rb → internal/upload.rb} +0 -0
- /data/lib/onyxcord/{data → models}/attachment.rb +0 -0
- /data/lib/onyxcord/{data → models}/audit_logs.rb +0 -0
- /data/lib/onyxcord/{data → models}/call.rb +0 -0
- /data/lib/onyxcord/{data → models}/channel_tag.rb +0 -0
- /data/lib/onyxcord/{data → models}/component.rb +0 -0
- /data/lib/onyxcord/{data → models}/embed.rb +0 -0
- /data/lib/onyxcord/{data → models}/install_params.rb +0 -0
- /data/lib/onyxcord/{data → models}/integration.rb +0 -0
- /data/lib/onyxcord/{data → models}/message_activity.rb +0 -0
- /data/lib/onyxcord/{data → models}/overwrite.rb +0 -0
- /data/lib/onyxcord/{data → models}/reaction.rb +0 -0
- /data/lib/onyxcord/{data → models}/recipient.rb +0 -0
- /data/lib/onyxcord/{data → models}/role_connection_data.rb +0 -0
- /data/lib/onyxcord/{data → models}/role_subscription.rb +0 -0
- /data/lib/onyxcord/{data → models}/snapshot.rb +0 -0
- /data/lib/onyxcord/{data → models}/timestamp.rb +0 -0
- /data/lib/onyxcord/{data → models}/voice_region.rb +0 -0
- /data/lib/onyxcord/{data → models}/voice_state.rb +0 -0
- /data/lib/onyxcord/{colour_rgb.rb → utils/colour_rgb.rb} +0 -0
- /data/lib/onyxcord/{id_object.rb → utils/id_object.rb} +0 -0
- /data/lib/onyxcord/{message_components.rb → utils/message_components.rb} +0 -0
- /data/lib/onyxcord/{paginator.rb → utils/paginator.rb} +0 -0
- /data/lib/onyxcord/{permissions.rb → utils/permissions.rb} +0 -0
data/README.md
DELETED
|
@@ -1,448 +0,0 @@
|
|
|
1
|
-
# OnyxCord
|
|
2
|
-
|
|
3
|
-
[](https://rubygems.org/gems/onyxcord)
|
|
4
|
-
[](https://rubygems.org/gems/onyxcord)
|
|
5
|
-
|
|
6
|
-
OnyxCord is a Ruby library for Discord bots, interactions, webhooks, modern modals, and Components V2.
|
|
7
|
-
|
|
8
|
-
Community Discord: https://discord.gg/Jy2tpCUtzM
|
|
9
|
-
|
|
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.
|
|
15
|
-
|
|
16
|
-
```txt
|
|
17
|
-
Simple to start, deep enough to control.
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
### Highlights
|
|
21
|
-
|
|
22
|
-
- Friendly Ruby API for Discord bots.
|
|
23
|
-
- Traditional object events for productivity.
|
|
24
|
-
- Raw gateway events for performance and lower allocation.
|
|
25
|
-
- **Modern async runtime** built on `async` gem with non-blocking gateway, REST and event dispatch.
|
|
26
|
-
- **New modern slash command DSL** with `bot.slash`, `execute`, and `bot.sync_application_commands!`.
|
|
27
|
-
- Components V2 support with `Text Display`, `Container`, `Section`, `Media Gallery`, `File`, `Separator`, and `Thumbnail`.
|
|
28
|
-
- Modern modal components, including `Label`, `Text Display`, modal selects, file upload, radio group, checkbox group, and checkbox.
|
|
29
|
-
- Webhooks with embeds, files, and components.
|
|
30
|
-
- Runtime helpers, rate limiting, and event execution designed for modern OnyxCord bots.
|
|
31
|
-
|
|
32
|
-
### Installation
|
|
33
|
-
|
|
34
|
-
With Bundler:
|
|
35
|
-
|
|
36
|
-
```ruby
|
|
37
|
-
gem 'onyxcord'
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Then:
|
|
41
|
-
|
|
42
|
-
```sh
|
|
43
|
-
bundle install
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Or install directly:
|
|
47
|
-
|
|
48
|
-
```sh
|
|
49
|
-
gem install onyxcord
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### First Bot
|
|
53
|
-
|
|
54
|
-
```ruby
|
|
55
|
-
require 'onyxcord'
|
|
56
|
-
|
|
57
|
-
bot = OnyxCord::Bot.new(
|
|
58
|
-
token: ENV.fetch('DISCORD_TOKEN'),
|
|
59
|
-
intents: %i[servers server_messages direct_messages message_content],
|
|
60
|
-
mode: :hybrid
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
bot.message(content: 'ping') do |event|
|
|
64
|
-
event.respond!(content: 'pong')
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
bot.application_command(:ping) do |event|
|
|
68
|
-
event.respond(content: 'Pong via Slash Command!')
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
bot.run
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### Components V2
|
|
75
|
-
|
|
76
|
-
OnyxCord automatically applies the `IS_COMPONENTS_V2` flag when you use V2 components. You can also enable it explicitly with `components_v2: true`.
|
|
77
|
-
|
|
78
|
-
```ruby
|
|
79
|
-
bot.message(content: '!panel') do |event|
|
|
80
|
-
event.send_message!(content: nil, components_v2: true) do |_builder, view|
|
|
81
|
-
view.text_display(content: '## OnyxCord Panel')
|
|
82
|
-
view.text_display(content: 'Choose an action below.')
|
|
83
|
-
|
|
84
|
-
view.row do |row|
|
|
85
|
-
row.button(style: :primary, label: 'Open', custom_id: 'open_panel')
|
|
86
|
-
row.button(style: :secondary, label: 'Help', custom_id: 'help_panel')
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Modern Modals
|
|
93
|
-
|
|
94
|
-
```ruby
|
|
95
|
-
bot.application_command(:feedback) do |event|
|
|
96
|
-
event.show_modal(title: 'Feedback', custom_id: 'feedback_modal') do |modal|
|
|
97
|
-
modal.label(label: 'Message') do |label|
|
|
98
|
-
label.text_input(
|
|
99
|
-
style: :paragraph,
|
|
100
|
-
custom_id: 'message',
|
|
101
|
-
required: true,
|
|
102
|
-
placeholder: 'Tell us what you think...'
|
|
103
|
-
)
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
modal.label(label: 'Category') do |label|
|
|
107
|
-
label.string_select(custom_id: 'category', required: true) do |menu|
|
|
108
|
-
menu.option(label: 'Bug', value: 'bug')
|
|
109
|
-
menu.option(label: 'Idea', value: 'idea')
|
|
110
|
-
menu.option(label: 'Other', value: 'other')
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### Modern Command DSL
|
|
118
|
-
|
|
119
|
-
```ruby
|
|
120
|
-
bot.slash :ban, description: 'Ban a member', default_member_permissions: [:ban_members] do
|
|
121
|
-
user :member, 'Member to ban', required: true
|
|
122
|
-
string :reason, 'Ban reason', max_length: 512
|
|
123
|
-
|
|
124
|
-
execute do |ctx|
|
|
125
|
-
ctx.defer(ephemeral: true)
|
|
126
|
-
member = ctx.options[:member]
|
|
127
|
-
reason = ctx.options[:reason] || 'No reason provided'
|
|
128
|
-
ctx.guild.ban(member, reason: reason)
|
|
129
|
-
ctx.edit_original(content: 'Member banned.')
|
|
130
|
-
end
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
bot.sync_application_commands!(server_id: ENV.fetch('DISCORD_SERVER_ID'))
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### Community
|
|
137
|
-
|
|
138
|
-
Join the Discord server for support, updates, examples, and feedback: https://discord.gg/Jy2tpCUtzM
|
|
139
|
-
|
|
140
|
-
## Portugues
|
|
141
|
-
|
|
142
|
-
OnyxCord e uma biblioteca Ruby para criar bots, integracoes, webhooks e experiencias interativas no Discord.
|
|
143
|
-
|
|
144
|
-
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.
|
|
145
|
-
|
|
146
|
-
```txt
|
|
147
|
-
Simples para comecar, profundo para controlar.
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
### Destaques
|
|
151
|
-
|
|
152
|
-
- API Ruby amigavel para bots do Discord.
|
|
153
|
-
- Eventos tradicionais com objetos para quem quer produtividade.
|
|
154
|
-
- Eventos raw para quem quer performance e menos alocacao.
|
|
155
|
-
- **Runtime async moderno** baseado na gem `async`: gateway, REST e dispatch de eventos nao-bloqueantes.
|
|
156
|
-
- **Nova DSL moderna de slash commands** com `bot.slash`, `execute` e `bot.sync_application_commands!`.
|
|
157
|
-
- Components V2 com `Text Display`, `Container`, `Section`, `Media Gallery`, `File`, `Separator` e `Thumbnail`.
|
|
158
|
-
- Novos componentes de modal, incluindo `Label`, `Text Display`, selects em modal, upload, radio group, checkbox group e checkbox.
|
|
159
|
-
- Webhooks com embeds, arquivos e componentes.
|
|
160
|
-
- Rate limiter e executor de eventos preparados para o core moderno do OnyxCord.
|
|
161
|
-
|
|
162
|
-
### Instalacao
|
|
163
|
-
|
|
164
|
-
Com Bundler:
|
|
165
|
-
|
|
166
|
-
```ruby
|
|
167
|
-
gem 'onyxcord'
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
Depois:
|
|
171
|
-
|
|
172
|
-
```sh
|
|
173
|
-
bundle install
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
Ou direto pelo RubyGems:
|
|
177
|
-
|
|
178
|
-
```sh
|
|
179
|
-
gem install onyxcord
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
### Primeiro Bot
|
|
183
|
-
|
|
184
|
-
```ruby
|
|
185
|
-
require 'onyxcord'
|
|
186
|
-
|
|
187
|
-
bot = OnyxCord::Bot.new(
|
|
188
|
-
token: ENV.fetch('DISCORD_TOKEN'),
|
|
189
|
-
intents: %i[servers server_messages direct_messages message_content],
|
|
190
|
-
mode: :hybrid
|
|
191
|
-
)
|
|
192
|
-
|
|
193
|
-
bot.message(content: 'ping') do |event|
|
|
194
|
-
event.respond!(content: 'pong')
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
bot.application_command(:ping) do |event|
|
|
198
|
-
event.respond(content: 'Pong via Slash Command!')
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
bot.run
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
### Components V2
|
|
205
|
-
|
|
206
|
-
O OnyxCord aplica automaticamente a flag `IS_COMPONENTS_V2` quando voce usa componentes V2. Voce tambem pode deixar explicito com `components_v2: true`.
|
|
207
|
-
|
|
208
|
-
```ruby
|
|
209
|
-
bot.message(content: '!painel') do |event|
|
|
210
|
-
event.send_message!(content: nil, components_v2: true) do |_builder, view|
|
|
211
|
-
view.text_display(content: '## Painel OnyxCord')
|
|
212
|
-
view.text_display(content: 'Escolha uma acao abaixo.')
|
|
213
|
-
|
|
214
|
-
view.row do |row|
|
|
215
|
-
row.button(style: :primary, label: 'Abrir', custom_id: 'open_panel')
|
|
216
|
-
row.button(style: :secondary, label: 'Ajuda', custom_id: 'help_panel')
|
|
217
|
-
end
|
|
218
|
-
end
|
|
219
|
-
end
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
### Modais Modernos
|
|
223
|
-
|
|
224
|
-
```ruby
|
|
225
|
-
bot.application_command(:feedback) do |event|
|
|
226
|
-
event.show_modal(title: 'Feedback', custom_id: 'feedback_modal') do |modal|
|
|
227
|
-
modal.label(label: 'Mensagem') do |label|
|
|
228
|
-
label.text_input(
|
|
229
|
-
style: :paragraph,
|
|
230
|
-
custom_id: 'message',
|
|
231
|
-
required: true,
|
|
232
|
-
placeholder: 'Conte o que voce achou...'
|
|
233
|
-
)
|
|
234
|
-
end
|
|
235
|
-
|
|
236
|
-
modal.label(label: 'Categoria') do |label|
|
|
237
|
-
label.string_select(custom_id: 'category', required: true) do |menu|
|
|
238
|
-
menu.option(label: 'Bug', value: 'bug')
|
|
239
|
-
menu.option(label: 'Ideia', value: 'idea')
|
|
240
|
-
menu.option(label: 'Outro', value: 'other')
|
|
241
|
-
end
|
|
242
|
-
end
|
|
243
|
-
end
|
|
244
|
-
end
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
### DSL Moderna de Comandos
|
|
248
|
-
|
|
249
|
-
```ruby
|
|
250
|
-
bot.slash :ban, description: 'Bane um membro', default_member_permissions: [:ban_members] do
|
|
251
|
-
user :member, 'Membro que sera banido', required: true
|
|
252
|
-
string :reason, 'Motivo do banimento', max_length: 512
|
|
253
|
-
|
|
254
|
-
execute do |ctx|
|
|
255
|
-
ctx.defer(ephemeral: true)
|
|
256
|
-
member = ctx.options[:member]
|
|
257
|
-
reason = ctx.options[:reason] || 'Sem motivo informado'
|
|
258
|
-
ctx.guild.ban(member, reason: reason)
|
|
259
|
-
ctx.edit_original(content: 'Membro banido com sucesso.')
|
|
260
|
-
end
|
|
261
|
-
end
|
|
262
|
-
|
|
263
|
-
bot.sync_application_commands!(server_id: ENV.fetch('DISCORD_SERVER_ID'))
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
### Comunidade
|
|
267
|
-
|
|
268
|
-
Entre no servidor do Discord para suporte, atualizacoes, exemplos e feedback: https://discord.gg/Jy2tpCUtzM
|
|
269
|
-
|
|
270
|
-
## Espanol
|
|
271
|
-
|
|
272
|
-
OnyxCord es una biblioteca Ruby para crear bots, integraciones, webhooks y experiencias interactivas en Discord.
|
|
273
|
-
|
|
274
|
-
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.
|
|
275
|
-
|
|
276
|
-
```txt
|
|
277
|
-
Simple para empezar, profundo para controlar.
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
### Caracteristicas
|
|
281
|
-
|
|
282
|
-
- API Ruby amigavel para bots de Discord.
|
|
283
|
-
- Eventos tradicionales con objetos para productividad.
|
|
284
|
-
- Eventos raw para rendimiento y menos asignaciones.
|
|
285
|
-
- **Runtime async moderno** basado en la gem `async`: gateway, REST y dispatch de eventos no bloqueantes.
|
|
286
|
-
- **Nueva DSL moderna de slash commands** con `bot.slash`, `execute` y `bot.sync_application_commands!`.
|
|
287
|
-
- Components V2 con `Text Display`, `Container`, `Section`, `Media Gallery`, `File`, `Separator` y `Thumbnail`.
|
|
288
|
-
- Componentes modernos de modal, incluyendo `Label`, `Text Display`, selects en modal, subida de archivos, radio group, checkbox group y checkbox.
|
|
289
|
-
- Webhooks con embeds, archivos y componentes.
|
|
290
|
-
- Rate limiter y executor de eventos preparados para el core moderno de OnyxCord.
|
|
291
|
-
|
|
292
|
-
### Instalacion
|
|
293
|
-
|
|
294
|
-
Con Bundler:
|
|
295
|
-
|
|
296
|
-
```ruby
|
|
297
|
-
gem 'onyxcord'
|
|
298
|
-
```
|
|
299
|
-
|
|
300
|
-
Despues:
|
|
301
|
-
|
|
302
|
-
```sh
|
|
303
|
-
bundle install
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
O directamente con RubyGems:
|
|
307
|
-
|
|
308
|
-
```sh
|
|
309
|
-
gem install onyxcord
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
### Primer Bot
|
|
313
|
-
|
|
314
|
-
```ruby
|
|
315
|
-
require 'onyxcord'
|
|
316
|
-
|
|
317
|
-
bot = OnyxCord::Bot.new(
|
|
318
|
-
token: ENV.fetch('DISCORD_TOKEN'),
|
|
319
|
-
intents: %i[servers server_messages direct_messages message_content],
|
|
320
|
-
mode: :hybrid
|
|
321
|
-
)
|
|
322
|
-
|
|
323
|
-
bot.message(content: 'ping') do |event|
|
|
324
|
-
event.respond!(content: 'pong')
|
|
325
|
-
end
|
|
326
|
-
|
|
327
|
-
bot.application_command(:ping) do |event|
|
|
328
|
-
event.respond(content: 'Pong via Slash Command!')
|
|
329
|
-
end
|
|
330
|
-
|
|
331
|
-
bot.run
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
### Components V2
|
|
335
|
-
|
|
336
|
-
OnyxCord aplica automaticamente la flag `IS_COMPONENTS_V2` cuando usas componentes V2. Tambien puedes activarla de forma explicita con `components_v2: true`.
|
|
337
|
-
|
|
338
|
-
```ruby
|
|
339
|
-
bot.message(content: '!panel') do |event|
|
|
340
|
-
event.send_message!(content: nil, components_v2: true) do |_builder, view|
|
|
341
|
-
view.text_display(content: '## Panel OnyxCord')
|
|
342
|
-
view.text_display(content: 'Elige una accion abajo.')
|
|
343
|
-
|
|
344
|
-
view.row do |row|
|
|
345
|
-
row.button(style: :primary, label: 'Abrir', custom_id: 'open_panel')
|
|
346
|
-
row.button(style: :secondary, label: 'Ayuda', custom_id: 'help_panel')
|
|
347
|
-
end
|
|
348
|
-
end
|
|
349
|
-
end
|
|
350
|
-
```
|
|
351
|
-
|
|
352
|
-
### Modales Modernos
|
|
353
|
-
|
|
354
|
-
```ruby
|
|
355
|
-
bot.application_command(:feedback) do |event|
|
|
356
|
-
event.show_modal(title: 'Feedback', custom_id: 'feedback_modal') do |modal|
|
|
357
|
-
modal.label(label: 'Mensaje') do |label|
|
|
358
|
-
label.text_input(
|
|
359
|
-
style: :paragraph,
|
|
360
|
-
custom_id: 'message',
|
|
361
|
-
required: true,
|
|
362
|
-
placeholder: 'Cuentanos que piensas...'
|
|
363
|
-
)
|
|
364
|
-
end
|
|
365
|
-
|
|
366
|
-
modal.label(label: 'Categoria') do |label|
|
|
367
|
-
label.string_select(custom_id: 'category', required: true) do |menu|
|
|
368
|
-
menu.option(label: 'Bug', value: 'bug')
|
|
369
|
-
menu.option(label: 'Idea', value: 'idea')
|
|
370
|
-
menu.option(label: 'Otro', value: 'other')
|
|
371
|
-
end
|
|
372
|
-
end
|
|
373
|
-
end
|
|
374
|
-
end
|
|
375
|
-
```
|
|
376
|
-
|
|
377
|
-
### DSL Moderna de Comandos
|
|
378
|
-
|
|
379
|
-
```ruby
|
|
380
|
-
bot.slash :ban, description: 'Banear a un miembro', default_member_permissions: [:ban_members] do
|
|
381
|
-
user :member, 'Miembro a banear', required: true
|
|
382
|
-
string :reason, 'Motivo del baneo', max_length: 512
|
|
383
|
-
|
|
384
|
-
execute do |ctx|
|
|
385
|
-
ctx.defer(ephemeral: true)
|
|
386
|
-
member = ctx.options[:member]
|
|
387
|
-
reason = ctx.options[:reason] || 'Sin motivo'
|
|
388
|
-
ctx.guild.ban(member, reason: reason)
|
|
389
|
-
ctx.edit_original(content: 'Miembro baneado.')
|
|
390
|
-
end
|
|
391
|
-
end
|
|
392
|
-
|
|
393
|
-
bot.sync_application_commands!(server_id: ENV.fetch('DISCORD_SERVER_ID'))
|
|
394
|
-
```
|
|
395
|
-
|
|
396
|
-
### Comunidad
|
|
397
|
-
|
|
398
|
-
Unete al servidor de Discord para soporte, actualizaciones, ejemplos y feedback: https://discord.gg/Jy2tpCUtzM
|
|
399
|
-
|
|
400
|
-
## Dependencies
|
|
401
|
-
|
|
402
|
-
For normal bots:
|
|
403
|
-
|
|
404
|
-
- Ruby 3.3 or newer.
|
|
405
|
-
- Bundler is recommended.
|
|
406
|
-
- Build tools for native extensions, especially on Windows.
|
|
407
|
-
|
|
408
|
-
For voice features:
|
|
409
|
-
|
|
410
|
-
- `libsodium`
|
|
411
|
-
- `libopus`
|
|
412
|
-
- `FFmpeg`
|
|
413
|
-
|
|
414
|
-
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`.
|
|
415
|
-
|
|
416
|
-
## Examples
|
|
417
|
-
|
|
418
|
-
The `examples/` directory contains ready-to-use examples:
|
|
419
|
-
|
|
420
|
-
- `ping.rb`: simple ping/pong bot.
|
|
421
|
-
- `commands.rb`: classic commands.
|
|
422
|
-
- `slash_commands.rb`: slash commands.
|
|
423
|
-
- `components.rb`: Components V2.
|
|
424
|
-
- `modals.rb`: modern modals.
|
|
425
|
-
- `select_menus.rb`: select menus.
|
|
426
|
-
- `webhooks.rb`: webhooks.
|
|
427
|
-
- `voice_send.rb`: voice sending.
|
|
428
|
-
|
|
429
|
-
## Development
|
|
430
|
-
|
|
431
|
-
```sh
|
|
432
|
-
bundle install
|
|
433
|
-
bundle exec rspec spec
|
|
434
|
-
```
|
|
435
|
-
|
|
436
|
-
If `libsodium` is not installed, voice tests may fail. To test the rest:
|
|
437
|
-
|
|
438
|
-
```sh
|
|
439
|
-
bundle exec rspec $(find spec -name '*_spec.rb' ! -name 'sodium_spec.rb' | sort)
|
|
440
|
-
```
|
|
441
|
-
|
|
442
|
-
## Credits
|
|
443
|
-
|
|
444
|
-
OnyxCord was created from the foundation of `discordrb`, an important Ruby library for the Discord bot community.
|
|
445
|
-
|
|
446
|
-
## License
|
|
447
|
-
|
|
448
|
-
Open source under the MIT license.
|
data/Rakefile
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'bundler/gem_helper'
|
|
4
|
-
|
|
5
|
-
namespace :main do
|
|
6
|
-
Bundler::GemHelper.install_tasks(name: 'onyxcord')
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
task build: :'main:build'
|
|
10
|
-
task release: :'main:release'
|
|
11
|
-
|
|
12
|
-
# Make "build" the default task
|
|
13
|
-
task default: :build
|