onyxcord 2.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/onyxcord/application_commands/command.rb +4 -97
- data/lib/onyxcord/application_commands/context.rb +4 -94
- data/lib/onyxcord/application_commands/option.rb +4 -75
- data/lib/onyxcord/application_commands/registry.rb +4 -45
- data/lib/onyxcord/application_commands.rb +8 -5
- data/lib/onyxcord/bot.rb +24 -1759
- data/lib/onyxcord/{cache.rb → cache/manager.rb} +16 -14
- data/lib/onyxcord/cache/stores/gateway.rb +272 -0
- data/lib/onyxcord/commands/bot/channels.rb +48 -0
- data/lib/onyxcord/commands/bot/execution.rb +174 -0
- data/lib/onyxcord/commands/bot/message_dispatch.rb +58 -0
- data/lib/onyxcord/commands/bot/permissions.rb +72 -0
- data/lib/onyxcord/commands/bot.rb +209 -0
- data/lib/onyxcord/commands/container.rb +21 -2
- data/lib/onyxcord/commands/parser.rb +30 -1
- data/lib/onyxcord/container.rb +16 -960
- data/lib/onyxcord/core/bot/application_commands.rb +210 -0
- data/lib/onyxcord/core/bot/awaits.rb +112 -0
- data/lib/onyxcord/core/bot/invites.rb +42 -0
- data/lib/onyxcord/core/bot/messaging.rb +161 -0
- data/lib/onyxcord/core/bot/oauth.rb +27 -0
- data/lib/onyxcord/core/bot/presence.rb +103 -0
- data/lib/onyxcord/core/bot/runtime.rb +183 -0
- data/lib/onyxcord/core/bot/voice.rb +69 -0
- data/lib/onyxcord/{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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# API calls for interactions — response management.
|
|
4
|
+
module OnyxCord::REST::Interaction
|
|
5
|
+
module_function
|
|
6
|
+
|
|
7
|
+
# Get the original response to an interaction.
|
|
8
|
+
# https://discord.com/developers/docs/interactions/slash-commands#get-original-interaction-response
|
|
9
|
+
def get_original_interaction_response(interaction_token, application_id)
|
|
10
|
+
OnyxCord::REST::Webhook.token_get_message(interaction_token, application_id, '@original')
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Edit the original response to an interaction.
|
|
14
|
+
# https://discord.com/developers/docs/interactions/slash-commands#edit-original-interaction-response
|
|
15
|
+
def edit_original_interaction_response(interaction_token, application_id, content = nil, embeds = nil, allowed_mentions = nil, components = nil, attachments = nil, flags = nil, poll = nil)
|
|
16
|
+
OnyxCord::REST::Webhook.token_edit_message(interaction_token, application_id, '@original', content, embeds, allowed_mentions, components, attachments, flags, poll)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Delete the original response to an interaction.
|
|
20
|
+
# https://discord.com/developers/docs/interactions/slash-commands#delete-original-interaction-response
|
|
21
|
+
def delete_original_interaction_response(interaction_token, application_id)
|
|
22
|
+
OnyxCord::REST::Webhook.token_delete_message(interaction_token, application_id, '@original')
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# API calls for Invite object
|
|
4
|
-
module OnyxCord::
|
|
4
|
+
module OnyxCord::REST::Invite
|
|
5
5
|
module_function
|
|
6
6
|
|
|
7
7
|
# Resolve an invite
|
|
8
8
|
# https://discord.com/developers/docs/resources/invite#get-invite
|
|
9
9
|
def resolve(token, invite_code, counts = true)
|
|
10
|
-
OnyxCord::
|
|
10
|
+
OnyxCord::REST.request(
|
|
11
11
|
:invite_code,
|
|
12
12
|
nil,
|
|
13
13
|
:get,
|
|
14
|
-
"#{OnyxCord::
|
|
14
|
+
"#{OnyxCord::REST.api_base}/invites/#{invite_code}#{'?with_counts=true' if counts}",
|
|
15
15
|
Authorization: token
|
|
16
16
|
)
|
|
17
17
|
end
|
|
@@ -19,11 +19,11 @@ module OnyxCord::API::Invite
|
|
|
19
19
|
# Delete an invite by code
|
|
20
20
|
# https://discord.com/developers/docs/resources/invite#delete-invite
|
|
21
21
|
def delete(token, code, reason = nil)
|
|
22
|
-
OnyxCord::
|
|
22
|
+
OnyxCord::REST.request(
|
|
23
23
|
:invites_code,
|
|
24
24
|
nil,
|
|
25
25
|
:delete,
|
|
26
|
-
"#{OnyxCord::
|
|
26
|
+
"#{OnyxCord::REST.api_base}/invites/#{code}",
|
|
27
27
|
Authorization: token,
|
|
28
28
|
'X-Audit-Log-Reason': reason
|
|
29
29
|
)
|
|
@@ -32,11 +32,11 @@ module OnyxCord::API::Invite
|
|
|
32
32
|
# Join a server using an invite
|
|
33
33
|
# https://discord.com/developers/docs/resources/invite#accept-invite
|
|
34
34
|
def accept(token, invite_code)
|
|
35
|
-
OnyxCord::
|
|
35
|
+
OnyxCord::REST.request(
|
|
36
36
|
:invite_code,
|
|
37
37
|
nil,
|
|
38
38
|
:post,
|
|
39
|
-
"#{OnyxCord::
|
|
39
|
+
"#{OnyxCord::REST.api_base}/invites/#{invite_code}",
|
|
40
40
|
nil,
|
|
41
41
|
Authorization: token
|
|
42
42
|
)
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OnyxCord::REST::Server
|
|
4
|
+
module_function
|
|
5
|
+
|
|
6
|
+
# Get server prune count
|
|
7
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-prune-count
|
|
8
|
+
def prune_count(token, server_id, days)
|
|
9
|
+
OnyxCord::REST.request(
|
|
10
|
+
:guilds_sid_prune,
|
|
11
|
+
server_id,
|
|
12
|
+
:get,
|
|
13
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/prune?days=#{days}",
|
|
14
|
+
Authorization: token
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Begin server prune
|
|
19
|
+
# https://discord.com/developers/docs/resources/guild#begin-guild-prune
|
|
20
|
+
def begin_prune(token, server_id, days, reason = nil)
|
|
21
|
+
OnyxCord::REST.request(
|
|
22
|
+
:guilds_sid_prune,
|
|
23
|
+
server_id,
|
|
24
|
+
:post,
|
|
25
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/prune",
|
|
26
|
+
{ days: days },
|
|
27
|
+
Authorization: token,
|
|
28
|
+
'X-Audit-Log-Reason': reason
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Get invites from server
|
|
33
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-invites
|
|
34
|
+
def invites(token, server_id)
|
|
35
|
+
OnyxCord::REST.request(
|
|
36
|
+
:guilds_sid_invites,
|
|
37
|
+
server_id,
|
|
38
|
+
:get,
|
|
39
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/invites",
|
|
40
|
+
Authorization: token
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Gets a server's audit logs
|
|
45
|
+
# https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log
|
|
46
|
+
def audit_logs(token, server_id, limit, user_id = nil, action_type = nil, before = nil)
|
|
47
|
+
OnyxCord::REST.request(
|
|
48
|
+
:guilds_sid_auditlogs,
|
|
49
|
+
server_id,
|
|
50
|
+
:get,
|
|
51
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/audit-logs?limit=#{limit}#{"&user_id=#{user_id}" if user_id}#{"&action_type=#{action_type}" if action_type}#{"&before=#{before}" if before}",
|
|
52
|
+
Authorization: token
|
|
53
|
+
)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Get server integrations
|
|
57
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-integrations
|
|
58
|
+
def integrations(token, server_id)
|
|
59
|
+
OnyxCord::REST.request(
|
|
60
|
+
:guilds_sid_integrations,
|
|
61
|
+
server_id,
|
|
62
|
+
:get,
|
|
63
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/integrations",
|
|
64
|
+
Authorization: token
|
|
65
|
+
)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Create a server integration
|
|
69
|
+
# https://discord.com/developers/docs/resources/guild#create-guild-integration
|
|
70
|
+
def create_integration(token, server_id, type, id, reason = nil)
|
|
71
|
+
OnyxCord::REST.request(
|
|
72
|
+
:guilds_sid_integrations,
|
|
73
|
+
server_id,
|
|
74
|
+
:post,
|
|
75
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/integrations",
|
|
76
|
+
{ type: type, id: id },
|
|
77
|
+
Authorization: token,
|
|
78
|
+
'X-Audit-Log-Reason': reason
|
|
79
|
+
)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Update integration from server
|
|
83
|
+
# https://discord.com/developers/docs/resources/guild#modify-guild-integration
|
|
84
|
+
def update_integration(token, server_id, integration_id, expire_behavior, expire_grace_period, enable_emoticons)
|
|
85
|
+
OnyxCord::REST.request(
|
|
86
|
+
:guilds_sid_integrations_iid,
|
|
87
|
+
server_id,
|
|
88
|
+
:patch,
|
|
89
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/integrations/#{integration_id}",
|
|
90
|
+
{ expire_behavior: expire_behavior, expire_grace_period: expire_grace_period, enable_emoticons: enable_emoticons }.to_json,
|
|
91
|
+
Authorization: token,
|
|
92
|
+
content_type: :json
|
|
93
|
+
)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Delete a server integration
|
|
97
|
+
# https://discord.com/developers/docs/resources/guild#delete-guild-integration
|
|
98
|
+
def delete_integration(token, server_id, integration_id, reason = nil)
|
|
99
|
+
OnyxCord::REST.request(
|
|
100
|
+
:guilds_sid_integrations_iid,
|
|
101
|
+
server_id,
|
|
102
|
+
:delete,
|
|
103
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/integrations/#{integration_id}",
|
|
104
|
+
Authorization: token,
|
|
105
|
+
'X-Audit-Log-Reason': reason
|
|
106
|
+
)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Sync an integration
|
|
110
|
+
# https://discord.com/developers/docs/resources/guild#sync-guild-integration
|
|
111
|
+
def sync_integration(token, server_id, integration_id)
|
|
112
|
+
OnyxCord::REST.request(
|
|
113
|
+
:guilds_sid_integrations_iid_sync,
|
|
114
|
+
server_id,
|
|
115
|
+
:post,
|
|
116
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/integrations/#{integration_id}/sync",
|
|
117
|
+
nil,
|
|
118
|
+
Authorization: token
|
|
119
|
+
)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Retrieves a server's widget information
|
|
123
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-widget
|
|
124
|
+
def widget(token, server_id)
|
|
125
|
+
OnyxCord::REST.request(
|
|
126
|
+
:guilds_sid_embed,
|
|
127
|
+
server_id,
|
|
128
|
+
:get,
|
|
129
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/widget",
|
|
130
|
+
Authorization: token
|
|
131
|
+
)
|
|
132
|
+
end
|
|
133
|
+
alias embed widget
|
|
134
|
+
|
|
135
|
+
# Modify a server's widget settings
|
|
136
|
+
# https://discord.com/developers/docs/resources/guild#modify-guild-widget
|
|
137
|
+
def modify_widget(token, server_id, enabled, channel_id, reason = nil)
|
|
138
|
+
OnyxCord::REST.request(
|
|
139
|
+
:guilds_sid_embed,
|
|
140
|
+
server_id,
|
|
141
|
+
:patch,
|
|
142
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/widget",
|
|
143
|
+
{ enabled: enabled, channel_id: channel_id }.to_json,
|
|
144
|
+
Authorization: token,
|
|
145
|
+
'X-Audit-Log-Reason': reason,
|
|
146
|
+
content_type: :json
|
|
147
|
+
)
|
|
148
|
+
end
|
|
149
|
+
alias modify_embed modify_widget
|
|
150
|
+
|
|
151
|
+
# Available voice regions for this server
|
|
152
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-voice-regions
|
|
153
|
+
def regions(token, server_id)
|
|
154
|
+
OnyxCord::REST.request(
|
|
155
|
+
:guilds_sid_regions,
|
|
156
|
+
server_id,
|
|
157
|
+
:get,
|
|
158
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/regions",
|
|
159
|
+
Authorization: token
|
|
160
|
+
)
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# Get server webhooks
|
|
164
|
+
# https://discord.com/developers/docs/resources/webhook#get-guild-webhooks
|
|
165
|
+
def webhooks(token, server_id)
|
|
166
|
+
OnyxCord::REST.request(
|
|
167
|
+
:guilds_sid_webhooks,
|
|
168
|
+
server_id,
|
|
169
|
+
:get,
|
|
170
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/webhooks",
|
|
171
|
+
Authorization: token
|
|
172
|
+
)
|
|
173
|
+
end
|
|
174
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OnyxCord::REST::Server
|
|
4
|
+
module_function
|
|
5
|
+
|
|
6
|
+
# Make an member avatar URL from the server, user and avatar IDs
|
|
7
|
+
def avatar_url(server_id, user_id, avatar_id, format = nil)
|
|
8
|
+
format ||= if avatar_id.start_with?('a_')
|
|
9
|
+
'gif'
|
|
10
|
+
else
|
|
11
|
+
'webp'
|
|
12
|
+
end
|
|
13
|
+
"#{OnyxCord::REST.cdn_url}/guilds/#{server_id}/users/#{user_id}/avatars/#{avatar_id}.#{format}"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Make a banner URL from the server, user and banner IDs
|
|
17
|
+
def banner_url(server_id, user_id, banner_id, format = nil)
|
|
18
|
+
format ||= if banner_id.start_with?('a_')
|
|
19
|
+
'gif'
|
|
20
|
+
else
|
|
21
|
+
'webp'
|
|
22
|
+
end
|
|
23
|
+
"#{OnyxCord::REST.cdn_url}/guilds/#{server_id}/users/#{user_id}/banners/#{banner_id}.#{format}"
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OnyxCord::REST::Server
|
|
4
|
+
module_function
|
|
5
|
+
|
|
6
|
+
# Get a server's banned users
|
|
7
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-bans
|
|
8
|
+
def bans(token, server_id, limit = nil, before = nil, after = nil)
|
|
9
|
+
query_string = URI.encode_www_form({ limit: limit, before: before, after: after }.compact)
|
|
10
|
+
OnyxCord::REST.request(
|
|
11
|
+
:guilds_sid_bans,
|
|
12
|
+
server_id,
|
|
13
|
+
:get,
|
|
14
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/bans?#{query_string}",
|
|
15
|
+
Authorization: token
|
|
16
|
+
)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# @deprecated Please use {ban_user!} instead.
|
|
20
|
+
# https://discord.com/developers/docs/resources/guild#create-guild-ban
|
|
21
|
+
def ban_user(token, server_id, user_id, message_days, reason = nil)
|
|
22
|
+
ban_user!(token, server_id, user_id, message_days * 86_400, reason)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Ban a user from a server and delete their messages up to a given amount of time.
|
|
26
|
+
# https://discord.com/developers/docs/resources/guild#create-guild-ban
|
|
27
|
+
def ban_user!(token, server_id, user_id, message_seconds, reason = nil)
|
|
28
|
+
OnyxCord::REST.request(
|
|
29
|
+
:guilds_sid_bans_uid,
|
|
30
|
+
server_id,
|
|
31
|
+
:put,
|
|
32
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/bans/#{user_id}",
|
|
33
|
+
{ delete_message_seconds: message_seconds }.to_json,
|
|
34
|
+
Authorization: token,
|
|
35
|
+
content_type: :json,
|
|
36
|
+
'X-Audit-Log-Reason': reason
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Unban a user from a server
|
|
41
|
+
# https://discord.com/developers/docs/resources/guild#remove-guild-ban
|
|
42
|
+
def unban_user(token, server_id, user_id, reason = nil)
|
|
43
|
+
OnyxCord::REST.request(
|
|
44
|
+
:guilds_sid_bans_uid,
|
|
45
|
+
server_id,
|
|
46
|
+
:delete,
|
|
47
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/bans/#{user_id}",
|
|
48
|
+
Authorization: token,
|
|
49
|
+
'X-Audit-Log-Reason': reason
|
|
50
|
+
)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Ban multiple users in one go
|
|
54
|
+
# https://discord.com/developers/docs/resources/guild#bulk-guild-ban
|
|
55
|
+
def bulk_ban(token, server_id, users, message_seconds, reason = nil)
|
|
56
|
+
OnyxCord::REST.request(
|
|
57
|
+
:guilds_sid_bulk_bans,
|
|
58
|
+
server_id,
|
|
59
|
+
:post,
|
|
60
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/bulk-ban",
|
|
61
|
+
{ user_ids: users, delete_message_seconds: message_seconds }.compact.to_json,
|
|
62
|
+
content_type: :json,
|
|
63
|
+
Authorization: token,
|
|
64
|
+
'X-Audit-Log-Reason': reason
|
|
65
|
+
)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OnyxCord::REST::Server
|
|
4
|
+
module_function
|
|
5
|
+
|
|
6
|
+
# Get a server's data
|
|
7
|
+
# https://discord.com/developers/docs/resources/guild#get-guild
|
|
8
|
+
def resolve(token, server_id, with_counts = nil)
|
|
9
|
+
OnyxCord::REST.request(
|
|
10
|
+
:guilds_sid,
|
|
11
|
+
server_id,
|
|
12
|
+
:get,
|
|
13
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}#{'?with_counts=true' if with_counts}",
|
|
14
|
+
Authorization: token
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Update a server
|
|
19
|
+
# https://discord.com/developers/docs/resources/guild#modify-guild
|
|
20
|
+
def update(token, server_id, name, region, icon, afk_channel_id, afk_timeout, splash, default_message_notifications, verification_level, explicit_content_filter, system_channel_id, reason = nil)
|
|
21
|
+
OnyxCord::REST.request(
|
|
22
|
+
:guilds_sid,
|
|
23
|
+
server_id,
|
|
24
|
+
:patch,
|
|
25
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}",
|
|
26
|
+
{ name: name, region: region, icon: icon, afk_channel_id: afk_channel_id, afk_timeout: afk_timeout, splash: splash, default_message_notifications: default_message_notifications, verification_level: verification_level, explicit_content_filter: explicit_content_filter, system_channel_id: system_channel_id }.to_json,
|
|
27
|
+
Authorization: token,
|
|
28
|
+
content_type: :json,
|
|
29
|
+
'X-Audit-Log-Reason': reason
|
|
30
|
+
)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Update the properties of a guild.
|
|
34
|
+
# https://discord.com/developers/docs/resources/guild#modify-guild
|
|
35
|
+
def update!(token, server_id, name: :undef, region: :undef, verification_level: :undef, default_message_notifications: :undef, explicit_content_filter: :undef, afk_channel_id: :undef, afk_timeout: :undef, icon: :undef, splash: :undef, discovery_splash: :undef, banner: :undef, system_channel_id: :undef, system_channel_flags: :undef, rules_channel_id: :undef, public_updates_channel_id: :undef, preferred_locale: :undef, features: :undef, description: :undef, premium_progress_bar_enabled: :undef, safety_alerts_channel_id: :undef, reason: nil)
|
|
36
|
+
OnyxCord::REST.request(
|
|
37
|
+
:guilds_sid,
|
|
38
|
+
server_id,
|
|
39
|
+
:patch,
|
|
40
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}",
|
|
41
|
+
{ name:, region:, verification_level:, default_message_notifications:, explicit_content_filter:, afk_channel_id:, afk_timeout:, icon:, splash:, discovery_splash:, banner:, system_channel_id:, system_channel_flags:, rules_channel_id:, public_updates_channel_id:, preferred_locale:, features:, description:, premium_progress_bar_enabled:, safety_alerts_channel_id: }.reject { |_, value| value == :undef }.to_json,
|
|
42
|
+
Authorization: token,
|
|
43
|
+
content_type: :json,
|
|
44
|
+
'X-Audit-Log-Reason': reason
|
|
45
|
+
)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Modify the incident actions for a server.
|
|
49
|
+
# https://discord.com/developers/docs/resources/guild#modify-guild-incident-actions
|
|
50
|
+
def update_incident_actions(token, server_id, invites_disabled_until: :undef, dms_disabled_until: :undef, reason: nil)
|
|
51
|
+
OnyxCord::REST.request(
|
|
52
|
+
:guilds_sid_incidents_actions,
|
|
53
|
+
server_id,
|
|
54
|
+
:put,
|
|
55
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/incident-actions",
|
|
56
|
+
{ invites_disabled_until:, dms_disabled_until: }.reject { |_, value| value == :undef }.to_json,
|
|
57
|
+
Authorization: token,
|
|
58
|
+
content_type: :json,
|
|
59
|
+
'X-Audit-Log-Reason': reason
|
|
60
|
+
)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Modify the properties of a widget for a server.
|
|
64
|
+
# https://docs.discord.com/developers/resources/guild#modify-guild-widget
|
|
65
|
+
def update_widget(token, server_id, enabled: :undef, channel_id: :undef, reason: nil)
|
|
66
|
+
OnyxCord::REST.request(
|
|
67
|
+
:guilds_sid_widget,
|
|
68
|
+
server_id,
|
|
69
|
+
:patch,
|
|
70
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/widget",
|
|
71
|
+
{ enabled:, channel_id: }.reject { |_, value| value == :undef }.to_json,
|
|
72
|
+
content_type: :json,
|
|
73
|
+
Authorization: token,
|
|
74
|
+
'X-Audit-Log-Reason': reason
|
|
75
|
+
)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OnyxCord::REST::Server
|
|
4
|
+
module_function
|
|
5
|
+
|
|
6
|
+
# Get a server's channels list
|
|
7
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-channels
|
|
8
|
+
def channels(token, server_id)
|
|
9
|
+
OnyxCord::REST.request(
|
|
10
|
+
:guilds_sid_channels,
|
|
11
|
+
server_id,
|
|
12
|
+
:get,
|
|
13
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/channels",
|
|
14
|
+
Authorization: token
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Create a channel
|
|
19
|
+
# https://discord.com/developers/docs/resources/guild#create-guild-channel
|
|
20
|
+
def create_channel(token, server_id, name, type, topic, bitrate, user_limit, permission_overwrites, parent_id, nsfw, rate_limit_per_user, position, reason = nil)
|
|
21
|
+
OnyxCord::REST.request(
|
|
22
|
+
:guilds_sid_channels,
|
|
23
|
+
server_id,
|
|
24
|
+
:post,
|
|
25
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/channels",
|
|
26
|
+
{ name: name, type: type, topic: topic, bitrate: bitrate, user_limit: user_limit, permission_overwrites: permission_overwrites, parent_id: parent_id, nsfw: nsfw, rate_limit_per_user: rate_limit_per_user, position: position }.to_json,
|
|
27
|
+
Authorization: token,
|
|
28
|
+
content_type: :json,
|
|
29
|
+
'X-Audit-Log-Reason': reason
|
|
30
|
+
)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Get the preview of a server.
|
|
34
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-preview
|
|
35
|
+
def preview(token, server_id)
|
|
36
|
+
OnyxCord::REST.request(
|
|
37
|
+
:guilds_sid_preview,
|
|
38
|
+
server_id,
|
|
39
|
+
:get,
|
|
40
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/preview",
|
|
41
|
+
Authorization: token
|
|
42
|
+
)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Update a channels position
|
|
46
|
+
# https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions
|
|
47
|
+
def update_channel_positions(token, server_id, positions)
|
|
48
|
+
OnyxCord::REST.request(
|
|
49
|
+
:guilds_sid_channels,
|
|
50
|
+
server_id,
|
|
51
|
+
:patch,
|
|
52
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/channels",
|
|
53
|
+
positions.to_json,
|
|
54
|
+
Authorization: token,
|
|
55
|
+
content_type: :json
|
|
56
|
+
)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OnyxCord::REST::Server
|
|
4
|
+
module_function
|
|
5
|
+
|
|
6
|
+
# Adds a custom emoji.
|
|
7
|
+
# https://discord.com/developers/docs/resources/emoji#create-guild-emoji
|
|
8
|
+
def add_emoji(token, server_id, image, name, roles = [], reason = nil)
|
|
9
|
+
OnyxCord::REST.request(
|
|
10
|
+
:guilds_sid_emojis,
|
|
11
|
+
server_id,
|
|
12
|
+
:post,
|
|
13
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/emojis",
|
|
14
|
+
{ image: image, name: name, roles: roles }.to_json,
|
|
15
|
+
Authorization: token,
|
|
16
|
+
content_type: :json,
|
|
17
|
+
'X-Audit-Log-Reason': reason
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Changes an emoji name and/or roles.
|
|
22
|
+
# https://discord.com/developers/docs/resources/emoji#modify-guild-emoji
|
|
23
|
+
def edit_emoji(token, server_id, emoji_id, name, roles = nil, reason = nil)
|
|
24
|
+
OnyxCord::REST.request(
|
|
25
|
+
:guilds_sid_emojis_eid,
|
|
26
|
+
server_id,
|
|
27
|
+
:patch,
|
|
28
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/emojis/#{emoji_id}",
|
|
29
|
+
{ name: name, roles: roles }.to_json,
|
|
30
|
+
Authorization: token,
|
|
31
|
+
content_type: :json,
|
|
32
|
+
'X-Audit-Log-Reason': reason
|
|
33
|
+
)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Deletes a custom emoji
|
|
37
|
+
# https://discord.com/developers/docs/resources/emoji#delete-guild-emoji
|
|
38
|
+
def delete_emoji(token, server_id, emoji_id, reason = nil)
|
|
39
|
+
OnyxCord::REST.request(
|
|
40
|
+
:guilds_sid_emojis_eid,
|
|
41
|
+
server_id,
|
|
42
|
+
:delete,
|
|
43
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/emojis/#{emoji_id}",
|
|
44
|
+
Authorization: token,
|
|
45
|
+
'X-Audit-Log-Reason': reason
|
|
46
|
+
)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OnyxCord::REST::Server
|
|
4
|
+
module_function
|
|
5
|
+
|
|
6
|
+
# Get a member's data
|
|
7
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-member
|
|
8
|
+
def resolve_member(token, server_id, user_id)
|
|
9
|
+
OnyxCord::REST.request(
|
|
10
|
+
:guilds_sid_members_uid,
|
|
11
|
+
server_id,
|
|
12
|
+
:get,
|
|
13
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/members/#{user_id}",
|
|
14
|
+
Authorization: token
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Gets members from the server
|
|
19
|
+
# https://discord.com/developers/docs/resources/guild#list-guild-members
|
|
20
|
+
def resolve_members(token, server_id, limit, after = nil)
|
|
21
|
+
query_string = URI.encode_www_form({ limit: limit, after: after }.compact)
|
|
22
|
+
OnyxCord::REST.request(
|
|
23
|
+
:guilds_sid_members,
|
|
24
|
+
server_id,
|
|
25
|
+
:get,
|
|
26
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/members?#{query_string}",
|
|
27
|
+
Authorization: token
|
|
28
|
+
)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Search for a guild member
|
|
32
|
+
# https://discord.com/developers/docs/resources/guild#search-guild-members
|
|
33
|
+
def search_guild_members(token, server_id, query, limit)
|
|
34
|
+
query_string = URI.encode_www_form({ query: query, limit: limit }.compact)
|
|
35
|
+
OnyxCord::REST.request(
|
|
36
|
+
:guilds_sid_members,
|
|
37
|
+
server_id,
|
|
38
|
+
:get,
|
|
39
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/members/search?#{query_string}",
|
|
40
|
+
Authorization: token
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Update a user properties
|
|
45
|
+
# https://discord.com/developers/docs/resources/guild#modify-guild-member
|
|
46
|
+
def update_member(token, server_id, user_id, nick: :undef, roles: :undef, mute: :undef, deaf: :undef, channel_id: :undef,
|
|
47
|
+
communication_disabled_until: :undef, flags: :undef, reason: nil)
|
|
48
|
+
OnyxCord::REST.request(
|
|
49
|
+
:guilds_sid_members_uid,
|
|
50
|
+
server_id,
|
|
51
|
+
:patch,
|
|
52
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/members/#{user_id}", {
|
|
53
|
+
roles: roles,
|
|
54
|
+
nick: nick,
|
|
55
|
+
mute: mute,
|
|
56
|
+
deaf: deaf,
|
|
57
|
+
channel_id: channel_id,
|
|
58
|
+
communication_disabled_until: communication_disabled_until,
|
|
59
|
+
flags: flags
|
|
60
|
+
}.reject { |_, v| v == :undef }.to_json,
|
|
61
|
+
Authorization: token,
|
|
62
|
+
content_type: :json,
|
|
63
|
+
'X-Audit-Log-Reason': reason
|
|
64
|
+
)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Update the current member's properties.
|
|
68
|
+
# https://discord.com/developers/docs/resources/guild#modify-current-member
|
|
69
|
+
def update_current_member(token, server_id, nick = :undef, reason = nil, bio = :undef, banner = :undef, avatar = :undef)
|
|
70
|
+
OnyxCord::REST.request(
|
|
71
|
+
:guilds_sid_members_me,
|
|
72
|
+
server_id,
|
|
73
|
+
:patch,
|
|
74
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/members/@me",
|
|
75
|
+
{ nick: nick, bio: bio, banner: banner, avatar: avatar }.reject { |_, v| v == :undef }.to_json,
|
|
76
|
+
Authorization: token,
|
|
77
|
+
content_type: :json,
|
|
78
|
+
'X-Audit-Log-Reason': reason
|
|
79
|
+
)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Remove user from server
|
|
83
|
+
# https://discord.com/developers/docs/resources/guild#remove-guild-member
|
|
84
|
+
def remove_member(token, server_id, user_id, reason = nil)
|
|
85
|
+
OnyxCord::REST.request(
|
|
86
|
+
:guilds_sid_members_uid,
|
|
87
|
+
server_id,
|
|
88
|
+
:delete,
|
|
89
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/members/#{user_id}",
|
|
90
|
+
Authorization: token,
|
|
91
|
+
content_type: :json,
|
|
92
|
+
'X-Audit-Log-Reason': reason
|
|
93
|
+
)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Adds a member to a server with an OAuth2 Bearer token that has been granted `guilds.join`
|
|
97
|
+
# https://discord.com/developers/docs/resources/guild#add-guild-member
|
|
98
|
+
def add_member(token, server_id, user_id, access_token, nick = nil, roles = [], mute = false, deaf = false)
|
|
99
|
+
OnyxCord::REST.request(
|
|
100
|
+
:guilds_sid_members_uid,
|
|
101
|
+
server_id,
|
|
102
|
+
:put,
|
|
103
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/members/#{user_id}",
|
|
104
|
+
{ access_token: access_token, nick: nick, roles: roles, mute: mute, deaf: deaf }.to_json,
|
|
105
|
+
content_type: :json,
|
|
106
|
+
Authorization: token
|
|
107
|
+
)
|
|
108
|
+
end
|
|
109
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OnyxCord::REST::Server
|
|
4
|
+
module_function
|
|
5
|
+
|
|
6
|
+
# Query and filter the messages that have been sent in a server.
|
|
7
|
+
# https://discord.com/developers/docs/resources/message#search-guild-messages
|
|
8
|
+
def search_messages(token, server_id, limit: 25, offset: nil, max_id: nil, min_id: nil, slop: nil, content: nil, channel_id: nil, author_type: nil, author_id: nil, mentions: nil, mentions_role_id: nil, mention_everyone: nil, replied_to_user_id: nil, replied_to_message_id: nil, pinned: nil, has: nil, embed_type: nil, embed_provider: nil, link_hostname: nil, attachment_filename: nil, attachment_extension: nil, sort_by: nil, sort_order: nil, include_nsfw: nil)
|
|
9
|
+
query = URI.encode_www_form({ limit:, offset:, max_id:, min_id:, slop:, content:, channel_id:, author_type:, author_id:, mentions:, mentions_role_id:, mention_everyone:, replied_to_user_id:, replied_to_message_id:, pinned:, has:, embed_type:, embed_provider:, link_hostname:, attachment_filename:, attachment_extension:, sort_by:, sort_order:, include_nsfw: }.compact)
|
|
10
|
+
|
|
11
|
+
OnyxCord::REST.request(
|
|
12
|
+
:guilds_gid_messages_search,
|
|
13
|
+
server_id,
|
|
14
|
+
:get,
|
|
15
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/messages/search?#{query}",
|
|
16
|
+
Authorization: token
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
end
|