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
|
@@ -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,11 +98,11 @@ 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)
|
|
@@ -132,7 +132,7 @@ module OnyxCord::API
|
|
|
132
132
|
if Async::Task.current?
|
|
133
133
|
request_async(key, major_parameter, type, *attributes)
|
|
134
134
|
else
|
|
135
|
-
OnyxCord::AsyncRuntime.run { request_async(key, major_parameter, type, *attributes) }
|
|
135
|
+
OnyxCord::Internal::AsyncRuntime.run { request_async(key, major_parameter, type, *attributes) }
|
|
136
136
|
end
|
|
137
137
|
end
|
|
138
138
|
|
|
@@ -159,6 +159,7 @@ module OnyxCord::API
|
|
|
159
159
|
|
|
160
160
|
retries = 0
|
|
161
161
|
max_retries = key == :gateway ? 0 : 3
|
|
162
|
+
retryable_codes = [500, 502, 503, 504].freeze
|
|
162
163
|
|
|
163
164
|
begin
|
|
164
165
|
async_rate_limiter.before_request(key, major_parameter)
|
|
@@ -166,23 +167,23 @@ module OnyxCord::API
|
|
|
166
167
|
response = nil
|
|
167
168
|
loop do
|
|
168
169
|
begin
|
|
169
|
-
response = OnyxCord::HTTP.request(type, url, body, **headers)
|
|
170
|
+
response = ::OnyxCord::Internal::HTTP.request(type, url, body, **headers)
|
|
170
171
|
rescue StandardError => e
|
|
171
172
|
retries += 1
|
|
172
173
|
raise unless retries < max_retries
|
|
173
174
|
|
|
174
175
|
OnyxCord::LOGGER.warn("Temporary HTTP failure while sending request (#{e.class}), retrying")
|
|
175
|
-
OnyxCord::AsyncRuntime.sleep(retries * 0.5)
|
|
176
|
+
OnyxCord::Internal::AsyncRuntime.sleep(retries * 0.5)
|
|
176
177
|
next
|
|
177
178
|
end
|
|
178
179
|
|
|
179
|
-
break unless
|
|
180
|
+
break unless retryable_codes.include?(response.code)
|
|
180
181
|
|
|
181
182
|
retries += 1
|
|
182
183
|
break unless retries < max_retries
|
|
183
184
|
|
|
184
185
|
OnyxCord::LOGGER.warn("Got HTTP #{response.code} while sending a request, retrying")
|
|
185
|
-
OnyxCord::AsyncRuntime.sleep(retries * 0.5)
|
|
186
|
+
OnyxCord::Internal::AsyncRuntime.sleep(retries * 0.5)
|
|
186
187
|
end
|
|
187
188
|
|
|
188
189
|
if response.code == 403
|
|
@@ -242,9 +243,9 @@ module OnyxCord::API
|
|
|
242
243
|
if body_data['code'] == 110_000
|
|
243
244
|
case body_data['retry_after']
|
|
244
245
|
when 0, 1, nil
|
|
245
|
-
OnyxCord::AsyncRuntime.sleep(rand(4.5..5.0))
|
|
246
|
+
OnyxCord::Internal::AsyncRuntime.sleep(rand(4.5..5.0))
|
|
246
247
|
else
|
|
247
|
-
OnyxCord::AsyncRuntime.sleep(body_data['retry_after'])
|
|
248
|
+
OnyxCord::Internal::AsyncRuntime.sleep(body_data['retry_after'])
|
|
248
249
|
end
|
|
249
250
|
|
|
250
251
|
return request_async(key, major_parameter, type, url, body, headers)
|
|
@@ -281,7 +282,7 @@ module OnyxCord::API
|
|
|
281
282
|
|
|
282
283
|
def request_diagnostic(type, url, body, headers)
|
|
283
284
|
clean_url = url.to_s.sub(%r{/webhooks/(\d+)/[^?]+}, '/webhooks/\1/[token]')
|
|
284
|
-
|
|
285
|
+
.sub(%r{/interactions/(\d+)/[^/]+}, '/interactions/\1/[token]')
|
|
285
286
|
header_keys = headers.keys.map(&:to_s).sort.join(',')
|
|
286
287
|
body_info = if body.is_a?(Hash)
|
|
287
288
|
body.map do |key, value|
|
|
@@ -447,4 +448,4 @@ module OnyxCord::API
|
|
|
447
448
|
end
|
|
448
449
|
end
|
|
449
450
|
|
|
450
|
-
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
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OnyxCord::REST::Channel
|
|
4
|
+
module_function
|
|
5
|
+
|
|
6
|
+
# Build attachment metadata payload for multipart uploads.
|
|
7
|
+
# Returns an array of { id:, filename: } hashes.
|
|
8
|
+
def attachment_payload(attachments)
|
|
9
|
+
OnyxCord::MessagePayload.attachment_payload(attachments)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Build multipart body with named file fields and JSON payload.
|
|
13
|
+
def multipart_body(body, attachments)
|
|
14
|
+
OnyxCord::MessagePayload.multipart_body(body, attachments)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Get a channel's data
|
|
18
|
+
# https://discord.com/developers/docs/resources/channel#get-channel
|
|
19
|
+
def resolve(token, channel_id)
|
|
20
|
+
OnyxCord::REST.request(
|
|
21
|
+
:channels_cid,
|
|
22
|
+
channel_id,
|
|
23
|
+
:get,
|
|
24
|
+
"#{OnyxCord::REST.api_base}/channels/#{channel_id}",
|
|
25
|
+
Authorization: token
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Update a channel's data
|
|
30
|
+
# https://discord.com/developers/docs/resources/channel#modify-channel
|
|
31
|
+
def update(token, channel_id, name, topic, position, bitrate, user_limit, nsfw, permission_overwrites = nil, parent_id = nil, rate_limit_per_user = nil, reason = nil, archived = nil, auto_archive_duration = nil, locked = nil, invitable = nil, flags = nil, applied_tags = nil)
|
|
32
|
+
data = { name: name, position: position, topic: topic, bitrate: bitrate, user_limit: user_limit, nsfw: nsfw, parent_id: parent_id, rate_limit_per_user: rate_limit_per_user, archived: archived, auto_archive_duration: auto_archive_duration, locked: locked, invitable: invitable, flags: flags, applied_tags: applied_tags }
|
|
33
|
+
data[:permission_overwrites] = permission_overwrites unless permission_overwrites.nil?
|
|
34
|
+
OnyxCord::REST.request(
|
|
35
|
+
:channels_cid,
|
|
36
|
+
channel_id,
|
|
37
|
+
:patch,
|
|
38
|
+
"#{OnyxCord::REST.api_base}/channels/#{channel_id}",
|
|
39
|
+
data.to_json,
|
|
40
|
+
Authorization: token,
|
|
41
|
+
content_type: :json,
|
|
42
|
+
'X-Audit-Log-Reason': reason
|
|
43
|
+
)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Modify the properties of a channel.
|
|
47
|
+
# https://discord.com/developers/docs/resources/channel#modify-channel
|
|
48
|
+
def update!(token, channel_id, name: :undef, type: :undef, position: :undef, topic: :undef, nsfw: :undef, rate_limit_per_user: :undef, bitrate: :undef, user_limit: :undef, permission_overwrites: :undef, parent_id: :undef, rtc_region: :undef, video_quality_mode: :undef, default_auto_archive_duration: :undef, flags: :undef, available_tags: :undef, default_reaction_emoji: :undef, default_thread_rate_limit_per_user: :undef, default_sort_order: :undef, default_forum_layout: :undef, archived: :undef, auto_archive_duration: :undef, locked: :undef, invitable: :undef, applied_tags: :undef, reason: nil)
|
|
49
|
+
OnyxCord::REST.request(
|
|
50
|
+
:channels_cid,
|
|
51
|
+
channel_id,
|
|
52
|
+
:patch,
|
|
53
|
+
"#{OnyxCord::REST.api_base}/channels/#{channel_id}",
|
|
54
|
+
{ name:, type:, position:, topic:, nsfw:, rate_limit_per_user:, bitrate:, user_limit:, permission_overwrites:, parent_id:, rtc_region:, video_quality_mode:, default_auto_archive_duration:, flags:, available_tags:, default_reaction_emoji:, default_thread_rate_limit_per_user:, default_sort_order:, default_forum_layout:, archived:, auto_archive_duration:, locked:, invitable:, applied_tags: }.reject { |_, value| value == :undef }.to_json,
|
|
55
|
+
Authorization: token,
|
|
56
|
+
content_type: :json,
|
|
57
|
+
'X-Audit-Log-Reason': reason
|
|
58
|
+
)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Delete a channel
|
|
62
|
+
# https://discord.com/developers/docs/resources/channel#deleteclose-channel
|
|
63
|
+
def delete(token, channel_id, reason = nil)
|
|
64
|
+
OnyxCord::REST.request(
|
|
65
|
+
:channels_cid,
|
|
66
|
+
channel_id,
|
|
67
|
+
:delete,
|
|
68
|
+
"#{OnyxCord::REST.api_base}/channels/#{channel_id}",
|
|
69
|
+
Authorization: token,
|
|
70
|
+
'X-Audit-Log-Reason': reason
|
|
71
|
+
)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OnyxCord::REST::Channel
|
|
4
|
+
module_function
|
|
5
|
+
|
|
6
|
+
# Create an empty group channel.
|
|
7
|
+
# @deprecated Discord no longer supports bots in group DMs, this endpoint was repurposed and no longer works as implemented here.
|
|
8
|
+
# https://discord.com/developers/docs/resources/user#create-group-dm
|
|
9
|
+
def create_empty_group(token, bot_user_id)
|
|
10
|
+
OnyxCord::REST.request(
|
|
11
|
+
:users_uid_channels,
|
|
12
|
+
nil,
|
|
13
|
+
:post,
|
|
14
|
+
"#{OnyxCord::REST.api_base}/users/#{bot_user_id}/channels",
|
|
15
|
+
{}.to_json,
|
|
16
|
+
Authorization: token,
|
|
17
|
+
content_type: :json
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Create a group channel.
|
|
22
|
+
# @deprecated Discord no longer supports bots in group DMs, this endpoint was repurposed and no longer works as implemented here.
|
|
23
|
+
# https://discord.com/developers/docs/resources/channel#group-dm-add-recipient
|
|
24
|
+
def create_group(token, pm_channel_id, user_id)
|
|
25
|
+
OnyxCord::REST.request(
|
|
26
|
+
:channels_cid_recipients_uid,
|
|
27
|
+
nil,
|
|
28
|
+
:put,
|
|
29
|
+
"#{OnyxCord::REST.api_base}/channels/#{pm_channel_id}/recipients/#{user_id}",
|
|
30
|
+
{}.to_json,
|
|
31
|
+
Authorization: token,
|
|
32
|
+
content_type: :json
|
|
33
|
+
)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Add a user to a group channel.
|
|
37
|
+
# @deprecated Discord no longer supports bots in group DMs, this endpoint was repurposed and no longer works as implemented here.
|
|
38
|
+
# https://discord.com/developers/docs/resources/channel#group-dm-add-recipient
|
|
39
|
+
def add_group_user(token, group_channel_id, user_id)
|
|
40
|
+
OnyxCord::REST.request(
|
|
41
|
+
:channels_cid_recipients_uid,
|
|
42
|
+
nil,
|
|
43
|
+
:put,
|
|
44
|
+
"#{OnyxCord::REST.api_base}/channels/#{group_channel_id}/recipients/#{user_id}",
|
|
45
|
+
{}.to_json,
|
|
46
|
+
Authorization: token,
|
|
47
|
+
content_type: :json
|
|
48
|
+
)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Remove a user from a group channel.
|
|
52
|
+
# @deprecated Discord no longer supports bots in group DMs, this endpoint was repurposed and no longer works as implemented here.
|
|
53
|
+
# https://discord.com/developers/docs/resources/channel#group-dm-remove-recipient
|
|
54
|
+
def remove_group_user(token, group_channel_id, user_id)
|
|
55
|
+
OnyxCord::REST.request(
|
|
56
|
+
:channels_cid_recipients_uid,
|
|
57
|
+
nil,
|
|
58
|
+
:delete,
|
|
59
|
+
"#{OnyxCord::REST.api_base}/channels/#{group_channel_id}/recipients/#{user_id}",
|
|
60
|
+
Authorization: token,
|
|
61
|
+
content_type: :json
|
|
62
|
+
)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Leave a group channel.
|
|
66
|
+
# @deprecated Discord no longer supports bots in group DMs, this endpoint was repurposed and no longer works as implemented here.
|
|
67
|
+
# https://discord.com/developers/docs/resources/channel#deleteclose-channel
|
|
68
|
+
def leave_group(token, group_channel_id)
|
|
69
|
+
OnyxCord::REST.request(
|
|
70
|
+
:channels_cid,
|
|
71
|
+
nil,
|
|
72
|
+
:delete,
|
|
73
|
+
"#{OnyxCord::REST.api_base}/channels/#{group_channel_id}",
|
|
74
|
+
Authorization: token,
|
|
75
|
+
content_type: :json
|
|
76
|
+
)
|
|
77
|
+
end
|
|
78
|
+
end
|