onyxcord 2.0.13 → 3.2.0
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/{errors.rb → core/errors.rb} +18 -3
- 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/internal/message_payload.rb +78 -0
- 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/upload.rb +39 -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 +22 -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 +13 -11
- data/lib/onyxcord/models.rb +57 -0
- data/lib/onyxcord/{api.rb → rest/client.rb} +83 -27
- 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} +10 -33
- 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 +30 -32
- data/lib/onyxcord/{allowed_mentions.rb → utils/allowed_mentions.rb} +9 -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 -40
- metadata +208 -91
- 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 -202
- 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 -705
- 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 -1143
- data/lib/onyxcord/data.rb +0 -57
- data/lib/onyxcord/event_executor.rb +0 -153
- data/lib/onyxcord/gateway.rb +0 -500
- data/lib/onyxcord/http.rb +0 -115
- data/lib/onyxcord/json.rb +0 -49
- data/lib/onyxcord/rate_limiter/async_rest.rb +0 -149
- 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/{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
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'onyxcord/utils/allowed_mentions'
|
|
4
|
+
require 'onyxcord/utils/permissions'
|
|
5
|
+
require 'onyxcord/utils/id_object'
|
|
6
|
+
require 'onyxcord/utils/colour_rgb'
|
|
7
|
+
require 'onyxcord/core/errors'
|
|
8
|
+
require 'onyxcord/rest/client'
|
|
9
|
+
require 'onyxcord/rest/routes/channel'
|
|
10
|
+
require 'onyxcord/rest/routes/server'
|
|
11
|
+
require 'onyxcord/rest/routes/invite'
|
|
12
|
+
require 'onyxcord/rest/routes/user'
|
|
13
|
+
require 'onyxcord/rest/routes/webhook'
|
|
14
|
+
require 'onyxcord/webhooks/embeds'
|
|
15
|
+
require 'onyxcord/webhooks/view'
|
|
16
|
+
require 'onyxcord/utils/paginator'
|
|
17
|
+
require 'time'
|
|
18
|
+
require 'base64'
|
|
19
|
+
|
|
20
|
+
require 'onyxcord/models/activity'
|
|
21
|
+
require 'onyxcord/models/application'
|
|
22
|
+
require 'onyxcord/models/user'
|
|
23
|
+
require 'onyxcord/models/voice_state'
|
|
24
|
+
require 'onyxcord/models/voice_region'
|
|
25
|
+
require 'onyxcord/models/member'
|
|
26
|
+
require 'onyxcord/models/recipient'
|
|
27
|
+
require 'onyxcord/models/profile'
|
|
28
|
+
require 'onyxcord/models/role'
|
|
29
|
+
require 'onyxcord/models/invite'
|
|
30
|
+
require 'onyxcord/models/overwrite'
|
|
31
|
+
require 'onyxcord/models/channel'
|
|
32
|
+
require 'onyxcord/models/embed'
|
|
33
|
+
require 'onyxcord/models/attachment'
|
|
34
|
+
require 'onyxcord/models/message'
|
|
35
|
+
require 'onyxcord/models/reaction'
|
|
36
|
+
require 'onyxcord/models/emoji'
|
|
37
|
+
require 'onyxcord/models/integration'
|
|
38
|
+
require 'onyxcord/models/server'
|
|
39
|
+
require 'onyxcord/models/webhook'
|
|
40
|
+
require 'onyxcord/models/audit_logs'
|
|
41
|
+
require 'onyxcord/models/interaction'
|
|
42
|
+
require 'onyxcord/models/component'
|
|
43
|
+
require 'onyxcord/models/avatar_decoration'
|
|
44
|
+
require 'onyxcord/models/collectibles'
|
|
45
|
+
require 'onyxcord/models/primary_server'
|
|
46
|
+
require 'onyxcord/models/server_preview'
|
|
47
|
+
require 'onyxcord/models/call'
|
|
48
|
+
require 'onyxcord/models/snapshot'
|
|
49
|
+
require 'onyxcord/models/role_subscription'
|
|
50
|
+
require 'onyxcord/models/message_activity'
|
|
51
|
+
require 'onyxcord/models/team'
|
|
52
|
+
require 'onyxcord/models/install_params'
|
|
53
|
+
require 'onyxcord/models/role_connection_data'
|
|
54
|
+
require 'onyxcord/models/channel_tag'
|
|
55
|
+
require 'onyxcord/models/timestamp'
|
|
56
|
+
require 'onyxcord/models/scheduled_event'
|
|
57
|
+
require 'onyxcord/models/poll'
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'onyxcord/http'
|
|
4
|
-
require 'onyxcord/json'
|
|
5
|
-
require 'onyxcord/
|
|
3
|
+
require 'onyxcord/internal/http'
|
|
4
|
+
require 'onyxcord/internal/json'
|
|
5
|
+
require 'onyxcord/internal/async_runtime'
|
|
6
6
|
require 'time'
|
|
7
7
|
|
|
8
|
-
require 'onyxcord/errors'
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
require 'onyxcord/core/errors'
|
|
9
|
+
require_relative '../internal/rate_limiter/rest'
|
|
10
|
+
require_relative '../internal/rate_limiter/async_rest'
|
|
11
11
|
|
|
12
12
|
# List of methods representing endpoints in Discord's API
|
|
13
|
-
module OnyxCord::
|
|
13
|
+
module OnyxCord::REST
|
|
14
14
|
# The base URL of the Discord REST API.
|
|
15
15
|
APIBASE = 'https://discord.com/api/v9'
|
|
16
16
|
|
|
@@ -62,16 +62,16 @@ module OnyxCord::API
|
|
|
62
62
|
|
|
63
63
|
# Resets all rate limit mutexes
|
|
64
64
|
def reset_mutexes
|
|
65
|
-
@rate_limiter = OnyxCord::RateLimiter::Rest.new
|
|
66
|
-
@async_rate_limiter = OnyxCord::RateLimiter::AsyncRest.new
|
|
65
|
+
@rate_limiter = ::OnyxCord::Internal::RateLimiter::Rest.new
|
|
66
|
+
@async_rate_limiter = ::OnyxCord::Internal::RateLimiter::AsyncRest.new
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
def rate_limiter
|
|
70
|
-
@rate_limiter ||= OnyxCord::RateLimiter::Rest.new
|
|
70
|
+
@rate_limiter ||= ::OnyxCord::Internal::RateLimiter::Rest.new
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
def async_rate_limiter
|
|
74
|
-
@async_rate_limiter ||= OnyxCord::RateLimiter::AsyncRest.new
|
|
74
|
+
@async_rate_limiter ||= ::OnyxCord::Internal::RateLimiter::AsyncRest.new
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
def rate_limiter_stats
|
|
@@ -98,16 +98,24 @@ module OnyxCord::API
|
|
|
98
98
|
# @param url [String] The URL to request.
|
|
99
99
|
# @param body [String, Hash, nil] The request body.
|
|
100
100
|
# @param headers [Hash] Additional headers.
|
|
101
|
-
# @return [OnyxCord::HTTP::Response]
|
|
101
|
+
# @return [OnyxCord::Internal::HTTP::Response]
|
|
102
102
|
def raw_request(type, url, body = nil, **headers)
|
|
103
103
|
headers[:user_agent] = user_agent
|
|
104
104
|
|
|
105
|
-
response = OnyxCord::HTTP.request(type, url, body, **headers)
|
|
105
|
+
response = ::OnyxCord::Internal::HTTP.request(type, url, body, **headers)
|
|
106
106
|
|
|
107
107
|
if response.code == 403
|
|
108
|
-
|
|
108
|
+
route = request_diagnostic(type, url, body, headers)
|
|
109
|
+
noprm = OnyxCord::Errors::NoPermission.new(
|
|
110
|
+
"The bot doesn't have the required permission to do this!",
|
|
111
|
+
status: response.code,
|
|
112
|
+
headers: response.headers,
|
|
113
|
+
route: route,
|
|
114
|
+
body: response.body,
|
|
115
|
+
response: response
|
|
116
|
+
)
|
|
109
117
|
noprm.define_singleton_method(:_response) { response }
|
|
110
|
-
raise noprm
|
|
118
|
+
raise noprm
|
|
111
119
|
end
|
|
112
120
|
|
|
113
121
|
# Retry on 502 Bad Gateway
|
|
@@ -124,7 +132,7 @@ module OnyxCord::API
|
|
|
124
132
|
if Async::Task.current?
|
|
125
133
|
request_async(key, major_parameter, type, *attributes)
|
|
126
134
|
else
|
|
127
|
-
OnyxCord::AsyncRuntime.run { request_async(key, major_parameter, type, *attributes) }
|
|
135
|
+
OnyxCord::Internal::AsyncRuntime.run { request_async(key, major_parameter, type, *attributes) }
|
|
128
136
|
end
|
|
129
137
|
end
|
|
130
138
|
|
|
@@ -151,26 +159,45 @@ module OnyxCord::API
|
|
|
151
159
|
|
|
152
160
|
retries = 0
|
|
153
161
|
max_retries = key == :gateway ? 0 : 3
|
|
162
|
+
retryable_codes = [500, 502, 503, 504].freeze
|
|
154
163
|
|
|
155
164
|
begin
|
|
156
165
|
async_rate_limiter.before_request(key, major_parameter)
|
|
157
166
|
|
|
158
167
|
response = nil
|
|
159
168
|
loop do
|
|
160
|
-
|
|
161
|
-
|
|
169
|
+
begin
|
|
170
|
+
response = ::OnyxCord::Internal::HTTP.request(type, url, body, **headers)
|
|
171
|
+
rescue StandardError => e
|
|
172
|
+
retries += 1
|
|
173
|
+
raise unless retries < max_retries
|
|
174
|
+
|
|
175
|
+
OnyxCord::LOGGER.warn("Temporary HTTP failure while sending request (#{e.class}), retrying")
|
|
176
|
+
OnyxCord::Internal::AsyncRuntime.sleep(retries * 0.5)
|
|
177
|
+
next
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
break unless retryable_codes.include?(response.code)
|
|
162
181
|
|
|
163
182
|
retries += 1
|
|
164
183
|
break unless retries < max_retries
|
|
165
184
|
|
|
166
|
-
OnyxCord::LOGGER.warn(
|
|
167
|
-
OnyxCord::AsyncRuntime.sleep(retries * 0.5)
|
|
185
|
+
OnyxCord::LOGGER.warn("Got HTTP #{response.code} while sending a request, retrying")
|
|
186
|
+
OnyxCord::Internal::AsyncRuntime.sleep(retries * 0.5)
|
|
168
187
|
end
|
|
169
188
|
|
|
170
189
|
if response.code == 403
|
|
171
|
-
|
|
190
|
+
route = request_diagnostic(type, url, body, headers)
|
|
191
|
+
noprm = OnyxCord::Errors::NoPermission.new(
|
|
192
|
+
"The bot doesn't have the required permission to do this!",
|
|
193
|
+
status: response.code,
|
|
194
|
+
headers: response.headers,
|
|
195
|
+
route: route,
|
|
196
|
+
body: response.body,
|
|
197
|
+
response: response
|
|
198
|
+
)
|
|
172
199
|
noprm.define_singleton_method(:_response) { response }
|
|
173
|
-
raise noprm
|
|
200
|
+
raise noprm
|
|
174
201
|
end
|
|
175
202
|
|
|
176
203
|
if response.code >= 400 && response.code != 429
|
|
@@ -180,10 +207,20 @@ module OnyxCord::API
|
|
|
180
207
|
nil
|
|
181
208
|
end
|
|
182
209
|
|
|
183
|
-
|
|
210
|
+
route = request_diagnostic(type, url, body, headers)
|
|
211
|
+
unless data
|
|
212
|
+
raise OnyxCord::Errors::HTTPError.new(
|
|
213
|
+
"HTTP #{response.code} #{route}: #{response.body}",
|
|
214
|
+
status: response.code,
|
|
215
|
+
headers: response.headers,
|
|
216
|
+
route: route,
|
|
217
|
+
body: response.body,
|
|
218
|
+
response: response
|
|
219
|
+
)
|
|
220
|
+
end
|
|
184
221
|
|
|
185
222
|
err_klass = OnyxCord::Errors.error_class_for(data['code'] || 0)
|
|
186
|
-
e = err_klass.new(data['message'], data['errors'])
|
|
223
|
+
e = err_klass.new(data['message'], data['errors'], status: response.code, headers: response.headers, route: route, body: response.body, response: response)
|
|
187
224
|
OnyxCord::LOGGER.error(e.full_message)
|
|
188
225
|
raise e
|
|
189
226
|
end
|
|
@@ -206,9 +243,9 @@ module OnyxCord::API
|
|
|
206
243
|
if body_data['code'] == 110_000
|
|
207
244
|
case body_data['retry_after']
|
|
208
245
|
when 0, 1, nil
|
|
209
|
-
OnyxCord::AsyncRuntime.sleep(rand(4.5..5.0))
|
|
246
|
+
OnyxCord::Internal::AsyncRuntime.sleep(rand(4.5..5.0))
|
|
210
247
|
else
|
|
211
|
-
OnyxCord::AsyncRuntime.sleep(body_data['retry_after'])
|
|
248
|
+
OnyxCord::Internal::AsyncRuntime.sleep(body_data['retry_after'])
|
|
212
249
|
end
|
|
213
250
|
|
|
214
251
|
return request_async(key, major_parameter, type, url, body, headers)
|
|
@@ -243,6 +280,25 @@ module OnyxCord::API
|
|
|
243
280
|
end
|
|
244
281
|
end
|
|
245
282
|
|
|
283
|
+
def request_diagnostic(type, url, body, headers)
|
|
284
|
+
clean_url = url.to_s.sub(%r{/webhooks/(\d+)/[^?]+}, '/webhooks/\1/[token]')
|
|
285
|
+
.sub(%r{/interactions/(\d+)/[^/]+}, '/interactions/\1/[token]')
|
|
286
|
+
header_keys = headers.keys.map(&:to_s).sort.join(',')
|
|
287
|
+
body_info = if body.is_a?(Hash)
|
|
288
|
+
body.map do |key, value|
|
|
289
|
+
path = value.path if value.respond_to?(:path)
|
|
290
|
+
detail = path ? "file:#{File.basename(path)}" : value.to_s.bytesize
|
|
291
|
+
"#{key}=#{detail}"
|
|
292
|
+
end.join(',')
|
|
293
|
+
else
|
|
294
|
+
body.nil? ? 'nil' : "#{body.class}:#{body.to_s.bytesize}"
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
"(#{type.to_s.upcase} #{clean_url} headers=#{header_keys} body=#{body_info})"
|
|
298
|
+
rescue StandardError => e
|
|
299
|
+
"(diagnostic_failed=#{e.class}: #{e.message})"
|
|
300
|
+
end
|
|
301
|
+
|
|
246
302
|
# Make an icon URL from server and icon IDs
|
|
247
303
|
def icon_url(server_id, icon_id, format = 'webp')
|
|
248
304
|
"#{cdn_url}/icons/#{server_id}/#{icon_id}.#{format}"
|
|
@@ -392,4 +448,4 @@ module OnyxCord::API
|
|
|
392
448
|
end
|
|
393
449
|
end
|
|
394
450
|
|
|
395
|
-
OnyxCord::
|
|
451
|
+
OnyxCord::REST.reset_mutexes
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# API calls for slash commands.
|
|
4
|
-
module OnyxCord::
|
|
4
|
+
module OnyxCord::REST::Application
|
|
5
5
|
module_function
|
|
6
6
|
|
|
7
7
|
# Get a list of global application commands.
|
|
8
8
|
# https://discord.com/developers/docs/interactions/slash-commands#get-global-application-commands
|
|
9
9
|
def get_global_commands(token, application_id)
|
|
10
|
-
OnyxCord::
|
|
10
|
+
OnyxCord::REST.request(
|
|
11
11
|
:applications_aid_commands,
|
|
12
12
|
nil,
|
|
13
13
|
:get,
|
|
14
|
-
"#{OnyxCord::
|
|
14
|
+
"#{OnyxCord::REST.api_base}/applications/#{application_id}/commands",
|
|
15
15
|
Authorization: token
|
|
16
16
|
)
|
|
17
17
|
end
|
|
@@ -19,24 +19,26 @@ module OnyxCord::API::Application
|
|
|
19
19
|
# Get a global application command by ID.
|
|
20
20
|
# https://discord.com/developers/docs/interactions/slash-commands#get-global-application-command
|
|
21
21
|
def get_global_command(token, application_id, command_id)
|
|
22
|
-
OnyxCord::
|
|
22
|
+
OnyxCord::REST.request(
|
|
23
23
|
:applications_aid_commands_cid,
|
|
24
24
|
nil,
|
|
25
25
|
:get,
|
|
26
|
-
"#{OnyxCord::
|
|
26
|
+
"#{OnyxCord::REST.api_base}/applications/#{application_id}/commands/#{command_id}",
|
|
27
27
|
Authorization: token
|
|
28
28
|
)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
# Create a global application command.
|
|
32
32
|
# https://discord.com/developers/docs/interactions/slash-commands#create-global-application-command
|
|
33
|
-
def create_global_command(token, application_id, name, description, options = [], default_permission = nil, type = 1, default_member_permissions = nil, contexts = nil, nsfw = false, integration_types = nil)
|
|
34
|
-
OnyxCord::
|
|
33
|
+
def create_global_command(token, application_id, name, description, options = [], default_permission = nil, type = 1, default_member_permissions = nil, contexts = nil, nsfw = false, integration_types = nil, name_localizations: nil, description_localizations: nil)
|
|
34
|
+
OnyxCord::REST.request(
|
|
35
35
|
:applications_aid_commands,
|
|
36
36
|
nil,
|
|
37
37
|
:post,
|
|
38
|
-
"#{OnyxCord::
|
|
39
|
-
{ name: name, description: description, options: options, default_permission: default_permission, type: type,
|
|
38
|
+
"#{OnyxCord::REST.api_base}/applications/#{application_id}/commands",
|
|
39
|
+
{ name: name, description: description, options: options, default_permission: default_permission, type: type,
|
|
40
|
+
default_member_permissions: default_member_permissions, contexts: contexts, nsfw: nsfw, integration_types: integration_types,
|
|
41
|
+
name_localizations: name_localizations, description_localizations: description_localizations }.compact.to_json,
|
|
40
42
|
Authorization: token,
|
|
41
43
|
content_type: :json
|
|
42
44
|
)
|
|
@@ -44,13 +46,15 @@ module OnyxCord::API::Application
|
|
|
44
46
|
|
|
45
47
|
# Edit a global application command.
|
|
46
48
|
# https://discord.com/developers/docs/interactions/slash-commands#edit-global-application-command
|
|
47
|
-
def edit_global_command(token, application_id, command_id, name = nil, description = nil, options = nil, default_permission = nil, type = 1, default_member_permissions = nil, contexts = nil, nsfw = nil, integration_types = nil)
|
|
48
|
-
OnyxCord::
|
|
49
|
+
def edit_global_command(token, application_id, command_id, name = nil, description = nil, options = nil, default_permission = nil, type = 1, default_member_permissions = nil, contexts = nil, nsfw = nil, integration_types = nil, name_localizations: nil, description_localizations: nil)
|
|
50
|
+
OnyxCord::REST.request(
|
|
49
51
|
:applications_aid_commands_cid,
|
|
50
52
|
nil,
|
|
51
53
|
:patch,
|
|
52
|
-
"#{OnyxCord::
|
|
53
|
-
{ name: name, description: description, options: options, default_permission: default_permission, type: type,
|
|
54
|
+
"#{OnyxCord::REST.api_base}/applications/#{application_id}/commands/#{command_id}",
|
|
55
|
+
{ name: name, description: description, options: options, default_permission: default_permission, type: type,
|
|
56
|
+
default_member_permissions: default_member_permissions, contexts: contexts, nsfw: nsfw, integration_types: integration_types,
|
|
57
|
+
name_localizations: name_localizations, description_localizations: description_localizations }.compact.to_json,
|
|
54
58
|
Authorization: token,
|
|
55
59
|
content_type: :json
|
|
56
60
|
)
|
|
@@ -59,11 +63,11 @@ module OnyxCord::API::Application
|
|
|
59
63
|
# Delete a global application command.
|
|
60
64
|
# https://discord.com/developers/docs/interactions/slash-commands#delete-global-application-command
|
|
61
65
|
def delete_global_command(token, application_id, command_id)
|
|
62
|
-
OnyxCord::
|
|
66
|
+
OnyxCord::REST.request(
|
|
63
67
|
:applications_aid_commands_cid,
|
|
64
68
|
nil,
|
|
65
69
|
:delete,
|
|
66
|
-
"#{OnyxCord::
|
|
70
|
+
"#{OnyxCord::REST.api_base}/applications/#{application_id}/commands/#{command_id}",
|
|
67
71
|
Authorization: token
|
|
68
72
|
)
|
|
69
73
|
end
|
|
@@ -71,11 +75,11 @@ module OnyxCord::API::Application
|
|
|
71
75
|
# Set global application commands in bulk.
|
|
72
76
|
# https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands
|
|
73
77
|
def bulk_overwrite_global_commands(token, application_id, commands)
|
|
74
|
-
OnyxCord::
|
|
78
|
+
OnyxCord::REST.request(
|
|
75
79
|
:applications_aid_commands,
|
|
76
80
|
nil,
|
|
77
81
|
:put,
|
|
78
|
-
"#{OnyxCord::
|
|
82
|
+
"#{OnyxCord::REST.api_base}/applications/#{application_id}/commands",
|
|
79
83
|
commands.to_json,
|
|
80
84
|
Authorization: token,
|
|
81
85
|
content_type: :json
|
|
@@ -85,11 +89,11 @@ module OnyxCord::API::Application
|
|
|
85
89
|
# Get a guild's commands for an application.
|
|
86
90
|
# https://discord.com/developers/docs/interactions/slash-commands#get-guild-application-commands
|
|
87
91
|
def get_guild_commands(token, application_id, guild_id)
|
|
88
|
-
OnyxCord::
|
|
92
|
+
OnyxCord::REST.request(
|
|
89
93
|
:applications_aid_guilds_gid_commands,
|
|
90
94
|
guild_id,
|
|
91
95
|
:get,
|
|
92
|
-
"#{OnyxCord::
|
|
96
|
+
"#{OnyxCord::REST.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands",
|
|
93
97
|
Authorization: token
|
|
94
98
|
)
|
|
95
99
|
end
|
|
@@ -97,24 +101,26 @@ module OnyxCord::API::Application
|
|
|
97
101
|
# Get a guild command by ID.
|
|
98
102
|
# https://discord.com/developers/docs/interactions/slash-commands#get-guild-application-command
|
|
99
103
|
def get_guild_command(token, application_id, guild_id, command_id)
|
|
100
|
-
OnyxCord::
|
|
104
|
+
OnyxCord::REST.request(
|
|
101
105
|
:applications_aid_guilds_gid_commands_cid,
|
|
102
106
|
guild_id,
|
|
103
107
|
:get,
|
|
104
|
-
"#{OnyxCord::
|
|
108
|
+
"#{OnyxCord::REST.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands/#{command_id}",
|
|
105
109
|
Authorization: token
|
|
106
110
|
)
|
|
107
111
|
end
|
|
108
112
|
|
|
109
113
|
# Create an application command for a guild.
|
|
110
114
|
# https://discord.com/developers/docs/interactions/slash-commands#create-guild-application-command
|
|
111
|
-
def create_guild_command(token, application_id, guild_id, name, description, options = nil, default_permission = nil, type = 1, default_member_permissions = nil, contexts = nil, nsfw = false)
|
|
112
|
-
OnyxCord::
|
|
115
|
+
def create_guild_command(token, application_id, guild_id, name, description, options = nil, default_permission = nil, type = 1, default_member_permissions = nil, contexts = nil, nsfw = false, integration_types = nil, name_localizations: nil, description_localizations: nil)
|
|
116
|
+
OnyxCord::REST.request(
|
|
113
117
|
:applications_aid_guilds_gid_commands,
|
|
114
118
|
guild_id,
|
|
115
119
|
:post,
|
|
116
|
-
"#{OnyxCord::
|
|
117
|
-
{ name: name, description: description, options: options, default_permission: default_permission, type: type,
|
|
120
|
+
"#{OnyxCord::REST.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands",
|
|
121
|
+
{ name: name, description: description, options: options, default_permission: default_permission, type: type,
|
|
122
|
+
default_member_permissions: default_member_permissions, contexts: contexts, nsfw: nsfw, integration_types: integration_types,
|
|
123
|
+
name_localizations: name_localizations, description_localizations: description_localizations }.compact.to_json,
|
|
118
124
|
Authorization: token,
|
|
119
125
|
content_type: :json
|
|
120
126
|
)
|
|
@@ -122,13 +128,15 @@ module OnyxCord::API::Application
|
|
|
122
128
|
|
|
123
129
|
# Edit an application command for a guild.
|
|
124
130
|
# https://discord.com/developers/docs/interactions/slash-commands#edit-guild-application-command
|
|
125
|
-
def edit_guild_command(token, application_id, guild_id, command_id, name = nil, description = nil, options = nil, default_permission = nil, type = 1, default_member_permissions = nil, contexts = nil, nsfw = nil)
|
|
126
|
-
OnyxCord::
|
|
131
|
+
def edit_guild_command(token, application_id, guild_id, command_id, name = nil, description = nil, options = nil, default_permission = nil, type = 1, default_member_permissions = nil, contexts = nil, nsfw = nil, integration_types = nil, name_localizations: nil, description_localizations: nil)
|
|
132
|
+
OnyxCord::REST.request(
|
|
127
133
|
:applications_aid_guilds_gid_commands_cid,
|
|
128
134
|
guild_id,
|
|
129
135
|
:patch,
|
|
130
|
-
"#{OnyxCord::
|
|
131
|
-
{ name: name, description: description, options: options, default_permission: default_permission, type: type,
|
|
136
|
+
"#{OnyxCord::REST.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands/#{command_id}",
|
|
137
|
+
{ name: name, description: description, options: options, default_permission: default_permission, type: type,
|
|
138
|
+
default_member_permissions: default_member_permissions, contexts: contexts, nsfw: nsfw, integration_types: integration_types,
|
|
139
|
+
name_localizations: name_localizations, description_localizations: description_localizations }.compact.to_json,
|
|
132
140
|
Authorization: token,
|
|
133
141
|
content_type: :json
|
|
134
142
|
)
|
|
@@ -137,11 +145,11 @@ module OnyxCord::API::Application
|
|
|
137
145
|
# Delete an application command for a guild.
|
|
138
146
|
# https://discord.com/developers/docs/interactions/slash-commands#delete-guild-application-command
|
|
139
147
|
def delete_guild_command(token, application_id, guild_id, command_id)
|
|
140
|
-
OnyxCord::
|
|
148
|
+
OnyxCord::REST.request(
|
|
141
149
|
:applications_aid_guilds_gid_commands_cid,
|
|
142
150
|
guild_id,
|
|
143
151
|
:delete,
|
|
144
|
-
"#{OnyxCord::
|
|
152
|
+
"#{OnyxCord::REST.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands/#{command_id}",
|
|
145
153
|
Authorization: token
|
|
146
154
|
)
|
|
147
155
|
end
|
|
@@ -149,11 +157,11 @@ module OnyxCord::API::Application
|
|
|
149
157
|
# Set guild commands in bulk.
|
|
150
158
|
# https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-guild-application-commands
|
|
151
159
|
def bulk_overwrite_guild_commands(token, application_id, guild_id, commands)
|
|
152
|
-
OnyxCord::
|
|
160
|
+
OnyxCord::REST.request(
|
|
153
161
|
:applications_aid_guilds_gid_commands,
|
|
154
162
|
guild_id,
|
|
155
163
|
:put,
|
|
156
|
-
"#{OnyxCord::
|
|
164
|
+
"#{OnyxCord::REST.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands",
|
|
157
165
|
commands.to_json,
|
|
158
166
|
Authorization: token,
|
|
159
167
|
content_type: :json
|
|
@@ -163,11 +171,11 @@ module OnyxCord::API::Application
|
|
|
163
171
|
# Get the permissions for a specific guild command.
|
|
164
172
|
# https://discord.com/developers/docs/interactions/slash-commands#get-application-command-permissions
|
|
165
173
|
def get_guild_command_permissions(token, application_id, guild_id)
|
|
166
|
-
OnyxCord::
|
|
174
|
+
OnyxCord::REST.request(
|
|
167
175
|
:applications_aid_guilds_gid_commands_permissions,
|
|
168
176
|
guild_id,
|
|
169
177
|
:get,
|
|
170
|
-
"#{OnyxCord::
|
|
178
|
+
"#{OnyxCord::REST.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands/permissions",
|
|
171
179
|
Authorization: token
|
|
172
180
|
)
|
|
173
181
|
end
|
|
@@ -175,11 +183,11 @@ module OnyxCord::API::Application
|
|
|
175
183
|
# Edit the permissions for a specific guild command.
|
|
176
184
|
# https://discord.com/developers/docs/interactions/slash-commands#edit-application-command-permissions
|
|
177
185
|
def edit_guild_command_permissions(token, application_id, guild_id, command_id, permissions)
|
|
178
|
-
OnyxCord::
|
|
186
|
+
OnyxCord::REST.request(
|
|
179
187
|
:applications_aid_guilds_gid_commands_cid_permissions,
|
|
180
188
|
guild_id,
|
|
181
189
|
:put,
|
|
182
|
-
"#{OnyxCord::
|
|
190
|
+
"#{OnyxCord::REST.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands/#{command_id}/permissions",
|
|
183
191
|
{ permissions: permissions }.to_json,
|
|
184
192
|
Authorization: token,
|
|
185
193
|
content_type: :json
|
|
@@ -189,11 +197,11 @@ module OnyxCord::API::Application
|
|
|
189
197
|
# Edit permissions for all commands in a guild.
|
|
190
198
|
# https://discord.com/developers/docs/interactions/slash-commands#batch-edit-application-command-permissions
|
|
191
199
|
def batch_edit_command_permissions(token, application_id, guild_id, permissions)
|
|
192
|
-
OnyxCord::
|
|
200
|
+
OnyxCord::REST.request(
|
|
193
201
|
:applications_aid_guilds_gid_commands_cid_permissions,
|
|
194
202
|
guild_id,
|
|
195
203
|
:put,
|
|
196
|
-
"#{OnyxCord::
|
|
204
|
+
"#{OnyxCord::REST.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands/permissions",
|
|
197
205
|
permissions.to_json,
|
|
198
206
|
Authorization: token,
|
|
199
207
|
content_type: :json
|
|
@@ -203,11 +211,11 @@ module OnyxCord::API::Application
|
|
|
203
211
|
# Get all of the permissions for the commands in a guild.
|
|
204
212
|
# https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command-permissions
|
|
205
213
|
def get_guild_application_command_permissions(token, application_id, guild_id)
|
|
206
|
-
OnyxCord::
|
|
214
|
+
OnyxCord::REST.request(
|
|
207
215
|
:applications_aid_guilds_gid_commands_permissions,
|
|
208
216
|
guild_id,
|
|
209
217
|
:get,
|
|
210
|
-
"#{OnyxCord::
|
|
218
|
+
"#{OnyxCord::REST.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands/permissions",
|
|
211
219
|
Authorization: token
|
|
212
220
|
)
|
|
213
221
|
end
|
|
@@ -215,11 +223,11 @@ module OnyxCord::API::Application
|
|
|
215
223
|
# Get the permissions for a specific command in a guild.
|
|
216
224
|
# https://discord.com/developers/docs/interactions/application-commands#get-application-command-permissions
|
|
217
225
|
def get_application_command_permissions(token, application_id, guild_id, command_id)
|
|
218
|
-
OnyxCord::
|
|
226
|
+
OnyxCord::REST.request(
|
|
219
227
|
:applications_aid_guilds_gid_commands_cid_permissions,
|
|
220
228
|
guild_id,
|
|
221
229
|
:get,
|
|
222
|
-
"#{OnyxCord::
|
|
230
|
+
"#{OnyxCord::REST.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands/#{command_id}/permissions",
|
|
223
231
|
Authorization: token
|
|
224
232
|
)
|
|
225
233
|
end
|
|
@@ -227,11 +235,11 @@ module OnyxCord::API::Application
|
|
|
227
235
|
# Get a list of application emojis.
|
|
228
236
|
# https://discord.com/developers/docs/resources/emoji#list-application-emojis
|
|
229
237
|
def list_application_emojis(token, application_id)
|
|
230
|
-
OnyxCord::
|
|
238
|
+
OnyxCord::REST.request(
|
|
231
239
|
:applications_aid_emojis,
|
|
232
240
|
application_id,
|
|
233
241
|
:get,
|
|
234
|
-
"#{OnyxCord::
|
|
242
|
+
"#{OnyxCord::REST.api_base}/applications/#{application_id}/emojis",
|
|
235
243
|
Authorization: token
|
|
236
244
|
)
|
|
237
245
|
end
|
|
@@ -239,11 +247,11 @@ module OnyxCord::API::Application
|
|
|
239
247
|
# Get an application emoji by ID.
|
|
240
248
|
# https://discord.com/developers/docs/resources/emoji#get-application-emoji
|
|
241
249
|
def get_application_emoji(token, application_id, emoji_id)
|
|
242
|
-
OnyxCord::
|
|
250
|
+
OnyxCord::REST.request(
|
|
243
251
|
:applications_aid_emojis_eid,
|
|
244
252
|
application_id,
|
|
245
253
|
:get,
|
|
246
|
-
"#{OnyxCord::
|
|
254
|
+
"#{OnyxCord::REST.api_base}/applications/#{application_id}/emojis/#{emoji_id}",
|
|
247
255
|
Authorization: token
|
|
248
256
|
)
|
|
249
257
|
end
|
|
@@ -251,11 +259,11 @@ module OnyxCord::API::Application
|
|
|
251
259
|
# Create an application emoji.
|
|
252
260
|
# https://discord.com/developers/docs/resources/emoji#create-application-emoji
|
|
253
261
|
def create_application_emoji(token, application_id, name, image)
|
|
254
|
-
OnyxCord::
|
|
262
|
+
OnyxCord::REST.request(
|
|
255
263
|
:applications_aid_emojis,
|
|
256
264
|
application_id,
|
|
257
265
|
:post,
|
|
258
|
-
"#{OnyxCord::
|
|
266
|
+
"#{OnyxCord::REST.api_base}/applications/#{application_id}/emojis",
|
|
259
267
|
{ name: name, image: image }.to_json,
|
|
260
268
|
Authorization: token,
|
|
261
269
|
content_type: :json
|
|
@@ -265,11 +273,11 @@ module OnyxCord::API::Application
|
|
|
265
273
|
# Edit an application emoji.
|
|
266
274
|
# https://discord.com/developers/docs/resources/emoji#modify-application-emoji
|
|
267
275
|
def edit_application_emoji(token, application_id, emoji_id, name)
|
|
268
|
-
OnyxCord::
|
|
276
|
+
OnyxCord::REST.request(
|
|
269
277
|
:applications_aid_emojis_eid,
|
|
270
278
|
application_id,
|
|
271
279
|
:patch,
|
|
272
|
-
"#{OnyxCord::
|
|
280
|
+
"#{OnyxCord::REST.api_base}/applications/#{application_id}/emojis/#{emoji_id}",
|
|
273
281
|
{ name: name }.to_json,
|
|
274
282
|
Authorization: token,
|
|
275
283
|
content_type: :json
|
|
@@ -279,11 +287,11 @@ module OnyxCord::API::Application
|
|
|
279
287
|
# Delete an application emoji.
|
|
280
288
|
# https://discord.com/developers/docs/resources/emoji#delete-application-emoji
|
|
281
289
|
def delete_application_emoji(token, application_id, emoji_id)
|
|
282
|
-
OnyxCord::
|
|
290
|
+
OnyxCord::REST.request(
|
|
283
291
|
:applications_aid_emojis_eid,
|
|
284
292
|
application_id,
|
|
285
293
|
:delete,
|
|
286
|
-
"#{OnyxCord::
|
|
294
|
+
"#{OnyxCord::REST.api_base}/applications/#{application_id}/emojis/#{emoji_id}",
|
|
287
295
|
Authorization: token
|
|
288
296
|
)
|
|
289
297
|
end
|
|
@@ -291,11 +299,11 @@ module OnyxCord::API::Application
|
|
|
291
299
|
# Edit the current application for the requesting bot user.
|
|
292
300
|
# https://discord.com/developers/docs/resources/application#edit-current-application
|
|
293
301
|
def update_current_application(token, custom_install_url: :undef, description: :undef, role_connections_verification_url: :undef, install_params: :undef, integration_types_config: :undef, flags: :undef, interactions_endpoint_url: :undef, tags: :undef, event_webhooks_url: :undef, event_webhooks_status: :undef, event_webhooks_types: :undef, icon: :undef, cover_image: :undef)
|
|
294
|
-
OnyxCord::
|
|
302
|
+
OnyxCord::REST.request(
|
|
295
303
|
:applications_me,
|
|
296
304
|
nil,
|
|
297
305
|
:patch,
|
|
298
|
-
"#{OnyxCord::
|
|
306
|
+
"#{OnyxCord::REST.api_base}/applications/@me",
|
|
299
307
|
{ custom_install_url:, description:, role_connections_verification_url:, install_params:, integration_types_config:, flags:, interactions_endpoint_url:, tags:, event_webhooks_url:, event_webhooks_status:, event_webhooks_types:, icon:, cover_image: }.reject { |_, value| value == :undef }.to_json,
|
|
300
308
|
Authorization: token,
|
|
301
309
|
content_type: :json
|
|
@@ -305,12 +313,26 @@ module OnyxCord::API::Application
|
|
|
305
313
|
# Get a list of role connection metadata records.
|
|
306
314
|
# https://discord.com/developers/docs/resources/application-role-connection-metadata#get-application-role-connection-metadata-records
|
|
307
315
|
def get_application_role_connection_metadata_records(token, application_id)
|
|
308
|
-
OnyxCord::
|
|
316
|
+
OnyxCord::REST.request(
|
|
309
317
|
:applications_aid_role_connections_metadata,
|
|
310
318
|
nil,
|
|
311
319
|
:get,
|
|
312
|
-
"#{OnyxCord::
|
|
320
|
+
"#{OnyxCord::REST.api_base}/applications/#{application_id}/role-connections/metadata",
|
|
313
321
|
Authorization: token
|
|
314
322
|
)
|
|
315
323
|
end
|
|
324
|
+
|
|
325
|
+
# Update the role connection metadata records for the application.
|
|
326
|
+
# https://discord.com/developers/docs/resources/application-role-connection-metadata#update-application-role-connection-metadata-records
|
|
327
|
+
def set_application_role_connection_metadata_records(token, application_id, metadata)
|
|
328
|
+
OnyxCord::REST.request(
|
|
329
|
+
:applications_aid_role_connections_metadata,
|
|
330
|
+
nil,
|
|
331
|
+
:put,
|
|
332
|
+
"#{OnyxCord::REST.api_base}/applications/#{application_id}/role-connections/metadata",
|
|
333
|
+
metadata.to_json,
|
|
334
|
+
Authorization: token,
|
|
335
|
+
content_type: :json
|
|
336
|
+
)
|
|
337
|
+
end
|
|
316
338
|
end
|