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
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OnyxCord
|
|
4
|
+
module EventContainer
|
|
5
|
+
# This **event** is raised whenever a user votes on a poll.
|
|
6
|
+
# @param attributes [Hash] The event's attributes.
|
|
7
|
+
# @option attributes [String, Integer, User, Member] :user A user to match against.
|
|
8
|
+
# @option attributes [String, Integer, Channel] :channel A channel to match against.
|
|
9
|
+
# @option attributes [String, Integer, Server] :server A server to match against.
|
|
10
|
+
# @option attributes [String, Integer, Message] :message A message to match against.
|
|
11
|
+
# @option attributes [String, Integer, Answer] :answer A poll answer to match against.
|
|
12
|
+
# @yield The block is executed when the event is raised.
|
|
13
|
+
# @yieldparam event [PollVoteAddEvent] The event that was raised.
|
|
14
|
+
# @return [PollVoteAddEventHandler] The event handler that was registered.
|
|
15
|
+
def poll_vote_add(attributes = {}, &block)
|
|
16
|
+
register_event(PollVoteAddEvent, attributes, block)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# This **event** is raised whenever a user removes their vote on a poll.
|
|
20
|
+
# @param attributes [Hash] The event's attributes.
|
|
21
|
+
# @option attributes [String, Integer, User, Member] :user A user to match against.
|
|
22
|
+
# @option attributes [String, Integer, Channel] :channel A channel to match against.
|
|
23
|
+
# @option attributes [String, Integer, Server] :server A server to match against.
|
|
24
|
+
# @option attributes [String, Integer, Message] :message A message to match against.
|
|
25
|
+
# @option attributes [String, Integer, Answer] :answer A poll answer to match against.
|
|
26
|
+
# @yield The block is executed when the event is raised.
|
|
27
|
+
# @yieldparam event [PollVoteRemoveEvent] The event that was raised.
|
|
28
|
+
# @return [PollVoteRemoveEventHandler] The event handler that was registered.
|
|
29
|
+
|
|
30
|
+
# This **event** is raised whenever a user removes their vote on a poll.
|
|
31
|
+
# @param attributes [Hash] The event's attributes.
|
|
32
|
+
# @option attributes [String, Integer, User, Member] :user A user to match against.
|
|
33
|
+
# @option attributes [String, Integer, Channel] :channel A channel to match against.
|
|
34
|
+
# @option attributes [String, Integer, Server] :server A server to match against.
|
|
35
|
+
# @option attributes [String, Integer, Message] :message A message to match against.
|
|
36
|
+
# @option attributes [String, Integer, Answer] :answer A poll answer to match against.
|
|
37
|
+
# @yield The block is executed when the event is raised.
|
|
38
|
+
# @yieldparam event [PollVoteRemoveEvent] The event that was raised.
|
|
39
|
+
# @return [PollVoteRemoveEventHandler] The event handler that was registered.
|
|
40
|
+
def poll_vote_remove(attributes = {}, &block)
|
|
41
|
+
register_event(PollVoteRemoveEvent, attributes, block)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# This **event** is raised when a scheduled event is created.
|
|
45
|
+
# @param attributes [Hash] The event's attributes.
|
|
46
|
+
# @option attributes [String, Integer] :server Matches the scheduled event's server.
|
|
47
|
+
# @option attributes [String, Integer, ScheduledEvent] :id Matches the scheduled event.
|
|
48
|
+
# @option attributes [String, Integer, User, Member] :creator Matches the scheduled event's creator.
|
|
49
|
+
# @option attributes [String, Integer, Channel] :channel Matches the scheduled event's channel.
|
|
50
|
+
# @option attributes [Integer, Symbol, String] :status Matches the status of the scheduled event.
|
|
51
|
+
# @option attributes [Integer, String] :entity_id Matches the entity ID of the scheduled event.
|
|
52
|
+
# @option attributes [Integer, Symbol, String] :entity_type Matches the entity type of the scheduled event.
|
|
53
|
+
# @yield The block is executed when the event is raised.
|
|
54
|
+
# @yieldparam event [ScheduledEventCreateEvent] The event that was raised.
|
|
55
|
+
# @return [ScheduledEventCreateEventHandler] the event handler that was registered.
|
|
56
|
+
|
|
57
|
+
# This **event** is raised when a scheduled event is created.
|
|
58
|
+
# @param attributes [Hash] The event's attributes.
|
|
59
|
+
# @option attributes [String, Integer] :server Matches the scheduled event's server.
|
|
60
|
+
# @option attributes [String, Integer, ScheduledEvent] :id Matches the scheduled event.
|
|
61
|
+
# @option attributes [String, Integer, User, Member] :creator Matches the scheduled event's creator.
|
|
62
|
+
# @option attributes [String, Integer, Channel] :channel Matches the scheduled event's channel.
|
|
63
|
+
# @option attributes [Integer, Symbol, String] :status Matches the status of the scheduled event.
|
|
64
|
+
# @option attributes [Integer, String] :entity_id Matches the entity ID of the scheduled event.
|
|
65
|
+
# @option attributes [Integer, Symbol, String] :entity_type Matches the entity type of the scheduled event.
|
|
66
|
+
# @yield The block is executed when the event is raised.
|
|
67
|
+
# @yieldparam event [ScheduledEventCreateEvent] The event that was raised.
|
|
68
|
+
# @return [ScheduledEventCreateEventHandler] the event handler that was registered.
|
|
69
|
+
def scheduled_event_create(attributes = {}, &block)
|
|
70
|
+
register_event(ScheduledEventCreateEvent, attributes, block)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# This **event** is raised when a scheduled event is updated.
|
|
74
|
+
# @param attributes [Hash] The event's attributes.
|
|
75
|
+
# @option attributes [String, Integer, Server] :server Matches the scheduled event's server.
|
|
76
|
+
# @option attributes [String, Integer, ScheduledEvent] :id Matches the scheduled event.
|
|
77
|
+
# @option attributes [String, Integer, User, Member] :creator Matches the scheduled event's creator.
|
|
78
|
+
# @option attributes [String, Integer, Channel] :channel Matches the scheduled event's channel.
|
|
79
|
+
# @option attributes [Integer, Symbol, String] :status Matches the status of the scheduled event.
|
|
80
|
+
# @option attributes [Integer, String] :entity_id Matches the entity ID of the scheduled event.
|
|
81
|
+
# @option attributes [Integer, Symbol, String] :entity_type Matches the entity type of the scheduled event.
|
|
82
|
+
# @yield The block is executed when the event is raised.
|
|
83
|
+
# @yieldparam event [ScheduledEventUpdateEvent] The event that was raised.
|
|
84
|
+
# @return [ScheduledEventUpdateEventHandler] the event handler that was registered.
|
|
85
|
+
|
|
86
|
+
# This **event** is raised when a scheduled event is updated.
|
|
87
|
+
# @param attributes [Hash] The event's attributes.
|
|
88
|
+
# @option attributes [String, Integer, Server] :server Matches the scheduled event's server.
|
|
89
|
+
# @option attributes [String, Integer, ScheduledEvent] :id Matches the scheduled event.
|
|
90
|
+
# @option attributes [String, Integer, User, Member] :creator Matches the scheduled event's creator.
|
|
91
|
+
# @option attributes [String, Integer, Channel] :channel Matches the scheduled event's channel.
|
|
92
|
+
# @option attributes [Integer, Symbol, String] :status Matches the status of the scheduled event.
|
|
93
|
+
# @option attributes [Integer, String] :entity_id Matches the entity ID of the scheduled event.
|
|
94
|
+
# @option attributes [Integer, Symbol, String] :entity_type Matches the entity type of the scheduled event.
|
|
95
|
+
# @yield The block is executed when the event is raised.
|
|
96
|
+
# @yieldparam event [ScheduledEventUpdateEvent] The event that was raised.
|
|
97
|
+
# @return [ScheduledEventUpdateEventHandler] the event handler that was registered.
|
|
98
|
+
def scheduled_event_update(attributes = {}, &block)
|
|
99
|
+
register_event(ScheduledEventUpdateEvent, attributes, block)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# This **event** is raised when a scheduled event is deleted.
|
|
103
|
+
# @param attributes [Hash] The event's attributes.
|
|
104
|
+
# @option attributes [String, Integer, Server] :server Matches the scheduled event's server.
|
|
105
|
+
# @option attributes [String, Integer, ScheduledEvent] :id Matches the scheduled event.
|
|
106
|
+
# @option attributes [String, Integer, User, Member] :creator Matches the scheduled event's creator.
|
|
107
|
+
# @option attributes [String, Integer, Channel] :channel Matches the scheduled event's channel.
|
|
108
|
+
# @option attributes [Integer, Symbol, String] :status Matches the status of the scheduled event.
|
|
109
|
+
# @option attributes [Integer, String] :entity_id Matches the entity ID of the scheduled event.
|
|
110
|
+
# @option attributes [Integer, Symbol, String] :entity_type Matches the entity type of the scheduled event.
|
|
111
|
+
# @yield The block is executed when the event is raised.
|
|
112
|
+
# @yieldparam event [ScheduledEventDeleteEvent] The event that was raised.
|
|
113
|
+
# @return [ScheduledEventDeleteEventHandler] the event handler that was registered.
|
|
114
|
+
|
|
115
|
+
# This **event** is raised when a scheduled event is deleted.
|
|
116
|
+
# @param attributes [Hash] The event's attributes.
|
|
117
|
+
# @option attributes [String, Integer, Server] :server Matches the scheduled event's server.
|
|
118
|
+
# @option attributes [String, Integer, ScheduledEvent] :id Matches the scheduled event.
|
|
119
|
+
# @option attributes [String, Integer, User, Member] :creator Matches the scheduled event's creator.
|
|
120
|
+
# @option attributes [String, Integer, Channel] :channel Matches the scheduled event's channel.
|
|
121
|
+
# @option attributes [Integer, Symbol, String] :status Matches the status of the scheduled event.
|
|
122
|
+
# @option attributes [Integer, String] :entity_id Matches the entity ID of the scheduled event.
|
|
123
|
+
# @option attributes [Integer, Symbol, String] :entity_type Matches the entity type of the scheduled event.
|
|
124
|
+
# @yield The block is executed when the event is raised.
|
|
125
|
+
# @yieldparam event [ScheduledEventDeleteEvent] The event that was raised.
|
|
126
|
+
# @return [ScheduledEventDeleteEventHandler] the event handler that was registered.
|
|
127
|
+
def scheduled_event_delete(attributes = {}, &block)
|
|
128
|
+
register_event(ScheduledEventDeleteEvent, attributes, block)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# This **event** is raised when a user is added to a scheduled event.
|
|
132
|
+
# @param attributes [Hash] The event's attributes.
|
|
133
|
+
# @option attributes [String, Integer, Server] :server Matches the scheduled event's server.
|
|
134
|
+
# @option attributes [String, Integer, ScheduledEvent] :scheduled_event Matches the scheduled event.
|
|
135
|
+
# @option attributes [String, Integer, User, Member] :user Matches the user that was added.
|
|
136
|
+
# @yield The block is executed when the event is raised.
|
|
137
|
+
# @yieldparam event [ScheduledEventUserAddEvent] The event that was raised.
|
|
138
|
+
# @return [ScheduledEventUserAddEventHandler] the event handler that was registered.
|
|
139
|
+
|
|
140
|
+
# This **event** is raised when a user is added to a scheduled event.
|
|
141
|
+
# @param attributes [Hash] The event's attributes.
|
|
142
|
+
# @option attributes [String, Integer, Server] :server Matches the scheduled event's server.
|
|
143
|
+
# @option attributes [String, Integer, ScheduledEvent] :scheduled_event Matches the scheduled event.
|
|
144
|
+
# @option attributes [String, Integer, User, Member] :user Matches the user that was added.
|
|
145
|
+
# @yield The block is executed when the event is raised.
|
|
146
|
+
# @yieldparam event [ScheduledEventUserAddEvent] The event that was raised.
|
|
147
|
+
# @return [ScheduledEventUserAddEventHandler] the event handler that was registered.
|
|
148
|
+
def scheduled_event_user_add(attributes = {}, &block)
|
|
149
|
+
register_event(ScheduledEventUserAddEvent, attributes, block)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# This **event** is raised when a user is removed from a scheduled event.
|
|
153
|
+
# @param attributes [Hash] The event's attributes.
|
|
154
|
+
# @option attributes [String, Integer, Server] :server Matches the scheduled event's server.
|
|
155
|
+
# @option attributes [String, Integer, ScheduledEvent] :scheduled_event Matches the scheduled event.
|
|
156
|
+
# @option attributes [String, Integer, User, Member] :user Matches the user that was removed.
|
|
157
|
+
# @yield The block is executed when the event is raised.
|
|
158
|
+
# @yieldparam event [ScheduledEventUserRemoveEvent] The event that was raised.
|
|
159
|
+
# @return [ScheduledEventUserRemoveEventHandler] the event handler that was registered.
|
|
160
|
+
|
|
161
|
+
# This **event** is raised when a user is removed from a scheduled event.
|
|
162
|
+
# @param attributes [Hash] The event's attributes.
|
|
163
|
+
# @option attributes [String, Integer, Server] :server Matches the scheduled event's server.
|
|
164
|
+
# @option attributes [String, Integer, ScheduledEvent] :scheduled_event Matches the scheduled event.
|
|
165
|
+
# @option attributes [String, Integer, User, Member] :user Matches the user that was removed.
|
|
166
|
+
# @yield The block is executed when the event is raised.
|
|
167
|
+
# @yieldparam event [ScheduledEventUserRemoveEvent] The event that was raised.
|
|
168
|
+
# @return [ScheduledEventUserRemoveEventHandler] the event handler that was registered.
|
|
169
|
+
def scheduled_event_user_remove(attributes = {}, &block)
|
|
170
|
+
register_event(ScheduledEventUserRemoveEvent, attributes, block)
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
# This **event** is raised whenever an integration is added to a server.
|
|
174
|
+
# @param attributes [Hash] The event's attributes.
|
|
175
|
+
# @option attributes [String, Integer, Integration] :id An integration to match against.
|
|
176
|
+
# @option attributes [String, Integer, Server] :server A server to match against.
|
|
177
|
+
# @option attributes [String, Integer, Application] :application An application to match against.
|
|
178
|
+
# @yield The block is executed when the event is raised.
|
|
179
|
+
# @yieldparam event [IntegrationCreateEvent] The event that was raised.
|
|
180
|
+
# @return [IntegrationCreateEventHandler] The event handler that was registered.
|
|
181
|
+
|
|
182
|
+
# This **event** is raised whenever an integration is added to a server.
|
|
183
|
+
# @param attributes [Hash] The event's attributes.
|
|
184
|
+
# @option attributes [String, Integer, Integration] :id An integration to match against.
|
|
185
|
+
# @option attributes [String, Integer, Server] :server A server to match against.
|
|
186
|
+
# @option attributes [String, Integer, Application] :application An application to match against.
|
|
187
|
+
# @yield The block is executed when the event is raised.
|
|
188
|
+
# @yieldparam event [IntegrationCreateEvent] The event that was raised.
|
|
189
|
+
# @return [IntegrationCreateEventHandler] The event handler that was registered.
|
|
190
|
+
def integration_create(attributes = {}, &block)
|
|
191
|
+
register_event(IntegrationCreateEvent, attributes, block)
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# This **event** is raised whenever an integration is updated in a server.
|
|
195
|
+
# @param attributes [Hash] The event's attributes.
|
|
196
|
+
# @option attributes [String, Integer, Integration] :id An integration to match against.
|
|
197
|
+
# @option attributes [String, Integer, Server] :server A server to match against.
|
|
198
|
+
# @option attributes [String, Integer, Application] :application An application to match against.
|
|
199
|
+
# @yield The block is executed when the event is raised.
|
|
200
|
+
# @yieldparam event [IntegrationUpdateEvent] The event that was raised.
|
|
201
|
+
# @return [IntegrationUpdateEventHandler] The event handler that was registered.
|
|
202
|
+
|
|
203
|
+
# This **event** is raised whenever an integration is updated in a server.
|
|
204
|
+
# @param attributes [Hash] The event's attributes.
|
|
205
|
+
# @option attributes [String, Integer, Integration] :id An integration to match against.
|
|
206
|
+
# @option attributes [String, Integer, Server] :server A server to match against.
|
|
207
|
+
# @option attributes [String, Integer, Application] :application An application to match against.
|
|
208
|
+
# @yield The block is executed when the event is raised.
|
|
209
|
+
# @yieldparam event [IntegrationUpdateEvent] The event that was raised.
|
|
210
|
+
# @return [IntegrationUpdateEventHandler] The event handler that was registered.
|
|
211
|
+
def integration_update(attributes = {}, &block)
|
|
212
|
+
register_event(IntegrationUpdateEvent, attributes, block)
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
# This **event** is raised whenever an integration is removed from a server.
|
|
216
|
+
# @param attributes [Hash] The event's attributes.
|
|
217
|
+
# @option attributes [String, Integer, Integration] :id An integration to match against.
|
|
218
|
+
# @option attributes [String, Integer, Server] :server A server to match against.
|
|
219
|
+
# @option attributes [String, Integer, Application] :application An application to match against.
|
|
220
|
+
# @yield The block is executed when the event is raised.
|
|
221
|
+
# @yieldparam event [IntegrationDeleteEvent] The event that was raised.
|
|
222
|
+
# @return [IntegrationDeleteEventHandler] The event handler that was registered.
|
|
223
|
+
|
|
224
|
+
# This **event** is raised whenever an integration is removed from a server.
|
|
225
|
+
# @param attributes [Hash] The event's attributes.
|
|
226
|
+
# @option attributes [String, Integer, Integration] :id An integration to match against.
|
|
227
|
+
# @option attributes [String, Integer, Server] :server A server to match against.
|
|
228
|
+
# @option attributes [String, Integer, Application] :application An application to match against.
|
|
229
|
+
# @yield The block is executed when the event is raised.
|
|
230
|
+
# @yieldparam event [IntegrationDeleteEvent] The event that was raised.
|
|
231
|
+
# @return [IntegrationDeleteEventHandler] The event handler that was registered.
|
|
232
|
+
def integration_delete(attributes = {}, &block)
|
|
233
|
+
register_event(IntegrationDeleteEvent, attributes, block)
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
# This **event** is raised for every dispatch received over the gateway, whether supported by onyxcord or not.
|
|
237
|
+
# @param attributes [Hash] The event's attributes.
|
|
238
|
+
# @option attributes [String, Symbol, Regexp] :type Matches the event type of the dispatch.
|
|
239
|
+
# @yield The block is executed when the event is raised.
|
|
240
|
+
# @yieldparam event [RawEvent] The event that was raised.
|
|
241
|
+
# @return [RawEventHandler] The event handler that was registered.
|
|
242
|
+
end
|
|
243
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OnyxCord
|
|
4
|
+
module EventContainer
|
|
5
|
+
# This **event** is raised when a user's voice state changes. This includes when a user joins, leaves, or
|
|
6
|
+
# moves between voice channels, as well as their mute and deaf status for themselves and on the server.
|
|
7
|
+
# @param attributes [Hash] The event's attributes.
|
|
8
|
+
# @option attributes [String, Integer, User] :from Matches the user that raised the event.
|
|
9
|
+
# @option attributes [String, Integer, Channel] :channel Matches the voice channel the user has joined.
|
|
10
|
+
# @option attributes [String, Integer, Channel] :old_channel Matches the voice channel the user was in previously.
|
|
11
|
+
# @option attributes [true, false] :mute Matches whether or not the user is muted server-wide.
|
|
12
|
+
# @option attributes [true, false] :deaf Matches whether or not the user is deafened server-wide.
|
|
13
|
+
# @option attributes [true, false] :self_mute Matches whether or not the user is muted by the bot.
|
|
14
|
+
# @option attributes [true, false] :self_deaf Matches whether or not the user is deafened by the bot.
|
|
15
|
+
# @yield The block is executed when the event is raised.
|
|
16
|
+
# @yieldparam event [VoiceStateUpdateEvent] The event that was raised.
|
|
17
|
+
# @return [VoiceStateUpdateEventHandler] the event handler that was registered.
|
|
18
|
+
def voice_state_update(attributes = {}, &block)
|
|
19
|
+
register_event(VoiceStateUpdateEvent, attributes, block)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# This **event** is raised when first connecting to a server's voice channel.
|
|
23
|
+
# @param attributes [Hash] The event's attributes.
|
|
24
|
+
# @option attributes [String, Integer, User] :from Matches the server that the update is for.
|
|
25
|
+
# @yield The block is executed when the event is raised.
|
|
26
|
+
# @yieldparam event [VoiceServerUpdateEvent] The event that was raised.
|
|
27
|
+
# @return [VoiceServerUpdateEventHandler] The event handler that was registered.
|
|
28
|
+
|
|
29
|
+
# This **event** is raised when first connecting to a server's voice channel.
|
|
30
|
+
# @param attributes [Hash] The event's attributes.
|
|
31
|
+
# @option attributes [String, Integer, User] :from Matches the server that the update is for.
|
|
32
|
+
# @yield The block is executed when the event is raised.
|
|
33
|
+
# @yieldparam event [VoiceServerUpdateEvent] The event that was raised.
|
|
34
|
+
# @return [VoiceServerUpdateEventHandler] The event handler that was registered.
|
|
35
|
+
def voice_server_update(attributes = {}, &block)
|
|
36
|
+
register_event(VoiceServerUpdateEvent, attributes, block)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# This **event** is raised when a new user joins a server.
|
|
40
|
+
# @param attributes [Hash] The event's attributes.
|
|
41
|
+
# @option attributes [String] :username Matches the username of the joined user.
|
|
42
|
+
# @yield The block is executed when the event is raised.
|
|
43
|
+
# @yieldparam event [ServerMemberAddEvent] The event that was raised.
|
|
44
|
+
# @return [ServerMemberAddEventHandler] the event handler that was registered.
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'onyxcord/models'
|
|
4
|
+
require 'onyxcord/events/generic'
|
|
5
|
+
|
|
6
|
+
module OnyxCord::Events
|
|
7
|
+
# Generic superclass for integration events.
|
|
8
|
+
class IntegrationEvent < Event
|
|
9
|
+
# @return [Server] the server associated with the event.
|
|
10
|
+
attr_reader :server
|
|
11
|
+
|
|
12
|
+
# @return [Integration] the integration associated with the event.
|
|
13
|
+
attr_reader :integration
|
|
14
|
+
|
|
15
|
+
# @!visibility private
|
|
16
|
+
def initialize(data, bot)
|
|
17
|
+
@bot = bot
|
|
18
|
+
@server = bot.server(data['guild_id'].to_i)
|
|
19
|
+
@integration = OnyxCord::Integration.new(data, @bot, @server)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Generic event handler for integration events.
|
|
24
|
+
class IntegrationEventHandler < EventHandler
|
|
25
|
+
# @!visibility private
|
|
26
|
+
def matches?(event)
|
|
27
|
+
# Check for the proper event type.
|
|
28
|
+
return false unless event.is_a?(IntegrationEvent)
|
|
29
|
+
|
|
30
|
+
[
|
|
31
|
+
matches_all(@attributes[:server], event.server) do |a, e|
|
|
32
|
+
a&.resolve_id == e&.resolve_id
|
|
33
|
+
end,
|
|
34
|
+
|
|
35
|
+
matches_all(@attributes[:id], event.integration) do |a, e|
|
|
36
|
+
a&.resolve_id == e&.resolve_id
|
|
37
|
+
end,
|
|
38
|
+
|
|
39
|
+
matches_all(@attributes[:application], event.integration) do |a, e|
|
|
40
|
+
a&.resolve_id == e.application&.resolve_id
|
|
41
|
+
end
|
|
42
|
+
].reduce(true, &:&)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'onyxcord/events/integration/base'
|
|
4
|
+
|
|
5
|
+
module OnyxCord::Events
|
|
6
|
+
# Raised whenever an integration is created.
|
|
7
|
+
class IntegrationCreateEvent < IntegrationEvent; end
|
|
8
|
+
|
|
9
|
+
# Event handler for INTEGRATION_CREATE events.
|
|
10
|
+
class IntegrationCreateEventHandler < IntegrationEventHandler; end
|
|
11
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'onyxcord/events/generic'
|
|
4
|
+
|
|
5
|
+
module OnyxCord::Events
|
|
6
|
+
# Raised whenever an integration is deleted.
|
|
7
|
+
class IntegrationDeleteEvent < Event
|
|
8
|
+
# @return [Server] the server associated with the event.
|
|
9
|
+
attr_reader :server
|
|
10
|
+
|
|
11
|
+
# @return [Integer] the ID of the integration that was removed.
|
|
12
|
+
attr_reader :integration_id
|
|
13
|
+
|
|
14
|
+
# @return [Integer, nil] the ID of the application that was removed.
|
|
15
|
+
attr_reader :application_id
|
|
16
|
+
|
|
17
|
+
# @!visibility private
|
|
18
|
+
def initialize(data, bot)
|
|
19
|
+
@bot = bot
|
|
20
|
+
@server = bot.server(data['guild_id'].to_i)
|
|
21
|
+
@integration_id = data['id'].to_i
|
|
22
|
+
@application_id = data['application_id']&.to_i
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Event handler for INTEGRATION_DELETE events.
|
|
27
|
+
class IntegrationDeleteEventHandler < EventHandler
|
|
28
|
+
# @!visibility private
|
|
29
|
+
def matches?(event)
|
|
30
|
+
# Check for the proper event type.
|
|
31
|
+
return false unless event.is_a?(IntegrationDeleteEvent)
|
|
32
|
+
|
|
33
|
+
[
|
|
34
|
+
matches_all(@attributes[:server], event.server) do |a, e|
|
|
35
|
+
a&.resolve_id == e&.resolve_id
|
|
36
|
+
end,
|
|
37
|
+
|
|
38
|
+
matches_all(@attributes[:id], event.integration_id) do |a, e|
|
|
39
|
+
a&.resolve_id == e&.resolve_id
|
|
40
|
+
end,
|
|
41
|
+
|
|
42
|
+
matches_all(@attributes[:application], event.application_id) do |a, e|
|
|
43
|
+
a&.resolve_id == e&.resolve_id
|
|
44
|
+
end
|
|
45
|
+
].reduce(true, &:&)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'onyxcord/events/integration/base'
|
|
4
|
+
|
|
5
|
+
module OnyxCord::Events
|
|
6
|
+
# Raised whenever an integration is updated.
|
|
7
|
+
class IntegrationUpdateEvent < IntegrationEvent; end
|
|
8
|
+
|
|
9
|
+
# Event handler for INTEGRATION_UPDATE events.
|
|
10
|
+
class IntegrationUpdateEventHandler < IntegrationEventHandler; end
|
|
11
|
+
end
|
|
@@ -1,100 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'onyxcord/
|
|
4
|
-
require 'onyxcord/events/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
# Generic superclass for integration events.
|
|
8
|
-
class IntegrationEvent < Event
|
|
9
|
-
# @return [Server] the server associated with the event.
|
|
10
|
-
attr_reader :server
|
|
11
|
-
|
|
12
|
-
# @return [Integration] the integration associated with the event.
|
|
13
|
-
attr_reader :integration
|
|
14
|
-
|
|
15
|
-
# @!visibility private
|
|
16
|
-
def initialize(data, bot)
|
|
17
|
-
@bot = bot
|
|
18
|
-
@server = bot.server(data['guild_id'].to_i)
|
|
19
|
-
@integration = OnyxCord::Integration.new(data, @bot, @server)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# Raised whenever an integration is created.
|
|
24
|
-
class IntegrationCreateEvent < IntegrationEvent; end
|
|
25
|
-
|
|
26
|
-
# Raised whenever an integration is updated.
|
|
27
|
-
class IntegrationUpdateEvent < IntegrationEvent; end
|
|
28
|
-
|
|
29
|
-
# Raised whenever an integration is deleted.
|
|
30
|
-
class IntegrationDeleteEvent < Event
|
|
31
|
-
# @return [Server] the server associated with the event.
|
|
32
|
-
attr_reader :server
|
|
33
|
-
|
|
34
|
-
# @return [Integer] the ID of the integration that was removed.
|
|
35
|
-
attr_reader :integration_id
|
|
36
|
-
|
|
37
|
-
# @return [Integer, nil] the ID of the application that was removed.
|
|
38
|
-
attr_reader :application_id
|
|
39
|
-
|
|
40
|
-
# @!visibility private
|
|
41
|
-
def initialize(data, bot)
|
|
42
|
-
@bot = bot
|
|
43
|
-
@server = bot.server(data['guild_id'].to_i)
|
|
44
|
-
@integration_id = data['id'].to_i
|
|
45
|
-
@application_id = data['application_id']&.to_i
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# Generic event handler for integration events.
|
|
50
|
-
class IntegrationEventHandler < EventHandler
|
|
51
|
-
# @!visibility private
|
|
52
|
-
def matches?(event)
|
|
53
|
-
# Check for the proper event type.
|
|
54
|
-
return false unless event.is_a?(IntegrationEvent)
|
|
55
|
-
|
|
56
|
-
[
|
|
57
|
-
matches_all(@attributes[:server], event.server) do |a, e|
|
|
58
|
-
a&.resolve_id == e&.resolve_id
|
|
59
|
-
end,
|
|
60
|
-
|
|
61
|
-
matches_all(@attributes[:id], event.integration) do |a, e|
|
|
62
|
-
a&.resolve_id == e&.resolve_id
|
|
63
|
-
end,
|
|
64
|
-
|
|
65
|
-
matches_all(@attributes[:application], event.integration) do |a, e|
|
|
66
|
-
a&.resolve_id == e.application&.resolve_id
|
|
67
|
-
end
|
|
68
|
-
].reduce(true, &:&)
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
# Event handler for INTEGRATION_CREATE events.
|
|
73
|
-
class IntegrationCreateEventHandler < IntegrationEventHandler; end
|
|
74
|
-
|
|
75
|
-
# Event handler for INTEGRATION_UPDATE events.
|
|
76
|
-
class IntegrationUpdateEventHandler < IntegrationEventHandler; end
|
|
77
|
-
|
|
78
|
-
# Event handler for INTEGRATION_DELETE events.
|
|
79
|
-
class IntegrationDeleteEventHandler < EventHandler
|
|
80
|
-
# @!visibility private
|
|
81
|
-
def matches?(event)
|
|
82
|
-
# Check for the proper event type.
|
|
83
|
-
return false unless event.is_a?(IntegrationDeleteEvent)
|
|
84
|
-
|
|
85
|
-
[
|
|
86
|
-
matches_all(@attributes[:server], event.server) do |a, e|
|
|
87
|
-
a&.resolve_id == e&.resolve_id
|
|
88
|
-
end,
|
|
89
|
-
|
|
90
|
-
matches_all(@attributes[:id], event.integration_id) do |a, e|
|
|
91
|
-
a&.resolve_id == e&.resolve_id
|
|
92
|
-
end,
|
|
93
|
-
|
|
94
|
-
matches_all(@attributes[:application], event.application_id) do |a, e|
|
|
95
|
-
a&.resolve_id == e&.resolve_id
|
|
96
|
-
end
|
|
97
|
-
].reduce(true, &:&)
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
end
|
|
3
|
+
require 'onyxcord/events/integration/base'
|
|
4
|
+
require 'onyxcord/events/integration/create'
|
|
5
|
+
require 'onyxcord/events/integration/update'
|
|
6
|
+
require 'onyxcord/events/integration/delete'
|