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,156 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OnyxCord::REST::Server
|
|
4
|
+
module_function
|
|
5
|
+
|
|
6
|
+
# Get server roles
|
|
7
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-roles
|
|
8
|
+
def roles(token, server_id)
|
|
9
|
+
OnyxCord::REST.request(
|
|
10
|
+
:guilds_sid_roles,
|
|
11
|
+
server_id,
|
|
12
|
+
:get,
|
|
13
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/roles",
|
|
14
|
+
Authorization: token
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Get a single role
|
|
19
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-role
|
|
20
|
+
def role(token, server_id, role_id)
|
|
21
|
+
OnyxCord::REST.request(
|
|
22
|
+
:guilds_sid_roles_rid,
|
|
23
|
+
server_id,
|
|
24
|
+
:get,
|
|
25
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/roles/#{role_id}",
|
|
26
|
+
Authorization: token
|
|
27
|
+
)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Create a role (parameters such as name and colour if not set can be set by update_role afterwards)
|
|
31
|
+
# Permissions are the Discord defaults; allowed: invite creation, reading/sending messages,
|
|
32
|
+
# sending TTS messages, embedding links, sending files, reading the history, mentioning everybody,
|
|
33
|
+
# connecting to voice, speaking and voice activity (push-to-talk isn't mandatory)
|
|
34
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-roles
|
|
35
|
+
def create_role(token, server_id, name, colour, hoist, mentionable, packed_permissions, reason = nil, colours = nil, icon = nil, unicode_emoji = nil)
|
|
36
|
+
OnyxCord::REST.request(
|
|
37
|
+
:guilds_sid_roles,
|
|
38
|
+
server_id,
|
|
39
|
+
:post,
|
|
40
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/roles",
|
|
41
|
+
{ color: colour, name: name, hoist: hoist, mentionable: mentionable, permissions: packed_permissions, colors: colours, icon: icon, unicode_emoji: unicode_emoji }.compact.to_json,
|
|
42
|
+
Authorization: token,
|
|
43
|
+
content_type: :json,
|
|
44
|
+
'X-Audit-Log-Reason': reason
|
|
45
|
+
)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Update a role
|
|
49
|
+
# Permissions are the Discord defaults; allowed: invite creation, reading/sending messages,
|
|
50
|
+
# sending TTS messages, embedding links, sending files, reading the history, mentioning everybody,
|
|
51
|
+
# connecting to voice, speaking and voice activity (push-to-talk isn't mandatory)
|
|
52
|
+
# https://discord.com/developers/docs/resources/guild#batch-modify-guild-role
|
|
53
|
+
# @param icon [:undef, File]
|
|
54
|
+
def update_role(token, server_id, role_id, name, colour, hoist = false, mentionable = false, packed_permissions = 104_324_161, reason = nil, icon = :undef, unicode_emoji = :undef, colours = :undef)
|
|
55
|
+
data = { color: colour, name: name, hoist: hoist, mentionable: mentionable, permissions: packed_permissions, colors: colours, unicode_emoji: unicode_emoji }
|
|
56
|
+
|
|
57
|
+
if icon != :undef && icon
|
|
58
|
+
data[:icon] = OnyxCord.encode64(icon)
|
|
59
|
+
elsif icon.nil?
|
|
60
|
+
data[:icon] = nil
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
OnyxCord::REST.request(
|
|
64
|
+
:guilds_sid_roles_rid,
|
|
65
|
+
server_id,
|
|
66
|
+
:patch,
|
|
67
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/roles/#{role_id}",
|
|
68
|
+
data.reject { |_, value| value == :undef }.to_json,
|
|
69
|
+
Authorization: token,
|
|
70
|
+
content_type: :json,
|
|
71
|
+
'X-Audit-Log-Reason': reason
|
|
72
|
+
)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Modify the properties of a role.
|
|
76
|
+
# https://docs.discord.com/developers/resources/guild#modify-guild-role
|
|
77
|
+
def update_role!(token, server_id, role_id, name: :undef, permissions: :undef, colors: :undef, hoist: :undef, icon: :undef, unicode_emoji: :undef, mentionable: :undef, reason: nil)
|
|
78
|
+
OnyxCord::REST.request(
|
|
79
|
+
:guilds_sid_roles_rid,
|
|
80
|
+
server_id,
|
|
81
|
+
:patch,
|
|
82
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/roles/#{role_id}",
|
|
83
|
+
{ name:, permissions:, colors:, hoist:, icon:, unicode_emoji:, mentionable: }.reject { |_, value| value == :undef }.to_json,
|
|
84
|
+
content_type: :json,
|
|
85
|
+
Authorization: token,
|
|
86
|
+
'X-Audit-Log-Reason': reason
|
|
87
|
+
)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Update role positions
|
|
91
|
+
# https://discord.com/developers/docs/resources/guild#modify-guild-role-positions
|
|
92
|
+
def update_role_positions(token, server_id, roles, reason = nil)
|
|
93
|
+
OnyxCord::REST.request(
|
|
94
|
+
:guilds_sid_roles,
|
|
95
|
+
server_id,
|
|
96
|
+
:patch,
|
|
97
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/roles",
|
|
98
|
+
roles.to_json,
|
|
99
|
+
Authorization: token,
|
|
100
|
+
content_type: :json,
|
|
101
|
+
'X-Audit-Log-Reason': reason
|
|
102
|
+
)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# Delete a role
|
|
106
|
+
# https://discord.com/developers/docs/resources/guild#delete-guild-role
|
|
107
|
+
def delete_role(token, server_id, role_id, reason = nil)
|
|
108
|
+
OnyxCord::REST.request(
|
|
109
|
+
:guilds_sid_roles_rid,
|
|
110
|
+
server_id,
|
|
111
|
+
:delete,
|
|
112
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/roles/#{role_id}",
|
|
113
|
+
Authorization: token,
|
|
114
|
+
'X-Audit-Log-Reason': reason
|
|
115
|
+
)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Adds a single role to a member
|
|
119
|
+
# https://discord.com/developers/docs/resources/guild#add-guild-member-role
|
|
120
|
+
def add_member_role(token, server_id, user_id, role_id, reason = nil)
|
|
121
|
+
OnyxCord::REST.request(
|
|
122
|
+
:guilds_sid_members_uid_roles_rid,
|
|
123
|
+
server_id,
|
|
124
|
+
:put,
|
|
125
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/members/#{user_id}/roles/#{role_id}",
|
|
126
|
+
nil,
|
|
127
|
+
Authorization: token,
|
|
128
|
+
'X-Audit-Log-Reason': reason
|
|
129
|
+
)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# Removes a single role from a member
|
|
133
|
+
# https://discord.com/developers/docs/resources/guild#remove-guild-member-role
|
|
134
|
+
def remove_member_role(token, server_id, user_id, role_id, reason = nil)
|
|
135
|
+
OnyxCord::REST.request(
|
|
136
|
+
:guilds_sid_members_uid_roles_rid,
|
|
137
|
+
server_id,
|
|
138
|
+
:delete,
|
|
139
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/members/#{user_id}/roles/#{role_id}",
|
|
140
|
+
Authorization: token,
|
|
141
|
+
'X-Audit-Log-Reason': reason
|
|
142
|
+
)
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# Get the amount of members who have a role
|
|
146
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-roles-members-count
|
|
147
|
+
def role_member_counts(token, server_id)
|
|
148
|
+
OnyxCord::REST.request(
|
|
149
|
+
:guilds_sid_roles_member_counts,
|
|
150
|
+
server_id,
|
|
151
|
+
:get,
|
|
152
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/roles/member-counts",
|
|
153
|
+
Authorization: token
|
|
154
|
+
)
|
|
155
|
+
end
|
|
156
|
+
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OnyxCord::REST::Server
|
|
4
|
+
module_function
|
|
5
|
+
|
|
6
|
+
# Get a list of all of the active scheduled events in the server.
|
|
7
|
+
# https://discord.com/developers/docs/resources/guild-scheduled-event#list-scheduled-events-for-guild
|
|
8
|
+
def list_scheduled_events(token, server_id, with_user_count: false)
|
|
9
|
+
OnyxCord::REST.request(
|
|
10
|
+
:guilds_sid_scheduled_events,
|
|
11
|
+
server_id,
|
|
12
|
+
:get,
|
|
13
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/scheduled-events?with_user_count=#{with_user_count}",
|
|
14
|
+
Authorization: token
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Get a single scheduled event in the server.
|
|
19
|
+
# https://discord.com/developers/docs/resources/guild-scheduled-event#get-guild-scheduled-event
|
|
20
|
+
def get_scheduled_event(token, server_id, scheduled_event_id, with_user_count: false)
|
|
21
|
+
OnyxCord::REST.request(
|
|
22
|
+
:guilds_sid_scheduled_events_seid,
|
|
23
|
+
server_id,
|
|
24
|
+
:get,
|
|
25
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/scheduled-events/#{scheduled_event_id}?with_user_count=#{with_user_count}",
|
|
26
|
+
Authorization: token
|
|
27
|
+
)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Get a list of subscribers for a scheduled event in the server.
|
|
31
|
+
# https://discord.com/developers/docs/resources/guild-scheduled-event#get-guild-scheduled-event-users
|
|
32
|
+
def get_scheduled_event_users(token, server_id, scheduled_event_id, limit: 100, with_member: false, before: nil, after: nil)
|
|
33
|
+
query = URI.encode_www_form({ limit:, with_member:, before:, after: }.compact)
|
|
34
|
+
|
|
35
|
+
OnyxCord::REST.request(
|
|
36
|
+
:guilds_sid_scheduled_events_seid_users,
|
|
37
|
+
server_id,
|
|
38
|
+
:get,
|
|
39
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/scheduled-events/#{scheduled_event_id}/users?#{query}",
|
|
40
|
+
Authorization: token
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Create a scheduled event in the server.
|
|
45
|
+
# https://discord.com/developers/docs/resources/guild-scheduled-event#create-guild-scheduled-event
|
|
46
|
+
def create_scheduled_event(token, server_id, name:, privacy_level:, scheduled_start_time:, entity_type:, channel_id: nil, entity_metadata: nil, scheduled_end_time: nil, description: nil, image: nil, recurrence_rule: nil, reason: nil)
|
|
47
|
+
OnyxCord::REST.request(
|
|
48
|
+
:guilds_sid_scheduled_events,
|
|
49
|
+
server_id,
|
|
50
|
+
:post,
|
|
51
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/scheduled-events",
|
|
52
|
+
{ name:, privacy_level:, scheduled_start_time:, entity_type:, channel_id:, entity_metadata:, scheduled_end_time:, description:, image:, recurrence_rule: }.compact.to_json,
|
|
53
|
+
Authorization: token,
|
|
54
|
+
content_type: :json,
|
|
55
|
+
'X-Audit-Log-Reason': reason
|
|
56
|
+
)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Update a scheduled event in the server.
|
|
60
|
+
# https://discord.com/developers/docs/resources/guild-scheduled-event#modify-guild-scheduled-event
|
|
61
|
+
def update_scheduled_event(token, server_id, scheduled_event_id, name: :undef, image: :undef, status: :undef, entity_type: :undef, privacy_level: :undef, scheduled_end_time: :undef, scheduled_start_time: :undef, channel_id: :undef, description: :undef, entity_metadata: :undef, recurrence_rule: :undef, reason: nil)
|
|
62
|
+
OnyxCord::REST.request(
|
|
63
|
+
:guilds_sid_scheduled_events_seid,
|
|
64
|
+
server_id,
|
|
65
|
+
:patch,
|
|
66
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/scheduled-events/#{scheduled_event_id}",
|
|
67
|
+
{ name:, image:, status:, entity_type:, privacy_level:, scheduled_end_time:, scheduled_start_time:, channel_id:, description:, entity_metadata:, recurrence_rule: }.reject { |_, value| value == :undef }.to_json,
|
|
68
|
+
Authorization: token,
|
|
69
|
+
content_type: :json,
|
|
70
|
+
'X-Audit-Log-Reason': reason
|
|
71
|
+
)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Delete a scheduled event in the server.
|
|
75
|
+
# https://discord.com/developers/docs/resources/guild-scheduled-event#delete-guild-scheduled-event
|
|
76
|
+
def delete_scheduled_event(token, server_id, scheduled_event_id, reason: nil)
|
|
77
|
+
OnyxCord::REST.request(
|
|
78
|
+
:guilds_sid_scheduled_events_seid,
|
|
79
|
+
server_id,
|
|
80
|
+
:delete,
|
|
81
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/scheduled-events/#{scheduled_event_id}",
|
|
82
|
+
Authorization: token,
|
|
83
|
+
'X-Audit-Log-Reason': reason
|
|
84
|
+
)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'onyxcord/rest/routes/server/base'
|
|
4
|
+
require 'onyxcord/rest/routes/server/channels'
|
|
5
|
+
require 'onyxcord/rest/routes/server/members'
|
|
6
|
+
require 'onyxcord/rest/routes/server/bans'
|
|
7
|
+
require 'onyxcord/rest/routes/server/messages'
|
|
8
|
+
require 'onyxcord/rest/routes/server/roles'
|
|
9
|
+
require 'onyxcord/rest/routes/server/admin'
|
|
10
|
+
require 'onyxcord/rest/routes/server/emoji'
|
|
11
|
+
require 'onyxcord/rest/routes/server/assets'
|
|
12
|
+
require 'onyxcord/rest/routes/server/scheduled_events'
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# API calls for User object
|
|
4
|
-
module OnyxCord::
|
|
4
|
+
module OnyxCord::REST::User
|
|
5
5
|
module_function
|
|
6
6
|
|
|
7
7
|
# Get user data
|
|
8
8
|
# https://discord.com/developers/docs/resources/user#get-user
|
|
9
9
|
def resolve(token, user_id)
|
|
10
|
-
OnyxCord::
|
|
10
|
+
OnyxCord::REST.request(
|
|
11
11
|
:users_uid,
|
|
12
12
|
nil,
|
|
13
13
|
:get,
|
|
14
|
-
"#{OnyxCord::
|
|
14
|
+
"#{OnyxCord::REST.api_base}/users/#{user_id}",
|
|
15
15
|
Authorization: token
|
|
16
16
|
)
|
|
17
17
|
end
|
|
@@ -19,23 +19,23 @@ module OnyxCord::API::User
|
|
|
19
19
|
# Get profile data
|
|
20
20
|
# https://discord.com/developers/docs/resources/user#get-current-user
|
|
21
21
|
def profile(token)
|
|
22
|
-
OnyxCord::
|
|
22
|
+
OnyxCord::REST.request(
|
|
23
23
|
:users_me,
|
|
24
24
|
nil,
|
|
25
25
|
:get,
|
|
26
|
-
"#{OnyxCord::
|
|
26
|
+
"#{OnyxCord::REST.api_base}/users/@me",
|
|
27
27
|
Authorization: token
|
|
28
28
|
)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
# @deprecated Please use {OnyxCord::
|
|
31
|
+
# @deprecated Please use {OnyxCord::REST::Server.update_current_member} instead.
|
|
32
32
|
# https://discord.com/developers/docs/resources/user#modify-current-user-nick
|
|
33
33
|
def change_own_nickname(token, server_id, nick, reason = nil)
|
|
34
|
-
OnyxCord::
|
|
34
|
+
OnyxCord::REST.request(
|
|
35
35
|
:guilds_sid_members_me_nick,
|
|
36
36
|
server_id, # This is technically a guild endpoint
|
|
37
37
|
:patch,
|
|
38
|
-
"#{OnyxCord::
|
|
38
|
+
"#{OnyxCord::REST.api_base}/guilds/#{server_id}/members/@me/nick",
|
|
39
39
|
{ nick: nick }.to_json,
|
|
40
40
|
Authorization: token,
|
|
41
41
|
content_type: :json,
|
|
@@ -52,11 +52,11 @@ module OnyxCord::API::User
|
|
|
52
52
|
# Update the properties of the user for the current bot.
|
|
53
53
|
# https://discord.com/developers/docs/resources/user#modify-current-user
|
|
54
54
|
def update_current_user(token, username = :undef, avatar = :undef, banner = :undef)
|
|
55
|
-
OnyxCord::
|
|
55
|
+
OnyxCord::REST.request(
|
|
56
56
|
:users_me,
|
|
57
57
|
nil,
|
|
58
58
|
:patch,
|
|
59
|
-
"#{OnyxCord::
|
|
59
|
+
"#{OnyxCord::REST.api_base}/users/@me",
|
|
60
60
|
{ username: username, avatar: avatar, banner: banner }.reject { |_, value| value == :undef }.to_json,
|
|
61
61
|
Authorization: token,
|
|
62
62
|
content_type: :json
|
|
@@ -66,11 +66,11 @@ module OnyxCord::API::User
|
|
|
66
66
|
# Get the servers a user is connected to
|
|
67
67
|
# https://discord.com/developers/docs/resources/user#get-current-user-guilds
|
|
68
68
|
def servers(token)
|
|
69
|
-
OnyxCord::
|
|
69
|
+
OnyxCord::REST.request(
|
|
70
70
|
:users_me_guilds,
|
|
71
71
|
nil,
|
|
72
72
|
:get,
|
|
73
|
-
"#{OnyxCord::
|
|
73
|
+
"#{OnyxCord::REST.api_base}/users/@me/guilds",
|
|
74
74
|
Authorization: token
|
|
75
75
|
)
|
|
76
76
|
end
|
|
@@ -78,11 +78,11 @@ module OnyxCord::API::User
|
|
|
78
78
|
# Leave a server
|
|
79
79
|
# https://discord.com/developers/docs/resources/user#leave-guild
|
|
80
80
|
def leave_server(token, server_id)
|
|
81
|
-
OnyxCord::
|
|
81
|
+
OnyxCord::REST.request(
|
|
82
82
|
:users_me_guilds_sid,
|
|
83
83
|
nil,
|
|
84
84
|
:delete,
|
|
85
|
-
"#{OnyxCord::
|
|
85
|
+
"#{OnyxCord::REST.api_base}/users/@me/guilds/#{server_id}",
|
|
86
86
|
Authorization: token
|
|
87
87
|
)
|
|
88
88
|
end
|
|
@@ -90,11 +90,11 @@ module OnyxCord::API::User
|
|
|
90
90
|
# Get the DMs for the current user
|
|
91
91
|
# https://discord.com/developers/docs/resources/user#get-user-dms
|
|
92
92
|
def user_dms(token)
|
|
93
|
-
OnyxCord::
|
|
93
|
+
OnyxCord::REST.request(
|
|
94
94
|
:users_me_channels,
|
|
95
95
|
nil,
|
|
96
96
|
:get,
|
|
97
|
-
"#{OnyxCord::
|
|
97
|
+
"#{OnyxCord::REST.api_base}/users/@me/channels",
|
|
98
98
|
Authorization: token
|
|
99
99
|
)
|
|
100
100
|
end
|
|
@@ -102,11 +102,11 @@ module OnyxCord::API::User
|
|
|
102
102
|
# Create a DM to another user
|
|
103
103
|
# https://discord.com/developers/docs/resources/user#create-dm
|
|
104
104
|
def create_pm(token, recipient_id)
|
|
105
|
-
OnyxCord::
|
|
105
|
+
OnyxCord::REST.request(
|
|
106
106
|
:users_me_channels,
|
|
107
107
|
nil,
|
|
108
108
|
:post,
|
|
109
|
-
"#{OnyxCord::
|
|
109
|
+
"#{OnyxCord::REST.api_base}/users/@me/channels",
|
|
110
110
|
{ recipient_id: recipient_id }.to_json,
|
|
111
111
|
Authorization: token,
|
|
112
112
|
content_type: :json
|
|
@@ -116,11 +116,11 @@ module OnyxCord::API::User
|
|
|
116
116
|
# Get information about a user's connections
|
|
117
117
|
# https://discord.com/developers/docs/resources/user#get-users-connections
|
|
118
118
|
def connections(token)
|
|
119
|
-
OnyxCord::
|
|
119
|
+
OnyxCord::REST.request(
|
|
120
120
|
:users_me_connections,
|
|
121
121
|
nil,
|
|
122
122
|
:get,
|
|
123
|
-
"#{OnyxCord::
|
|
123
|
+
"#{OnyxCord::REST.api_base}/users/@me/connections",
|
|
124
124
|
Authorization: token
|
|
125
125
|
)
|
|
126
126
|
end
|
|
@@ -133,7 +133,7 @@ module OnyxCord::API::User
|
|
|
133
133
|
else
|
|
134
134
|
(discrim_id.to_i >> 22) % 5
|
|
135
135
|
end
|
|
136
|
-
"#{OnyxCord::
|
|
136
|
+
"#{OnyxCord::REST.cdn_url}/embed/avatars/#{index}.png"
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
# Make an avatar URL from the user and avatar IDs
|
|
@@ -143,7 +143,7 @@ module OnyxCord::API::User
|
|
|
143
143
|
else
|
|
144
144
|
'webp'
|
|
145
145
|
end
|
|
146
|
-
"#{OnyxCord::
|
|
146
|
+
"#{OnyxCord::REST.cdn_url}/avatars/#{user_id}/#{avatar_id}.#{format}"
|
|
147
147
|
end
|
|
148
148
|
|
|
149
149
|
# Make a banner URL from the user and banner IDs
|
|
@@ -153,6 +153,6 @@ module OnyxCord::API::User
|
|
|
153
153
|
else
|
|
154
154
|
'png'
|
|
155
155
|
end
|
|
156
|
-
"#{OnyxCord::
|
|
156
|
+
"#{OnyxCord::REST.cdn_url}/banners/#{user_id}/#{banner_id}.#{format}"
|
|
157
157
|
end
|
|
158
158
|
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'onyxcord/message_payload'
|
|
3
|
+
require 'onyxcord/internal/message_payload'
|
|
4
4
|
|
|
5
5
|
# API calls for Webhook object
|
|
6
|
-
module OnyxCord::
|
|
6
|
+
module OnyxCord::REST::Webhook
|
|
7
7
|
module_function
|
|
8
8
|
|
|
9
9
|
# Build attachment metadata payload for multipart uploads.
|
|
@@ -20,11 +20,11 @@ module OnyxCord::API::Webhook
|
|
|
20
20
|
# Get a webhook
|
|
21
21
|
# https://discord.com/developers/docs/resources/webhook#get-webhook
|
|
22
22
|
def webhook(token, webhook_id)
|
|
23
|
-
OnyxCord::
|
|
23
|
+
OnyxCord::REST.request(
|
|
24
24
|
:webhooks_wid,
|
|
25
25
|
nil,
|
|
26
26
|
:get,
|
|
27
|
-
"#{OnyxCord::
|
|
27
|
+
"#{OnyxCord::REST.api_base}/webhooks/#{webhook_id}",
|
|
28
28
|
Authorization: token
|
|
29
29
|
)
|
|
30
30
|
end
|
|
@@ -32,11 +32,11 @@ module OnyxCord::API::Webhook
|
|
|
32
32
|
# Get a webhook via webhook token
|
|
33
33
|
# https://discord.com/developers/docs/resources/webhook#get-webhook-with-token
|
|
34
34
|
def token_webhook(webhook_token, webhook_id)
|
|
35
|
-
OnyxCord::
|
|
35
|
+
OnyxCord::REST.request(
|
|
36
36
|
:webhooks_wid,
|
|
37
37
|
nil,
|
|
38
38
|
:get,
|
|
39
|
-
"#{OnyxCord::
|
|
39
|
+
"#{OnyxCord::REST.api_base}/webhooks/#{webhook_id}/#{webhook_token}"
|
|
40
40
|
)
|
|
41
41
|
end
|
|
42
42
|
|
|
@@ -62,11 +62,11 @@ module OnyxCord::API::Webhook
|
|
|
62
62
|
with_components = components&.any? || nil
|
|
63
63
|
query = URI.encode_www_form({ wait: wait, with_components: with_components }.compact)
|
|
64
64
|
|
|
65
|
-
OnyxCord::
|
|
65
|
+
OnyxCord::REST.request(
|
|
66
66
|
:webhooks_wid,
|
|
67
67
|
webhook_id,
|
|
68
68
|
:post,
|
|
69
|
-
"#{OnyxCord::
|
|
69
|
+
"#{OnyxCord::REST.api_base}/webhooks/#{webhook_id}/#{webhook_token}?#{query}",
|
|
70
70
|
body,
|
|
71
71
|
headers
|
|
72
72
|
)
|
|
@@ -75,11 +75,11 @@ module OnyxCord::API::Webhook
|
|
|
75
75
|
# Update a webhook
|
|
76
76
|
# https://discord.com/developers/docs/resources/webhook#modify-webhook
|
|
77
77
|
def update_webhook(token, webhook_id, data, reason = nil)
|
|
78
|
-
OnyxCord::
|
|
78
|
+
OnyxCord::REST.request(
|
|
79
79
|
:webhooks_wid,
|
|
80
80
|
webhook_id,
|
|
81
81
|
:patch,
|
|
82
|
-
"#{OnyxCord::
|
|
82
|
+
"#{OnyxCord::REST.api_base}/webhooks/#{webhook_id}",
|
|
83
83
|
data.to_json,
|
|
84
84
|
Authorization: token,
|
|
85
85
|
content_type: :json,
|
|
@@ -90,11 +90,11 @@ module OnyxCord::API::Webhook
|
|
|
90
90
|
# Update a webhook via webhook token
|
|
91
91
|
# https://discord.com/developers/docs/resources/webhook#modify-webhook-with-token
|
|
92
92
|
def token_update_webhook(webhook_token, webhook_id, data, reason = nil)
|
|
93
|
-
OnyxCord::
|
|
93
|
+
OnyxCord::REST.request(
|
|
94
94
|
:webhooks_wid,
|
|
95
95
|
webhook_id,
|
|
96
96
|
:patch,
|
|
97
|
-
"#{OnyxCord::
|
|
97
|
+
"#{OnyxCord::REST.api_base}/webhooks/#{webhook_id}/#{webhook_token}",
|
|
98
98
|
data.to_json,
|
|
99
99
|
content_type: :json,
|
|
100
100
|
'X-Audit-Log-Reason': reason
|
|
@@ -104,11 +104,11 @@ module OnyxCord::API::Webhook
|
|
|
104
104
|
# Deletes a webhook
|
|
105
105
|
# https://discord.com/developers/docs/resources/webhook#delete-webhook
|
|
106
106
|
def delete_webhook(token, webhook_id, reason = nil)
|
|
107
|
-
OnyxCord::
|
|
107
|
+
OnyxCord::REST.request(
|
|
108
108
|
:webhooks_wid,
|
|
109
109
|
webhook_id,
|
|
110
110
|
:delete,
|
|
111
|
-
"#{OnyxCord::
|
|
111
|
+
"#{OnyxCord::REST.api_base}/webhooks/#{webhook_id}",
|
|
112
112
|
Authorization: token,
|
|
113
113
|
'X-Audit-Log-Reason': reason
|
|
114
114
|
)
|
|
@@ -117,11 +117,11 @@ module OnyxCord::API::Webhook
|
|
|
117
117
|
# Deletes a webhook via webhook token
|
|
118
118
|
# https://discord.com/developers/docs/resources/webhook#delete-webhook-with-token
|
|
119
119
|
def token_delete_webhook(webhook_token, webhook_id, reason = nil)
|
|
120
|
-
OnyxCord::
|
|
120
|
+
OnyxCord::REST.request(
|
|
121
121
|
:webhooks_wid,
|
|
122
122
|
webhook_id,
|
|
123
123
|
:delete,
|
|
124
|
-
"#{OnyxCord::
|
|
124
|
+
"#{OnyxCord::REST.api_base}/webhooks/#{webhook_id}/#{webhook_token}",
|
|
125
125
|
'X-Audit-Log-Reason': reason
|
|
126
126
|
)
|
|
127
127
|
end
|
|
@@ -129,11 +129,11 @@ module OnyxCord::API::Webhook
|
|
|
129
129
|
# Get a message that was created by the webhook corresponding to the provided token.
|
|
130
130
|
# https://discord.com/developers/docs/resources/webhook#get-webhook-message
|
|
131
131
|
def token_get_message(webhook_token, webhook_id, message_id)
|
|
132
|
-
OnyxCord::
|
|
132
|
+
OnyxCord::REST.request(
|
|
133
133
|
:webhooks_wid_messages_mid,
|
|
134
134
|
webhook_id,
|
|
135
135
|
:get,
|
|
136
|
-
"#{OnyxCord::
|
|
136
|
+
"#{OnyxCord::REST.api_base}/webhooks/#{webhook_id}/#{webhook_token}/messages/#{message_id}"
|
|
137
137
|
)
|
|
138
138
|
end
|
|
139
139
|
|
|
@@ -153,11 +153,11 @@ module OnyxCord::API::Webhook
|
|
|
153
153
|
|
|
154
154
|
headers = { content_type: :json } unless attachments
|
|
155
155
|
|
|
156
|
-
OnyxCord::
|
|
156
|
+
OnyxCord::REST.request(
|
|
157
157
|
:webhooks_wid_messages,
|
|
158
158
|
webhook_id,
|
|
159
159
|
:patch,
|
|
160
|
-
"#{OnyxCord::
|
|
160
|
+
"#{OnyxCord::REST.api_base}/webhooks/#{webhook_id}/#{webhook_token}/messages/#{message_id}",
|
|
161
161
|
body,
|
|
162
162
|
headers
|
|
163
163
|
)
|
|
@@ -166,11 +166,11 @@ module OnyxCord::API::Webhook
|
|
|
166
166
|
# Delete a webhook message via webhook token.
|
|
167
167
|
# https://discord.com/developers/docs/resources/webhook#delete-webhook-message
|
|
168
168
|
def token_delete_message(webhook_token, webhook_id, message_id)
|
|
169
|
-
OnyxCord::
|
|
169
|
+
OnyxCord::REST.request(
|
|
170
170
|
:webhooks_wid_messages,
|
|
171
171
|
webhook_id,
|
|
172
172
|
:delete,
|
|
173
|
-
"#{OnyxCord::
|
|
173
|
+
"#{OnyxCord::REST.api_base}/webhooks/#{webhook_id}/#{webhook_token}/messages/#{message_id}"
|
|
174
174
|
)
|
|
175
175
|
end
|
|
176
176
|
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OnyxCord
|
|
4
|
+
# A timestamp referenced in a message via markdown.
|
|
5
|
+
class TimestampMarkdown
|
|
6
|
+
# Mapping of timestamp styles.
|
|
7
|
+
STYLES = {
|
|
8
|
+
short_time: 't', # 16:20
|
|
9
|
+
long_time: 'T', # 16:20:30
|
|
10
|
+
short_date: 'd', # 20/04/2021
|
|
11
|
+
long_date: 'D', # 20 April 2021
|
|
12
|
+
short_datetime: 'f', # 20 April 2021 16:20
|
|
13
|
+
long_datetime: 'F', # Tuesday, 20 April 2021 16:20
|
|
14
|
+
relative: 'R', # 2 months ago
|
|
15
|
+
simple_datetime: 's', # 20/04/2021, 16:20
|
|
16
|
+
medium_datetime: 'S' # 20/04/2021, 16:20:30
|
|
17
|
+
}.freeze
|
|
18
|
+
|
|
19
|
+
# @return [Time] the time that the timestamp is referencing.
|
|
20
|
+
attr_reader :time
|
|
21
|
+
|
|
22
|
+
# @!visibility private
|
|
23
|
+
def initialize(time, style)
|
|
24
|
+
@time = time
|
|
25
|
+
@style = style
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Get the specifier used to determine the style of the timestamp.
|
|
29
|
+
# @return [String] the formatting specifier used to display the timestamp.
|
|
30
|
+
def style
|
|
31
|
+
@style || 'f'
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Get a string that will allow you to display the time in the Discord client.
|
|
35
|
+
# @return [String] The timestamp serialized as a string for the Discord client.
|
|
36
|
+
def to_s
|
|
37
|
+
OnyxCord.timestamp(@time, @style)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# @!visibility private
|
|
41
|
+
def inspect
|
|
42
|
+
"<TimestampMarkdown time=#{@time.to_i} style=\"#{style}\">"
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# @!method short_time?
|
|
46
|
+
# @return [true, false] whether or not the timestamp is displayed in a format such as `16:20`.
|
|
47
|
+
# @!method long_time?
|
|
48
|
+
# @return [true, false] whether or not the timestamp is displayed in a format such as `16:20:30`.
|
|
49
|
+
# @!method short_date?
|
|
50
|
+
# @return [true, false] whether or not the timestamp is displayed in a format such as `20/04/2021`.
|
|
51
|
+
# @!method long_date?
|
|
52
|
+
# @return [true, false] whether or not the timestamp is displayed in a format such as `20 April 2021`.
|
|
53
|
+
# @!method short_datetime?
|
|
54
|
+
# @return [true, false] whether or not the timestamp is displayed in a format such as `20 April 2021 16:20`.
|
|
55
|
+
# @!method long_datetime?
|
|
56
|
+
# @return [true, false] whether or not the timestamp is displayed in a format such as `Tuesday, 20 April 2021 16:20`.
|
|
57
|
+
# @!method relative?
|
|
58
|
+
# @return [true, false] whether or not the timestamp is displayed in a format such as `2 months ago`.
|
|
59
|
+
# @!method simple_datetime?
|
|
60
|
+
# @return [true, false] whether or not the timestamp is displayed in a format such as `20/04/2021, 16:20`.
|
|
61
|
+
# @!method medium_datetime?
|
|
62
|
+
# @return [true, false] whether or not the timestamp is displayed in a format such as ` 20/04/2021, 16:20:30`.
|
|
63
|
+
STYLES.each do |name, value|
|
|
64
|
+
define_method("#{name}?") do
|
|
65
|
+
style == value
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
require 'onyxcord/voice/encoder'
|
|
4
4
|
require 'onyxcord/voice/network'
|
|
5
5
|
require 'onyxcord/voice/timer'
|
|
6
|
-
require 'onyxcord/logger'
|
|
6
|
+
require 'onyxcord/core/logger'
|
|
7
7
|
require 'ffi'
|
|
8
8
|
|
|
9
9
|
# Voice support
|
|
@@ -20,9 +20,9 @@ module OnyxCord::Voice
|
|
|
20
20
|
#
|
|
21
21
|
# onyxcord does latency adjustments every now and then to improve playback quality. I made sure to put useful
|
|
22
22
|
# defaults for the adjustment parameters, but if the sound is patchy or too fast (or the speed varies a lot) you
|
|
23
|
-
# should check the parameters and adjust them to your connection: {
|
|
24
|
-
# {
|
|
25
|
-
class
|
|
23
|
+
# should check the parameters and adjust them to your connection: {Client#adjust_interval},
|
|
24
|
+
# {Client#adjust_offset}, and {Client#adjust_average}.
|
|
25
|
+
class Client
|
|
26
26
|
# @return [Channel] the current voice channel
|
|
27
27
|
attr_reader :channel
|
|
28
28
|
|
|
@@ -18,7 +18,7 @@ module OnyxCord::Voice
|
|
|
18
18
|
# @return [true, false] whether avconv should be used instead of ffmpeg.
|
|
19
19
|
attr_accessor :use_avconv
|
|
20
20
|
|
|
21
|
-
# @see
|
|
21
|
+
# @see Client#filter_volume=
|
|
22
22
|
# @return [Integer] the volume used as a filter to ffmpeg/avconv.
|
|
23
23
|
attr_accessor :filter_volume
|
|
24
24
|
|