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
|
@@ -70,10 +70,10 @@ module OnyxCord
|
|
|
70
70
|
|
|
71
71
|
# @!visibility private
|
|
72
72
|
def update_profile_data(new_data)
|
|
73
|
-
update_data(JSON.parse(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
update_data(JSON.parse(REST::User.update_current_user(@bot.token,
|
|
74
|
+
new_data[:username] || :undef,
|
|
75
|
+
new_data.key?(:avatar) ? new_data[:avatar] : :undef,
|
|
76
|
+
new_data.key?(:banner) ? new_data[:banner] : :undef)))
|
|
77
77
|
end
|
|
78
78
|
end
|
|
79
79
|
end
|
|
@@ -227,7 +227,7 @@ module OnyxCord
|
|
|
227
227
|
# @param format ['webp', 'png', 'jpeg']
|
|
228
228
|
# @return [String] URL to the icon on Discord's CDN.
|
|
229
229
|
def icon_url(format = 'webp')
|
|
230
|
-
|
|
230
|
+
REST.role_icon_url(@id, @icon, format) if @icon
|
|
231
231
|
end
|
|
232
232
|
|
|
233
233
|
# Get the icon that a role has displayed.
|
|
@@ -288,7 +288,7 @@ module OnyxCord
|
|
|
288
288
|
# Deletes this role. This cannot be undone without recreating the role!
|
|
289
289
|
# @param reason [String] the reason for this role's deletion
|
|
290
290
|
def delete(reason = nil)
|
|
291
|
-
|
|
291
|
+
REST::Server.delete_role(@bot.token, @server.id, @id, reason)
|
|
292
292
|
@server.delete_role(@id)
|
|
293
293
|
end
|
|
294
294
|
|
|
@@ -308,17 +308,13 @@ module OnyxCord
|
|
|
308
308
|
# @param reason [String, nil] The audit log reason to show for moving the role.
|
|
309
309
|
# @return [Integer] The new position of the role.
|
|
310
310
|
def move(bottom: nil, above: nil, below: nil, offset: 0, reason: nil)
|
|
311
|
-
if [bottom, above, below].count(&:itself) > 1
|
|
312
|
-
raise ArgumentError, "'bottom', 'above', and 'below' are mutually exclusive"
|
|
313
|
-
end
|
|
311
|
+
raise ArgumentError, "'bottom', 'above', and 'below' are mutually exclusive" if [bottom, above, below].count(&:itself) > 1
|
|
314
312
|
|
|
315
313
|
if (above || below) && !(target = @server.role(above || below))
|
|
316
314
|
raise ArgumentError, "The given 'above' or 'below' options are not valid"
|
|
317
315
|
end
|
|
318
316
|
|
|
319
|
-
if (below && target&.id == @server.id) || (@id == target&.id)
|
|
320
|
-
raise ArgumentError, 'The target role that was provded is not valid'
|
|
321
|
-
end
|
|
317
|
+
raise ArgumentError, 'The target role that was provded is not valid' if (below && target&.id == @server.id) || (@id == target&.id)
|
|
322
318
|
|
|
323
319
|
roles = @server.roles.sort_by { |role| [role.position, role.id] }
|
|
324
320
|
|
|
@@ -394,9 +390,7 @@ module OnyxCord
|
|
|
394
390
|
permissions: :undef, reason: nil
|
|
395
391
|
)
|
|
396
392
|
if display_icon != :undef
|
|
397
|
-
if icon != :undef || unicode_emoji != :undef
|
|
398
|
-
raise ArgumentError, "'display_icon' is mutually exclusive with 'icon' and 'unicode_emoji'"
|
|
399
|
-
end
|
|
393
|
+
raise ArgumentError, "'display_icon' is mutually exclusive with 'icon' and 'unicode_emoji'" if icon != :undef || unicode_emoji != :undef
|
|
400
394
|
|
|
401
395
|
if display_icon.nil?
|
|
402
396
|
icon = nil
|
|
@@ -437,7 +431,7 @@ module OnyxCord
|
|
|
437
431
|
}
|
|
438
432
|
end
|
|
439
433
|
|
|
440
|
-
update_data(JSON.parse(
|
|
434
|
+
update_data(JSON.parse(REST::Server.update_role!(@bot.token, @server.id, @id, **data)))
|
|
441
435
|
nil
|
|
442
436
|
end
|
|
443
437
|
|
|
@@ -93,7 +93,7 @@ module OnyxCord
|
|
|
93
93
|
# @param size [Integer, nil] The URL will default to `4096`. You can otherwise specify any number that's a power of two to override this.
|
|
94
94
|
# @return [String, nil] The URL to the scheduled event's cover image, or `nil` if the scheduled event doesn't have a cover image set.
|
|
95
95
|
def cover_url(format: 'webp', size: 4096)
|
|
96
|
-
|
|
96
|
+
REST.scheduled_event_cover_url(@id, @cover_id, format, size) if @cover_id
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
# @!method scheduled?
|
|
@@ -191,7 +191,7 @@ module OnyxCord
|
|
|
191
191
|
builder[:recurrence_rule] = builder.to_h
|
|
192
192
|
end
|
|
193
193
|
|
|
194
|
-
update_data(JSON.parse(
|
|
194
|
+
update_data(JSON.parse(REST::Server.update_scheduled_event(@bot.token, @server_id, @id, **data)))
|
|
195
195
|
nil
|
|
196
196
|
end
|
|
197
197
|
|
|
@@ -199,7 +199,7 @@ module OnyxCord
|
|
|
199
199
|
# @param reason [String, nil] The reason to show in the audit log for deleting the scheduled event.
|
|
200
200
|
# @return [nil]
|
|
201
201
|
def delete(reason: nil)
|
|
202
|
-
|
|
202
|
+
REST::Server.delete_scheduled_event(@bot.token, @server_id, @id, reason: reason)
|
|
203
203
|
@server&.delete_scheduled_event(@id)
|
|
204
204
|
nil
|
|
205
205
|
end
|
|
@@ -207,7 +207,7 @@ module OnyxCord
|
|
|
207
207
|
# Get the total amount of users who are subscribed to the scheduled event.
|
|
208
208
|
# @return [Integer] The total amount of users who are currently subscribed to the scheduled event.
|
|
209
209
|
def user_count
|
|
210
|
-
@user_count ||= JSON.parse(
|
|
210
|
+
@user_count ||= JSON.parse(REST::Server.get_scheduled_event(@bot.token, @server_id, @id, with_user_count: true))['user_count']
|
|
211
211
|
end
|
|
212
212
|
|
|
213
213
|
alias_method :subscriber_count, :user_count
|
|
@@ -218,7 +218,7 @@ module OnyxCord
|
|
|
218
218
|
# @return [Array<User, Member>] the users or members that have subscribed to the scheduled event.
|
|
219
219
|
def users(limit: 100, member: false)
|
|
220
220
|
get_users = proc do |fetch_limit, after = nil|
|
|
221
|
-
response = JSON.parse(
|
|
221
|
+
response = JSON.parse(REST::Server.get_scheduled_event_users(@bot.token, @server_id, @id, limit: fetch_limit, with_member: member, after: after))
|
|
222
222
|
response.map { |data| data['member'] ? Member.new(data['member'], server, @bot).tap { |member| server&.cache_member(member) } : User.new(data['user'], @bot) }
|
|
223
223
|
end
|
|
224
224
|
|
|
@@ -14,7 +14,7 @@ module OnyxCord
|
|
|
14
14
|
# or `png` to override this.
|
|
15
15
|
# @return [String, nil] The URL to the server's icon, or `nil` if the server hasn't set an icon.
|
|
16
16
|
def icon_url(format: 'webp')
|
|
17
|
-
|
|
17
|
+
REST.icon_url(@id, @icon_id, format) if @icon_id
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
@@ -172,7 +172,7 @@ module OnyxCord
|
|
|
172
172
|
# end
|
|
173
173
|
# @return [Hash<Integer => Integer>] A hash mapping role IDs to their respective member counts.
|
|
174
174
|
def role_member_counts
|
|
175
|
-
response = JSON.parse(
|
|
175
|
+
response = JSON.parse(REST::Server.role_member_counts(@bot.token, @id))
|
|
176
176
|
response.transform_keys!(&:to_i)
|
|
177
177
|
response.tap { |hash| hash[@id] = @member_count }
|
|
178
178
|
end
|
|
@@ -226,7 +226,7 @@ module OnyxCord
|
|
|
226
226
|
# @return [Array<Integration>] an array of the integrations in this server.
|
|
227
227
|
# @note If the server has more than 50 integrations, they cannot be accessed.
|
|
228
228
|
def integrations
|
|
229
|
-
integration = JSON.parse(
|
|
229
|
+
integration = JSON.parse(REST::Server.integrations(@bot.token, @id))
|
|
230
230
|
integration.map { |element| Integration.new(element, @bot, self) }
|
|
231
231
|
end
|
|
232
232
|
|
|
@@ -241,14 +241,14 @@ module OnyxCord
|
|
|
241
241
|
action = AuditLogs::ACTIONS.key(action)
|
|
242
242
|
user = user.resolve_id if user
|
|
243
243
|
before = before.resolve_id if before
|
|
244
|
-
AuditLogs.new(self, @bot, JSON.parse(
|
|
244
|
+
AuditLogs.new(self, @bot, JSON.parse(REST::Server.audit_logs(@bot.token, @id, limit, user, action, before)))
|
|
245
245
|
end
|
|
246
246
|
|
|
247
247
|
# @note For internal use only
|
|
248
248
|
# @!visibility private
|
|
249
249
|
def cache_widget_data(data = nil)
|
|
250
250
|
data ||= if bot.permission?(:manage_server)
|
|
251
|
-
JSON.parse(
|
|
251
|
+
JSON.parse(REST::Server.widget(@bot.token, @id))
|
|
252
252
|
else
|
|
253
253
|
return update_data(nil)
|
|
254
254
|
end
|
|
@@ -315,7 +315,7 @@ module OnyxCord
|
|
|
315
315
|
def modify_widget(enabled, channel, reason = nil)
|
|
316
316
|
cache_widget_data if @widget_enabled.nil?
|
|
317
317
|
channel_id = channel ? channel.resolve_id : @widget_channel_id
|
|
318
|
-
cache_widget_data(JSON.parse(
|
|
318
|
+
cache_widget_data(JSON.parse(REST::Server.modify_widget(@bot.token, @id, enabled, channel_id, reason)))
|
|
319
319
|
end
|
|
320
320
|
alias_method :modify_embed, :modify_widget
|
|
321
321
|
|
|
@@ -344,7 +344,7 @@ module OnyxCord
|
|
|
344
344
|
def add_member_using_token(user, access_token, nick: nil, roles: [], deaf: false, mute: false)
|
|
345
345
|
user_id = user.resolve_id
|
|
346
346
|
roles = roles.is_a?(Array) ? roles.map(&:resolve_id) : [roles.resolve_id]
|
|
347
|
-
response =
|
|
347
|
+
response = REST::Server.add_member(@bot.token, @id, user_id, access_token, nick, roles, deaf, mute)
|
|
348
348
|
return nil if response.empty?
|
|
349
349
|
|
|
350
350
|
add_member Member.new(JSON.parse(response), self, @bot)
|
|
@@ -357,7 +357,7 @@ module OnyxCord
|
|
|
357
357
|
def prune_count(days)
|
|
358
358
|
raise ArgumentError, 'Days must be between 1 and 30' unless days.between?(1, 30)
|
|
359
359
|
|
|
360
|
-
response = JSON.parse
|
|
360
|
+
response = JSON.parse REST::Server.prune_count(@bot.token, @id, days)
|
|
361
361
|
response['pruned']
|
|
362
362
|
end
|
|
363
363
|
|
|
@@ -369,7 +369,7 @@ module OnyxCord
|
|
|
369
369
|
def begin_prune(days, reason = nil)
|
|
370
370
|
raise ArgumentError, 'Days must be between 1 and 30' unless days.between?(1, 30)
|
|
371
371
|
|
|
372
|
-
response = JSON.parse
|
|
372
|
+
response = JSON.parse REST::Server.begin_prune(@bot.token, @id, days, reason)
|
|
373
373
|
response['pruned']
|
|
374
374
|
end
|
|
375
375
|
|
|
@@ -405,7 +405,7 @@ module OnyxCord
|
|
|
405
405
|
def widget_url
|
|
406
406
|
update_data if @widget_enabled.nil?
|
|
407
407
|
|
|
408
|
-
|
|
408
|
+
REST.widget_url(@id) if @widget_enabled
|
|
409
409
|
end
|
|
410
410
|
|
|
411
411
|
# @param style [Symbol] The style the picture should have. Possible styles are:
|
|
@@ -419,7 +419,7 @@ module OnyxCord
|
|
|
419
419
|
def widget_banner_url(style)
|
|
420
420
|
update_data if @widget_enabled.nil?
|
|
421
421
|
|
|
422
|
-
|
|
422
|
+
REST.widget_url(@id, style) if @widget_enabled
|
|
423
423
|
end
|
|
424
424
|
|
|
425
425
|
# Utility method to get a server's splash URL.
|
|
@@ -427,7 +427,7 @@ module OnyxCord
|
|
|
427
427
|
# override this.
|
|
428
428
|
# @return [String, nil] The URL to the server's splash image, or `nil` if the server doesn't have a splash image.
|
|
429
429
|
def splash_url(format: 'webp')
|
|
430
|
-
|
|
430
|
+
REST.splash_url(@id, @splash_id, format) if @splash_id
|
|
431
431
|
end
|
|
432
432
|
|
|
433
433
|
# Utility method to get a server's banner URL.
|
|
@@ -435,14 +435,14 @@ module OnyxCord
|
|
|
435
435
|
# override this.
|
|
436
436
|
# @return [String, nil] The URL to the server's banner image, or `nil` if the server doesn't have a banner image.
|
|
437
437
|
def banner_url(format: 'webp')
|
|
438
|
-
|
|
438
|
+
REST.banner_url(@id, @banner_id, format) if @banner_id
|
|
439
439
|
end
|
|
440
440
|
|
|
441
441
|
# Utility method to get a server's discovery splash URL.
|
|
442
442
|
# @param format [String] The URL will default to `webp`. You can otherwise specify one of `jpg` or `png` to override this.
|
|
443
443
|
# @return [String, nil] The URL to the server's discovery splash image, or `nil` if the server doesn't have a discovery splash image.
|
|
444
444
|
def discovery_splash_url(format: 'webp')
|
|
445
|
-
|
|
445
|
+
REST.discovery_splash_url(@id, @discovery_splash_id, format) if @discovery_splash_id
|
|
446
446
|
end
|
|
447
447
|
|
|
448
448
|
# @return [String] a URL that a user can use to navigate to this server in the client
|
|
@@ -581,7 +581,7 @@ module OnyxCord
|
|
|
581
581
|
total = nil
|
|
582
582
|
|
|
583
583
|
get_messages = lambda do |query|
|
|
584
|
-
data = JSON.parse(
|
|
584
|
+
data = JSON.parse(REST::Server.search_messages(@bot.token, @id, **options, **query.compact))
|
|
585
585
|
total ||= data['total_results']
|
|
586
586
|
|
|
587
587
|
data['threads']&.each do |thread|
|
|
@@ -636,7 +636,7 @@ module OnyxCord
|
|
|
636
636
|
# @note For internal use only
|
|
637
637
|
# @!visibility private
|
|
638
638
|
def update_role_positions(role_positions, reason: nil)
|
|
639
|
-
response = JSON.parse(
|
|
639
|
+
response = JSON.parse(REST::Server.update_role_positions(@bot.token, @id, role_positions, reason))
|
|
640
640
|
response.each { |data| role(data['id'].to_i)&.update_data(data) }
|
|
641
641
|
end
|
|
642
642
|
|
|
@@ -738,7 +738,7 @@ module OnyxCord
|
|
|
738
738
|
|
|
739
739
|
permission_overwrites.map! { |e| e.is_a?(Overwrite) ? e.to_hash : e } if permission_overwrites.is_a?(Array)
|
|
740
740
|
parent_id = parent.respond_to?(:resolve_id) ? parent.resolve_id : nil
|
|
741
|
-
response =
|
|
741
|
+
response = REST::Server.create_channel(@bot.token, @id, name, type, topic, bitrate, user_limit, permission_overwrites, parent_id, nsfw, rate_limit_per_user, position, reason)
|
|
742
742
|
Channel.new(JSON.parse(response), @bot)
|
|
743
743
|
end
|
|
744
744
|
|
|
@@ -782,7 +782,7 @@ module OnyxCord
|
|
|
782
782
|
icon = OnyxCord.encode64(display_icon)
|
|
783
783
|
end
|
|
784
784
|
|
|
785
|
-
response =
|
|
785
|
+
response = REST::Server.create_role(@bot.token, @id, name, nil, hoist, mentionable, permissions&.to_s, reason, colours, icon, unicode_emoji)
|
|
786
786
|
|
|
787
787
|
role = Role.new(JSON.parse(response), @bot, self)
|
|
788
788
|
@roles[role.id] = role
|
|
@@ -797,7 +797,7 @@ module OnyxCord
|
|
|
797
797
|
def add_emoji(name, image, roles = [], reason: nil)
|
|
798
798
|
image = image.respond_to?(:read) ? OnyxCord.encode64(image) : image
|
|
799
799
|
|
|
800
|
-
data = JSON.parse(
|
|
800
|
+
data = JSON.parse(REST::Server.add_emoji(@bot.token, @id, image, name, roles.map(&:resolve_id), reason))
|
|
801
801
|
new_emoji = Emoji.new(data, @bot, self)
|
|
802
802
|
@emoji[new_emoji.id] = new_emoji
|
|
803
803
|
end
|
|
@@ -806,7 +806,7 @@ module OnyxCord
|
|
|
806
806
|
# @param emoji [Emoji, String, Integer] The emoji or emoji ID to be deleted.
|
|
807
807
|
# @param reason [String] The reason the for the deletion of this emoji.
|
|
808
808
|
def delete_emoji(emoji, reason: nil)
|
|
809
|
-
|
|
809
|
+
REST::Server.delete_emoji(@bot.token, @id, emoji.resolve_id, reason)
|
|
810
810
|
end
|
|
811
811
|
|
|
812
812
|
# Changes the name and/or role whitelist of an emoji on this server.
|
|
@@ -817,7 +817,7 @@ module OnyxCord
|
|
|
817
817
|
# @return [Emoji] The edited emoji.
|
|
818
818
|
def edit_emoji(emoji, name: nil, roles: nil, reason: nil)
|
|
819
819
|
emoji = @emoji[emoji.resolve_id]
|
|
820
|
-
data = JSON.parse(
|
|
820
|
+
data = JSON.parse(REST::Server.edit_emoji(@bot.token, @id, emoji.resolve_id, name || emoji.name, (roles || emoji.roles).map(&:resolve_id), reason))
|
|
821
821
|
new_emoji = Emoji.new(data, @bot, self)
|
|
822
822
|
@emoji[new_emoji.id] = new_emoji
|
|
823
823
|
end
|
|
@@ -842,7 +842,7 @@ module OnyxCord
|
|
|
842
842
|
# @param limit [Integer] The maximum number of members between 1-1000 to return. Returns 1 member by default.
|
|
843
843
|
# @return [Array<Member>, nil] An array of member objects that match the given parameters, or nil for no members.
|
|
844
844
|
def search_members(name:, limit: nil)
|
|
845
|
-
response = JSON.parse(
|
|
845
|
+
response = JSON.parse(REST::Server.search_guild_members(@bot.token, @id, name, limit))
|
|
846
846
|
return nil if response.empty?
|
|
847
847
|
|
|
848
848
|
response.map { |mem| Member.new(mem, self, @bot) }
|
|
@@ -854,7 +854,7 @@ module OnyxCord
|
|
|
854
854
|
# @param after_id [Integer] Consider only users after given user id.
|
|
855
855
|
# @return [Array<ServerBan>] a list of banned users on this server and the reason they were banned.
|
|
856
856
|
def bans(limit: nil, before_id: nil, after_id: nil)
|
|
857
|
-
response = JSON.parse(
|
|
857
|
+
response = JSON.parse(REST::Server.bans(@bot.token, @id, limit, before_id, after_id))
|
|
858
858
|
response.map do |e|
|
|
859
859
|
ServerBan.new(self, @bot.ensure_user(e['user']), e['reason'])
|
|
860
860
|
end
|
|
@@ -875,7 +875,7 @@ module OnyxCord
|
|
|
875
875
|
f_before = before.is_a?(Time) ? IDObject.synthesize(before) : before&.resolve_id
|
|
876
876
|
|
|
877
877
|
get_bans = lambda do |before: nil, after: nil|
|
|
878
|
-
data =
|
|
878
|
+
data = REST::Server.bans(@bot.token, @id, f_limit, before&.id || f_before, after&.id || f_after)
|
|
879
879
|
JSON.parse(data).map { |ban| ServerBan.new(self, @bot.ensure_user(ban['user']), ban['reason']) }
|
|
880
880
|
end
|
|
881
881
|
|
|
@@ -902,14 +902,14 @@ module OnyxCord
|
|
|
902
902
|
message_seconds || 0
|
|
903
903
|
end
|
|
904
904
|
|
|
905
|
-
|
|
905
|
+
REST::Server.ban_user!(@bot.token, @id, user.resolve_id, delete_messages, reason)
|
|
906
906
|
end
|
|
907
907
|
|
|
908
908
|
# Unbans a previously banned user from this server.
|
|
909
909
|
# @param user [User, String, Integer] The user to unban.
|
|
910
910
|
# @param reason [String] The reason the user is being unbanned.
|
|
911
911
|
def unban(user, reason = nil)
|
|
912
|
-
|
|
912
|
+
REST::Server.unban_user(@bot.token, @id, user.resolve_id, reason)
|
|
913
913
|
end
|
|
914
914
|
|
|
915
915
|
# Ban up to 200 users from this server in one go.
|
|
@@ -922,7 +922,7 @@ module OnyxCord
|
|
|
922
922
|
|
|
923
923
|
return ban(users.first, 0, message_seconds: message_seconds, reason: reason) if users.size == 1
|
|
924
924
|
|
|
925
|
-
response =
|
|
925
|
+
response = REST::Server.bulk_ban(@bot.token, @id, users.map(&:resolve_id), message_seconds, reason)
|
|
926
926
|
BulkBan.new(JSON.parse(response), self, reason)
|
|
927
927
|
end
|
|
928
928
|
|
|
@@ -930,7 +930,7 @@ module OnyxCord
|
|
|
930
930
|
# @param user [User, String, Integer] The user to kick.
|
|
931
931
|
# @param reason [String] The reason the user is being kicked.
|
|
932
932
|
def kick(user, reason = nil)
|
|
933
|
-
|
|
933
|
+
REST::Server.remove_member(@bot.token, @id, user.resolve_id, reason)
|
|
934
934
|
end
|
|
935
935
|
|
|
936
936
|
# Forcibly moves a user into a different voice channel.
|
|
@@ -938,12 +938,12 @@ module OnyxCord
|
|
|
938
938
|
# @param user [User, String, Integer] The user to move.
|
|
939
939
|
# @param channel [Channel, String, Integer, nil] The voice channel to move into. (If nil, the user is disconnected from the voice channel)
|
|
940
940
|
def move(user, channel)
|
|
941
|
-
|
|
941
|
+
REST::Server.update_member(@bot.token, @id, user.resolve_id, channel_id: channel&.resolve_id)
|
|
942
942
|
end
|
|
943
943
|
|
|
944
944
|
# Leave the server.
|
|
945
945
|
def leave
|
|
946
|
-
|
|
946
|
+
REST::User.leave_server(@bot.token, @id)
|
|
947
947
|
end
|
|
948
948
|
|
|
949
949
|
# Sets the server's name.
|
|
@@ -958,7 +958,7 @@ module OnyxCord
|
|
|
958
958
|
|
|
959
959
|
@available_voice_regions = {}
|
|
960
960
|
|
|
961
|
-
data = JSON.parse
|
|
961
|
+
data = JSON.parse REST::Server.regions(@bot.token, @id)
|
|
962
962
|
@available_voice_regions = data.map { |e| VoiceRegion.new e }
|
|
963
963
|
end
|
|
964
964
|
|
|
@@ -971,7 +971,7 @@ module OnyxCord
|
|
|
971
971
|
# Moves the server to another region. This will cause a voice interruption of at most a second.
|
|
972
972
|
# @param region [String] The new region the server should be in.
|
|
973
973
|
def region=(region)
|
|
974
|
-
update_data(JSON.parse(
|
|
974
|
+
update_data(JSON.parse(REST::Server.update!(@bot.token, @id, region: region.to_s)))
|
|
975
975
|
end
|
|
976
976
|
|
|
977
977
|
# Sets the server's icon.
|
|
@@ -1127,14 +1127,14 @@ module OnyxCord
|
|
|
1127
1127
|
# Requests a list of Webhooks on the server.
|
|
1128
1128
|
# @return [Array<Webhook>] webhooks on the server.
|
|
1129
1129
|
def webhooks
|
|
1130
|
-
webhooks = JSON.parse(
|
|
1130
|
+
webhooks = JSON.parse(REST::Server.webhooks(@bot.token, @id))
|
|
1131
1131
|
webhooks.map { |webhook| Webhook.new(webhook, @bot) }
|
|
1132
1132
|
end
|
|
1133
1133
|
|
|
1134
1134
|
# Requests a list of Invites to the server.
|
|
1135
1135
|
# @return [Array<Invite>] invites to the server.
|
|
1136
1136
|
def invites
|
|
1137
|
-
invites = JSON.parse(
|
|
1137
|
+
invites = JSON.parse(REST::Server.invites(@bot.token, @id))
|
|
1138
1138
|
invites.map { |invite| Invite.new(invite, @bot) }
|
|
1139
1139
|
end
|
|
1140
1140
|
|
|
@@ -1143,7 +1143,7 @@ module OnyxCord
|
|
|
1143
1143
|
# should be ignored and re-fetched via an HTTP request.
|
|
1144
1144
|
# @return [Array<ScheduledEvent>] The scheduled events on the server.
|
|
1145
1145
|
def scheduled_events(bypass_cache: false)
|
|
1146
|
-
process_scheduled_events(JSON.parse(
|
|
1146
|
+
process_scheduled_events(JSON.parse(REST::Server.list_scheduled_events(@bot.token, @id, with_user_count: true))) if bypass_cache
|
|
1147
1147
|
|
|
1148
1148
|
@scheduled_events.values
|
|
1149
1149
|
end
|
|
@@ -1157,7 +1157,7 @@ module OnyxCord
|
|
|
1157
1157
|
return @scheduled_events[id] if @scheduled_events[id]
|
|
1158
1158
|
return nil unless request
|
|
1159
1159
|
|
|
1160
|
-
event = JSON.parse(
|
|
1160
|
+
event = JSON.parse(REST::Server.get_scheduled_event(@bot.token, @id, id, with_user_count: true))
|
|
1161
1161
|
scheduled_event = ScheduledEvent.new(event, self, @bot)
|
|
1162
1162
|
@scheduled_events[scheduled_event.id] = scheduled_event
|
|
1163
1163
|
rescue StandardError
|
|
@@ -1193,7 +1193,7 @@ module OnyxCord
|
|
|
1193
1193
|
recurrence_rule: block_given? ? builder.to_h : recurrence_rule&.to_h
|
|
1194
1194
|
}
|
|
1195
1195
|
|
|
1196
|
-
event = JSON.parse(
|
|
1196
|
+
event = JSON.parse(REST::Server.create_scheduled_event(@bot.token, @id, **options, reason: reason))
|
|
1197
1197
|
scheduled_event = ScheduledEvent.new(event, self, @bot)
|
|
1198
1198
|
@scheduled_events[scheduled_event.id] = scheduled_event
|
|
1199
1199
|
end
|
|
@@ -1305,7 +1305,7 @@ module OnyxCord
|
|
|
1305
1305
|
channel_id: widget_channel == :undef ? widget_channel : widget_channel&.resolve_id
|
|
1306
1306
|
}
|
|
1307
1307
|
|
|
1308
|
-
cache_widget_data(JSON.parse(
|
|
1308
|
+
cache_widget_data(JSON.parse(REST::Server.update_widget(@bot.token, @id, **widget_data, reason: reason)))
|
|
1309
1309
|
end
|
|
1310
1310
|
|
|
1311
1311
|
if invites_disabled_until != :undef || dms_disabled_until != :undef
|
|
@@ -1314,12 +1314,12 @@ module OnyxCord
|
|
|
1314
1314
|
invites_disabled_until: invites_disabled_until == :undef ? @invites_disabled_until&.iso8601 : invites_disabled_until&.iso8601
|
|
1315
1315
|
}
|
|
1316
1316
|
|
|
1317
|
-
process_incident_actions(JSON.parse(
|
|
1317
|
+
process_incident_actions(JSON.parse(REST::Server.update_incident_actions(@bot.token, @id, **incidents_data, reason: reason)))
|
|
1318
1318
|
end
|
|
1319
1319
|
|
|
1320
1320
|
return unless data.any? { |_, value| value != :undef }
|
|
1321
1321
|
|
|
1322
|
-
update_data(JSON.parse(
|
|
1322
|
+
update_data(JSON.parse(REST::Server.update!(@bot.token, @id, **data, reason: reason)))
|
|
1323
1323
|
nil
|
|
1324
1324
|
end
|
|
1325
1325
|
|
|
@@ -1327,7 +1327,7 @@ module OnyxCord
|
|
|
1327
1327
|
# @note For internal use only
|
|
1328
1328
|
# @!visibility private
|
|
1329
1329
|
def update_data(new_data = nil)
|
|
1330
|
-
new_data ||= JSON.parse(
|
|
1330
|
+
new_data ||= JSON.parse(REST::Server.resolve(@bot.token, @id))
|
|
1331
1331
|
@name = new_data['name']
|
|
1332
1332
|
@icon_id = new_data['icon']
|
|
1333
1333
|
@splash_id = new_data['splash']
|
|
@@ -55,14 +55,14 @@ module OnyxCord
|
|
|
55
55
|
# @param format [String] the URL will default to `webp`. You can otherwise specify one of `jpg` or `png` to override this.
|
|
56
56
|
# @return [String, nil] the URL to the server's splash image, or `nil` if the server doesn't have a splash image.
|
|
57
57
|
def splash_url(format = 'webp')
|
|
58
|
-
|
|
58
|
+
REST.splash_url(@id, @splash_id, format) if @splash_id
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
# Utility method to get a server preview's discovery splash URL.
|
|
62
62
|
# @param format [String] the URL will default to `webp`. You can otherwise specify one of `jpg` or `png` to override this.
|
|
63
63
|
# @return [String, nil] the URL to the server's discovery splash image, or `nil` if the server doesn't have a discovery splash image.
|
|
64
64
|
def discovery_splash_url(format = 'webp')
|
|
65
|
-
|
|
65
|
+
REST.discovery_splash_url(@id, @discovery_splash_id, format) if @discovery_splash_id
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
end
|
|
@@ -32,7 +32,7 @@ module OnyxCord
|
|
|
32
32
|
# @param format [String] The URL will default to `webp`. You can otherwise specify one of `webp`, `jpg`, or `png` to override this.
|
|
33
33
|
# @return [String, nil] the URL to the icon image (nil if no image is set).
|
|
34
34
|
def icon_url(format = 'webp')
|
|
35
|
-
|
|
35
|
+
REST.team_icon_url(@id, @icon_id, format) if @icon_id
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
# A member that has been invited to a team.
|
|
@@ -92,12 +92,12 @@ module OnyxCord
|
|
|
92
92
|
# TODO: Maybe change this method again after discriminator removal ?
|
|
93
93
|
def avatar_url(format = nil)
|
|
94
94
|
unless @avatar_id
|
|
95
|
-
return
|
|
95
|
+
return REST::User.default_avatar(@discriminator, legacy: true) if @discriminator && @discriminator != '0'
|
|
96
96
|
|
|
97
|
-
return
|
|
97
|
+
return REST::User.default_avatar(@id)
|
|
98
98
|
end
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
REST::User.avatar_url(@id, @avatar_id, format)
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
# @return [Integer] the public flags on a user's account
|
|
@@ -114,7 +114,7 @@ module OnyxCord
|
|
|
114
114
|
# You can otherwise specify one of `webp`, `jpg`, `png`, or `gif` to override this.
|
|
115
115
|
# @return [String, nil] the URL to the banner image or nil if the user doesn't have one.
|
|
116
116
|
def banner_url(format = nil)
|
|
117
|
-
|
|
117
|
+
REST::User.banner_url(@id, banner_id, format) if banner_id
|
|
118
118
|
end
|
|
119
119
|
end
|
|
120
120
|
|
|
@@ -193,7 +193,7 @@ module OnyxCord
|
|
|
193
193
|
# @return [String, nil] the ID of this user's current banner, can be used to generate a banner URL.
|
|
194
194
|
# @see #banner_url
|
|
195
195
|
def banner_id
|
|
196
|
-
@banner_id ||= JSON.parse(
|
|
196
|
+
@banner_id ||= JSON.parse(REST::User.resolve(@bot.token, @id))['banner']
|
|
197
197
|
end
|
|
198
198
|
|
|
199
199
|
# Set the user's username
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require 'onyxcord/webhooks/builder'
|
|
4
4
|
require 'onyxcord/webhooks/view'
|
|
5
|
-
require 'onyxcord/message_payload'
|
|
5
|
+
require 'onyxcord/internal/message_payload'
|
|
6
6
|
|
|
7
7
|
module OnyxCord
|
|
8
8
|
# A webhook on a server channel
|
|
@@ -95,9 +95,9 @@ module OnyxCord
|
|
|
95
95
|
# @param reason [String] The reason the webhook is being deleted.
|
|
96
96
|
def delete(reason = nil)
|
|
97
97
|
if token?
|
|
98
|
-
|
|
98
|
+
REST::Webhook.token_delete_webhook(@token, @id, reason)
|
|
99
99
|
else
|
|
100
|
-
|
|
100
|
+
REST::Webhook.delete_webhook(@bot.token, @id, reason)
|
|
101
101
|
end
|
|
102
102
|
end
|
|
103
103
|
|
|
@@ -151,7 +151,7 @@ module OnyxCord
|
|
|
151
151
|
components ||= view
|
|
152
152
|
flags = OnyxCord::MessageComponents.apply_v2_flag(flags, components, force: has_components || components_v2)
|
|
153
153
|
|
|
154
|
-
resp =
|
|
154
|
+
resp = REST::Webhook.token_execute_webhook(@token, @id, wait, data[:content], data[:username], data[:avatar_url], data[:tts], data[:file], data[:embeds], data[:allowed_mentions], flags, components.to_a)
|
|
155
155
|
|
|
156
156
|
Message.new(JSON.parse(resp), @bot) if wait
|
|
157
157
|
end
|
|
@@ -161,7 +161,7 @@ module OnyxCord
|
|
|
161
161
|
def delete_message(message)
|
|
162
162
|
raise OnyxCord::Errors::UnauthorizedWebhook unless @token
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
REST::Webhook.token_delete_message(@token, @id, message.resolve_id)
|
|
165
165
|
end
|
|
166
166
|
|
|
167
167
|
# Edit a message created by this webhook.
|
|
@@ -191,16 +191,16 @@ module OnyxCord
|
|
|
191
191
|
|
|
192
192
|
edit_content = content == OnyxCord::MessagePayload::KEEP || !content.nil? ? content : data[:content]
|
|
193
193
|
edit_embeds = embeds == OnyxCord::MessagePayload::KEEP || !embeds.nil? ? embeds : data[:embeds]
|
|
194
|
-
resp =
|
|
194
|
+
resp = REST::Webhook.token_edit_message(@token, @id, message.resolve_id, edit_content, edit_embeds, data[:allowed_mentions], components.to_a, nil, flags)
|
|
195
195
|
Message.new(JSON.parse(resp), @bot)
|
|
196
196
|
end
|
|
197
197
|
|
|
198
198
|
# Utility function to get a webhook's avatar URL.
|
|
199
199
|
# @return [String] the URL to the avatar image
|
|
200
200
|
def avatar_url
|
|
201
|
-
return
|
|
201
|
+
return REST::User.default_avatar(@id) unless @avatar
|
|
202
202
|
|
|
203
|
-
|
|
203
|
+
REST::User.avatar_url(@id, @avatar)
|
|
204
204
|
end
|
|
205
205
|
|
|
206
206
|
# The `inspect` method is overwritten to give more useful output.
|
|
@@ -229,9 +229,9 @@ module OnyxCord
|
|
|
229
229
|
def update_webhook(new_data)
|
|
230
230
|
reason = new_data.delete(:reason)
|
|
231
231
|
data = JSON.parse(if token?
|
|
232
|
-
|
|
232
|
+
REST::Webhook.token_update_webhook(@token, @id, new_data, reason)
|
|
233
233
|
else
|
|
234
|
-
|
|
234
|
+
REST::Webhook.update_webhook(@bot.token, @id, new_data, reason)
|
|
235
235
|
end)
|
|
236
236
|
# Only update cache if API call worked
|
|
237
237
|
update_internal(data) if data['name']
|
|
@@ -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'
|