onyxcord 2.1.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/onyxcord/application_commands/command.rb +4 -97
- data/lib/onyxcord/application_commands/context.rb +4 -94
- data/lib/onyxcord/application_commands/option.rb +4 -75
- data/lib/onyxcord/application_commands/registry.rb +4 -45
- data/lib/onyxcord/application_commands.rb +8 -5
- data/lib/onyxcord/bot.rb +24 -1759
- data/lib/onyxcord/{cache.rb → cache/manager.rb} +16 -14
- data/lib/onyxcord/cache/stores/gateway.rb +272 -0
- data/lib/onyxcord/commands/bot/channels.rb +48 -0
- data/lib/onyxcord/commands/bot/execution.rb +174 -0
- data/lib/onyxcord/commands/bot/message_dispatch.rb +58 -0
- data/lib/onyxcord/commands/bot/permissions.rb +72 -0
- data/lib/onyxcord/commands/bot.rb +209 -0
- data/lib/onyxcord/commands/container.rb +21 -2
- data/lib/onyxcord/commands/parser.rb +30 -1
- data/lib/onyxcord/container.rb +16 -960
- data/lib/onyxcord/core/bot/application_commands.rb +210 -0
- data/lib/onyxcord/core/bot/awaits.rb +112 -0
- data/lib/onyxcord/core/bot/invites.rb +42 -0
- data/lib/onyxcord/core/bot/messaging.rb +161 -0
- data/lib/onyxcord/core/bot/oauth.rb +27 -0
- data/lib/onyxcord/core/bot/presence.rb +103 -0
- data/lib/onyxcord/core/bot/runtime.rb +183 -0
- data/lib/onyxcord/core/bot/voice.rb +69 -0
- data/lib/onyxcord/{logger.rb → core/logger.rb} +5 -0
- data/lib/onyxcord/core/version.rb +5 -0
- data/lib/onyxcord/events/await/base.rb +48 -0
- data/lib/onyxcord/events/await.rb +1 -46
- data/lib/onyxcord/events/ban/base.rb +54 -0
- data/lib/onyxcord/events/ban/remove.rb +11 -0
- data/lib/onyxcord/events/bans.rb +2 -58
- data/lib/onyxcord/events/channels/base.rb +91 -0
- data/lib/onyxcord/events/channels/delete.rb +73 -0
- data/lib/onyxcord/events/channels/pins.rb +44 -0
- data/lib/onyxcord/events/channels/recipients.rb +77 -0
- data/lib/onyxcord/events/channels.rb +4 -239
- data/lib/onyxcord/events/guilds/audit_logs.rb +79 -0
- data/lib/onyxcord/events/guilds/base.rb +97 -0
- data/lib/onyxcord/events/guilds/emoji.rb +147 -0
- data/lib/onyxcord/events/guilds.rb +3 -267
- data/lib/onyxcord/events/handlers/channels.rb +133 -0
- data/lib/onyxcord/events/handlers/core.rb +146 -0
- data/lib/onyxcord/events/handlers/guilds.rb +375 -0
- data/lib/onyxcord/events/handlers/interactions.rb +238 -0
- data/lib/onyxcord/events/handlers/lifetime.rb +71 -0
- data/lib/onyxcord/events/handlers/messages.rb +218 -0
- data/lib/onyxcord/events/handlers/presence.rb +56 -0
- data/lib/onyxcord/events/handlers/raw.rb +39 -0
- data/lib/onyxcord/events/handlers/reactions.rb +98 -0
- data/lib/onyxcord/events/handlers/scheduled_events.rb +243 -0
- data/lib/onyxcord/events/handlers/voice.rb +46 -0
- data/lib/onyxcord/events/integration/base.rb +45 -0
- data/lib/onyxcord/events/integration/create.rb +11 -0
- data/lib/onyxcord/events/integration/delete.rb +48 -0
- data/lib/onyxcord/events/integration/update.rb +11 -0
- data/lib/onyxcord/events/integrations.rb +4 -98
- data/lib/onyxcord/events/interactions/application_commands.rb +185 -0
- data/lib/onyxcord/events/interactions/autocomplete.rb +62 -0
- data/lib/onyxcord/events/interactions/base.rb +175 -0
- data/lib/onyxcord/events/interactions/components.rb +221 -0
- data/lib/onyxcord/events/interactions/permissions.rb +53 -0
- data/lib/onyxcord/events/interactions.rb +5 -622
- data/lib/onyxcord/events/invite/create.rb +79 -0
- data/lib/onyxcord/events/invite/delete.rb +55 -0
- data/lib/onyxcord/events/invites.rb +2 -125
- data/lib/onyxcord/events/lifetime/base.rb +31 -0
- data/lib/onyxcord/events/lifetime.rb +1 -29
- data/lib/onyxcord/events/member/add.rb +12 -0
- data/lib/onyxcord/events/member/base.rb +67 -0
- data/lib/onyxcord/events/member/delete.rb +21 -0
- data/lib/onyxcord/events/member/update.rb +25 -0
- data/lib/onyxcord/events/members.rb +4 -108
- data/lib/onyxcord/events/message/base.rb +295 -0
- data/lib/onyxcord/events/message/ids.rb +71 -0
- data/lib/onyxcord/events/message/mentions.rb +55 -0
- data/lib/onyxcord/events/message/updates.rb +27 -0
- data/lib/onyxcord/events/message.rb +4 -397
- data/lib/onyxcord/events/poll/add.rb +11 -0
- data/lib/onyxcord/events/poll/base.rb +106 -0
- data/lib/onyxcord/events/poll/remove.rb +11 -0
- data/lib/onyxcord/events/polls.rb +3 -116
- data/lib/onyxcord/events/presence/playing.rb +77 -0
- data/lib/onyxcord/events/presence/status.rb +60 -0
- data/lib/onyxcord/events/presence.rb +2 -129
- data/lib/onyxcord/events/raw/base.rb +74 -0
- data/lib/onyxcord/events/raw.rb +1 -72
- data/lib/onyxcord/events/reactions/base.rb +143 -0
- data/lib/onyxcord/events/reactions/clear.rb +99 -0
- data/lib/onyxcord/events/reactions.rb +2 -216
- data/lib/onyxcord/events/role/create.rb +46 -0
- data/lib/onyxcord/events/role/delete.rb +40 -0
- data/lib/onyxcord/events/role/update.rb +11 -0
- data/lib/onyxcord/events/roles.rb +3 -85
- data/lib/onyxcord/events/scheduled_events/events.rb +112 -0
- data/lib/onyxcord/events/scheduled_events/users.rb +91 -0
- data/lib/onyxcord/events/scheduled_events.rb +2 -169
- data/lib/onyxcord/events/thread/base.rb +49 -0
- data/lib/onyxcord/events/thread/members.rb +44 -0
- data/lib/onyxcord/events/thread/update.rb +18 -0
- data/lib/onyxcord/events/threads.rb +3 -98
- data/lib/onyxcord/events/typing/base.rb +73 -0
- data/lib/onyxcord/events/typing.rb +1 -71
- data/lib/onyxcord/events/voice/server_update.rb +48 -0
- data/lib/onyxcord/events/voice/state_update.rb +137 -0
- data/lib/onyxcord/events/voice_server_update.rb +2 -46
- data/lib/onyxcord/events/voice_state_update.rb +2 -135
- data/lib/onyxcord/events/webhook/update.rb +65 -0
- data/lib/onyxcord/events/webhooks.rb +1 -63
- data/lib/onyxcord/gateway/client.rb +460 -0
- data/lib/onyxcord/interactions/command.rb +120 -0
- data/lib/onyxcord/interactions/context.rb +109 -0
- data/lib/onyxcord/interactions/internal/application_command.rb +203 -0
- data/lib/onyxcord/interactions/internal/message.rb +152 -0
- data/lib/onyxcord/interactions/internal/metadata.rb +109 -0
- data/lib/onyxcord/interactions/internal/option_builder.rb +230 -0
- data/lib/onyxcord/interactions/internal/permission_builder.rb +90 -0
- data/lib/onyxcord/interactions/option.rb +88 -0
- data/lib/onyxcord/interactions/registry.rb +50 -0
- data/lib/onyxcord/interactions.rb +16 -0
- data/lib/onyxcord/internal/async_runtime.rb +32 -0
- data/lib/onyxcord/internal/event_bus.rb +591 -0
- data/lib/onyxcord/internal/event_executor.rb +155 -0
- data/lib/onyxcord/internal/gateway/opcodes.rb +22 -0
- data/lib/onyxcord/internal/gateway/session.rb +45 -0
- data/lib/onyxcord/internal/http.rb +189 -0
- data/lib/onyxcord/internal/json.rb +51 -0
- data/lib/onyxcord/{message_payload.rb → internal/message_payload.rb} +3 -3
- data/lib/onyxcord/internal/rate_limiter/async_rest.rb +151 -0
- data/lib/onyxcord/internal/rate_limiter/gateway.rb +44 -0
- data/lib/onyxcord/internal/rate_limiter/rest.rb +144 -0
- data/lib/onyxcord/internal/websocket.rb +79 -0
- data/lib/onyxcord/light/data.rb +1 -1
- data/lib/onyxcord/light/integrations.rb +1 -1
- data/lib/onyxcord/light/light_bot.rb +7 -7
- data/lib/onyxcord/{data → models}/activity.rb +2 -2
- data/lib/onyxcord/{data → models}/application.rb +3 -3
- data/lib/onyxcord/{data → models}/avatar_decoration.rb +1 -1
- data/lib/onyxcord/{data → models}/channel.rb +23 -23
- data/lib/onyxcord/{data → models}/collectibles.rb +1 -1
- data/lib/onyxcord/{data → models}/emoji.rb +1 -1
- data/lib/onyxcord/models/interaction.rb +450 -0
- data/lib/onyxcord/{data → models}/invite.rb +1 -1
- data/lib/onyxcord/{data → models}/member.rb +11 -11
- data/lib/onyxcord/{data → models}/message.rb +18 -14
- data/lib/onyxcord/{data → models}/poll.rb +2 -2
- data/lib/onyxcord/{data → models}/primary_server.rb +1 -1
- data/lib/onyxcord/{data → models}/profile.rb +4 -4
- data/lib/onyxcord/{data → models}/role.rb +6 -12
- data/lib/onyxcord/{data → models}/scheduled_event.rb +5 -5
- data/lib/onyxcord/{data → models}/server.rb +41 -41
- data/lib/onyxcord/{data → models}/server_preview.rb +2 -2
- data/lib/onyxcord/{data → models}/team.rb +1 -1
- data/lib/onyxcord/{data → models}/user.rb +5 -5
- data/lib/onyxcord/{data → models}/webhook.rb +10 -10
- data/lib/onyxcord/models.rb +57 -0
- data/lib/onyxcord/{api.rb → rest/client.rb} +23 -22
- data/lib/onyxcord/{api → rest/routes}/application.rb +79 -57
- data/lib/onyxcord/rest/routes/channel/base.rb +73 -0
- data/lib/onyxcord/rest/routes/channel/groups.rb +78 -0
- data/lib/onyxcord/rest/routes/channel/messages.rb +130 -0
- data/lib/onyxcord/rest/routes/channel/permissions.rb +73 -0
- data/lib/onyxcord/rest/routes/channel/pins.rb +45 -0
- data/lib/onyxcord/rest/routes/channel/polls.rb +32 -0
- data/lib/onyxcord/rest/routes/channel/reactions.rb +86 -0
- data/lib/onyxcord/rest/routes/channel/threads.rb +176 -0
- data/lib/onyxcord/rest/routes/channel/webhooks.rb +47 -0
- data/lib/onyxcord/rest/routes/channel.rb +12 -0
- data/lib/onyxcord/{api/interaction.rb → rest/routes/interaction/base.rb} +7 -25
- data/lib/onyxcord/rest/routes/interaction/response.rb +24 -0
- data/lib/onyxcord/rest/routes/interaction.rb +4 -0
- data/lib/onyxcord/{api → rest/routes}/invite.rb +7 -7
- data/lib/onyxcord/rest/routes/server/admin.rb +174 -0
- data/lib/onyxcord/rest/routes/server/assets.rb +25 -0
- data/lib/onyxcord/rest/routes/server/bans.rb +67 -0
- data/lib/onyxcord/rest/routes/server/base.rb +77 -0
- data/lib/onyxcord/rest/routes/server/channels.rb +58 -0
- data/lib/onyxcord/rest/routes/server/emoji.rb +48 -0
- data/lib/onyxcord/rest/routes/server/members.rb +109 -0
- data/lib/onyxcord/rest/routes/server/messages.rb +19 -0
- data/lib/onyxcord/rest/routes/server/roles.rb +156 -0
- data/lib/onyxcord/rest/routes/server/scheduled_events.rb +86 -0
- data/lib/onyxcord/rest/routes/server.rb +12 -0
- data/lib/onyxcord/{api → rest/routes}/user.rb +23 -23
- data/lib/onyxcord/{api → rest/routes}/webhook.rb +22 -22
- data/lib/onyxcord/{allowed_mentions.rb → utils/allowed_mentions.rb} +1 -1
- data/lib/onyxcord/utils/timestamp.rb +69 -0
- data/lib/onyxcord/voice/{voice_bot.rb → client.rb} +4 -4
- data/lib/onyxcord/voice/encoder.rb +1 -1
- data/lib/onyxcord/voice/network/udp.rb +135 -0
- data/lib/onyxcord/voice/network/websocket.rb +225 -0
- data/lib/onyxcord/voice/network.rb +5 -357
- data/lib/onyxcord/webhooks/builder.rb +1 -1
- data/lib/onyxcord/webhooks/client.rb +13 -13
- data/lib/onyxcord/webhooks/modal/group_builder.rb +55 -0
- data/lib/onyxcord/webhooks/modal/label_builder.rb +183 -0
- data/lib/onyxcord/webhooks/modal.rb +2 -239
- data/lib/onyxcord/webhooks/version.rb +3 -3
- data/lib/onyxcord/webhooks/view/container_builder.rb +80 -0
- data/lib/onyxcord/webhooks/view/file_builder.rb +24 -0
- data/lib/onyxcord/webhooks/view/media_gallery_builder.rb +50 -0
- data/lib/onyxcord/webhooks/view/row_builder.rb +120 -0
- data/lib/onyxcord/webhooks/view/section_builder.rb +61 -0
- data/lib/onyxcord/webhooks/view/select_menu_builder.rb +77 -0
- data/lib/onyxcord/webhooks/view/separator_builder.rb +22 -0
- data/lib/onyxcord/webhooks/view/text_display_builder.rb +20 -0
- data/lib/onyxcord/webhooks/view.rb +9 -425
- data/lib/onyxcord.rb +106 -42
- metadata +207 -92
- data/.github/CONTRIBUTING.md +0 -13
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -24
- data/.github/pull_request_template.md +0 -37
- data/.github/workflows/ci.yml +0 -78
- data/.github/workflows/codeql.yml +0 -65
- data/.github/workflows/deploy.yml +0 -54
- data/.github/workflows/release.yml +0 -51
- data/.gitignore +0 -17
- data/.markdownlint.json +0 -4
- data/.overcommit.yml +0 -7
- data/.rspec +0 -2
- data/.rubocop.yml +0 -129
- data/.yardopts +0 -1
- data/CHANGELOG.md +0 -257
- data/Gemfile +0 -6
- data/LICENSE.txt +0 -21
- data/README.md +0 -448
- data/Rakefile +0 -13
- data/lib/onyxcord/api/channel.rb +0 -703
- data/lib/onyxcord/api/server.rb +0 -775
- data/lib/onyxcord/async/runtime.rb +0 -30
- data/lib/onyxcord/commands/command_bot.rb +0 -505
- data/lib/onyxcord/data/interaction.rb +0 -1151
- data/lib/onyxcord/data.rb +0 -57
- data/lib/onyxcord/event_executor.rb +0 -153
- data/lib/onyxcord/gateway.rb +0 -505
- data/lib/onyxcord/http.rb +0 -186
- data/lib/onyxcord/json.rb +0 -49
- data/lib/onyxcord/rate_limiter/async_rest.rb +0 -150
- data/lib/onyxcord/rate_limiter/gateway.rb +0 -42
- data/lib/onyxcord/rate_limiter/rest.rb +0 -142
- data/lib/onyxcord/version.rb +0 -7
- data/lib/onyxcord/websocket.rb +0 -77
- data/onyxcord.gemspec +0 -63
- /data/lib/onyxcord/{configuration.rb → core/configuration.rb} +0 -0
- /data/lib/onyxcord/{errors.rb → core/errors.rb} +0 -0
- /data/lib/onyxcord/{upload.rb → internal/upload.rb} +0 -0
- /data/lib/onyxcord/{data → models}/attachment.rb +0 -0
- /data/lib/onyxcord/{data → models}/audit_logs.rb +0 -0
- /data/lib/onyxcord/{data → models}/call.rb +0 -0
- /data/lib/onyxcord/{data → models}/channel_tag.rb +0 -0
- /data/lib/onyxcord/{data → models}/component.rb +0 -0
- /data/lib/onyxcord/{data → models}/embed.rb +0 -0
- /data/lib/onyxcord/{data → models}/install_params.rb +0 -0
- /data/lib/onyxcord/{data → models}/integration.rb +0 -0
- /data/lib/onyxcord/{data → models}/message_activity.rb +0 -0
- /data/lib/onyxcord/{data → models}/overwrite.rb +0 -0
- /data/lib/onyxcord/{data → models}/reaction.rb +0 -0
- /data/lib/onyxcord/{data → models}/recipient.rb +0 -0
- /data/lib/onyxcord/{data → models}/role_connection_data.rb +0 -0
- /data/lib/onyxcord/{data → models}/role_subscription.rb +0 -0
- /data/lib/onyxcord/{data → models}/snapshot.rb +0 -0
- /data/lib/onyxcord/{data → models}/timestamp.rb +0 -0
- /data/lib/onyxcord/{data → models}/voice_region.rb +0 -0
- /data/lib/onyxcord/{data → models}/voice_state.rb +0 -0
- /data/lib/onyxcord/{colour_rgb.rb → utils/colour_rgb.rb} +0 -0
- /data/lib/onyxcord/{id_object.rb → utils/id_object.rb} +0 -0
- /data/lib/onyxcord/{message_components.rb → utils/message_components.rb} +0 -0
- /data/lib/onyxcord/{paginator.rb → utils/paginator.rb} +0 -0
- /data/lib/onyxcord/{permissions.rb → utils/permissions.rb} +0 -0
|
@@ -1,269 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'onyxcord/events/
|
|
4
|
-
require 'onyxcord/
|
|
5
|
-
|
|
6
|
-
module OnyxCord::Events
|
|
7
|
-
# Generic subclass for server events (create/update/delete)
|
|
8
|
-
class ServerEvent < Event
|
|
9
|
-
# @return [Server] the server in question.
|
|
10
|
-
attr_reader :server
|
|
11
|
-
|
|
12
|
-
# @!visibility private
|
|
13
|
-
def initialize(data, bot)
|
|
14
|
-
@bot = bot
|
|
15
|
-
|
|
16
|
-
init_server(data, bot)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
# Initializes this event with server data. Should be overwritten in case the server doesn't exist at the time
|
|
20
|
-
# of event creation (e. g. {ServerDeleteEvent})
|
|
21
|
-
def init_server(data, bot)
|
|
22
|
-
@server = bot.server(data['id'].to_i)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# Generic event handler for member events
|
|
27
|
-
class ServerEventHandler < EventHandler
|
|
28
|
-
def matches?(event)
|
|
29
|
-
# Check for the proper event type
|
|
30
|
-
return false unless event.is_a? ServerEvent
|
|
31
|
-
|
|
32
|
-
[
|
|
33
|
-
matches_all(@attributes[:server], event.server) do |a, e|
|
|
34
|
-
a == case a
|
|
35
|
-
when String
|
|
36
|
-
e.name
|
|
37
|
-
when Integer
|
|
38
|
-
e.id
|
|
39
|
-
else
|
|
40
|
-
e
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
].reduce(true, &:&)
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
# Server is created
|
|
48
|
-
# @see OnyxCord::EventContainer#server_create
|
|
49
|
-
class ServerCreateEvent < ServerEvent; end
|
|
50
|
-
|
|
51
|
-
# Event handler for {ServerCreateEvent}
|
|
52
|
-
class ServerCreateEventHandler < ServerEventHandler; end
|
|
53
|
-
|
|
54
|
-
# Server is updated (e.g. name changed)
|
|
55
|
-
# @see OnyxCord::EventContainer#server_update
|
|
56
|
-
class ServerUpdateEvent < ServerEvent; end
|
|
57
|
-
|
|
58
|
-
# Event handler for {ServerUpdateEvent}
|
|
59
|
-
class ServerUpdateEventHandler < ServerEventHandler; end
|
|
60
|
-
|
|
61
|
-
# Server is deleted, the server was left because the bot was kicked, or the
|
|
62
|
-
# bot made itself leave the server.
|
|
63
|
-
# @see OnyxCord::EventContainer#server_delete
|
|
64
|
-
class ServerDeleteEvent < ServerEvent
|
|
65
|
-
# @return [Integer] The ID of the server that was left.
|
|
66
|
-
attr_reader :server
|
|
67
|
-
|
|
68
|
-
# @!visibility private
|
|
69
|
-
# @note Override init_server to account for the deleted server
|
|
70
|
-
def init_server(data, _bot)
|
|
71
|
-
@server = data['id'].to_i
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
# Event handler for {ServerDeleteEvent}
|
|
76
|
-
class ServerDeleteEventHandler < ServerEventHandler; end
|
|
77
|
-
|
|
78
|
-
# Emoji is created/deleted/updated
|
|
79
|
-
class ServerEmojiChangeEvent < ServerEvent
|
|
80
|
-
# @return [Server] the server in question.
|
|
81
|
-
attr_reader :server
|
|
82
|
-
|
|
83
|
-
# @return [Array<Emoji>] array of emojis.
|
|
84
|
-
attr_reader :emoji
|
|
85
|
-
|
|
86
|
-
# @!visibility private
|
|
87
|
-
def initialize(server, data, bot)
|
|
88
|
-
@bot = bot
|
|
89
|
-
@server = server
|
|
90
|
-
process_emoji(data)
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
# @!visibility private
|
|
94
|
-
def process_emoji(data)
|
|
95
|
-
@emoji = data['emojis'].map do |e|
|
|
96
|
-
@server.emoji[e['id']]
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
# Generic event helper for when an emoji is either created or deleted
|
|
102
|
-
class ServerEmojiCDEvent < ServerEvent
|
|
103
|
-
# @return [Server] the server in question.
|
|
104
|
-
attr_reader :server
|
|
105
|
-
|
|
106
|
-
# @return [Emoji] the emoji data.
|
|
107
|
-
attr_reader :emoji
|
|
108
|
-
|
|
109
|
-
# @!visibility private
|
|
110
|
-
def initialize(server, emoji, bot)
|
|
111
|
-
@bot = bot
|
|
112
|
-
@emoji = emoji
|
|
113
|
-
@server = server
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
# Emoji is created
|
|
118
|
-
class ServerEmojiCreateEvent < ServerEmojiCDEvent; end
|
|
119
|
-
|
|
120
|
-
# Emoji is deleted
|
|
121
|
-
class ServerEmojiDeleteEvent < ServerEmojiCDEvent; end
|
|
122
|
-
|
|
123
|
-
# Emoji is updated
|
|
124
|
-
class ServerEmojiUpdateEvent < ServerEvent
|
|
125
|
-
# @return [Server] the server in question.
|
|
126
|
-
attr_reader :server
|
|
127
|
-
|
|
128
|
-
# @return [Emoji, nil] the emoji data before the event.
|
|
129
|
-
attr_reader :old_emoji
|
|
130
|
-
|
|
131
|
-
# @return [Emoji, nil] the updated emoji data.
|
|
132
|
-
attr_reader :emoji
|
|
133
|
-
|
|
134
|
-
# @!visibility private
|
|
135
|
-
def initialize(server, old_emoji, emoji, bot)
|
|
136
|
-
@bot = bot
|
|
137
|
-
@old_emoji = old_emoji
|
|
138
|
-
@emoji = emoji
|
|
139
|
-
@server = server
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
# Event handler for {ServerEmojiChangeEvent}
|
|
144
|
-
class ServerEmojiChangeEventHandler < ServerEventHandler; end
|
|
145
|
-
|
|
146
|
-
# Generic handler for emoji create and delete
|
|
147
|
-
class ServerEmojiCDEventHandler < ServerEventHandler
|
|
148
|
-
def matches?(event)
|
|
149
|
-
# Check for the proper event type
|
|
150
|
-
return false unless event.is_a? ServerEmojiCDEvent
|
|
151
|
-
|
|
152
|
-
[
|
|
153
|
-
matches_all(@attributes[:server], event.server) do |a, e|
|
|
154
|
-
a == case a
|
|
155
|
-
when String
|
|
156
|
-
e.name
|
|
157
|
-
when Integer
|
|
158
|
-
e.id
|
|
159
|
-
else
|
|
160
|
-
e
|
|
161
|
-
end
|
|
162
|
-
end,
|
|
163
|
-
matches_all(@attributes[:id], event.emoji.id) { |a, e| a.resolve_id == e.resolve_id },
|
|
164
|
-
matches_all(@attributes[:name], event.emoji.name) { |a, e| a == e }
|
|
165
|
-
].reduce(true, &:&)
|
|
166
|
-
end
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
# Event handler for {ServerEmojiCreateEvent}
|
|
170
|
-
class ServerEmojiCreateEventHandler < ServerEmojiCDEventHandler; end
|
|
171
|
-
|
|
172
|
-
# Event handler for {ServerEmojiDeleteEvent}
|
|
173
|
-
class ServerEmojiDeleteEventHandler < ServerEmojiCDEventHandler; end
|
|
174
|
-
|
|
175
|
-
# Event handler for {ServerEmojiUpdateEvent}
|
|
176
|
-
class ServerEmojiUpdateEventHandler < EventHandler
|
|
177
|
-
def matches?(event)
|
|
178
|
-
# Check for the proper event type
|
|
179
|
-
return false unless event.is_a? ServerEmojiUpdateEvent
|
|
180
|
-
|
|
181
|
-
[
|
|
182
|
-
matches_all(@attributes[:server], event.server) do |a, e|
|
|
183
|
-
a == case a
|
|
184
|
-
when String
|
|
185
|
-
e.name
|
|
186
|
-
when Integer
|
|
187
|
-
e.id
|
|
188
|
-
else
|
|
189
|
-
e
|
|
190
|
-
end
|
|
191
|
-
end,
|
|
192
|
-
matches_all(@attributes[:id], event.old_emoji.id) { |a, e| a.resolve_id == e.resolve_id },
|
|
193
|
-
matches_all(@attributes[:old_name], event.old_emoji.name) { |a, e| a == e },
|
|
194
|
-
matches_all(@attributes[:name], event.emoji.name) { |a, e| a == e }
|
|
195
|
-
].reduce(true, &:&)
|
|
196
|
-
end
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
# Raised whenever an audit log entry is created.
|
|
200
|
-
class AuditLogEntryCreateEvent < Event
|
|
201
|
-
# @return [Server] the server of the audit log event.
|
|
202
|
-
attr_reader :server
|
|
203
|
-
|
|
204
|
-
# @return [AuditLogs::Entry] the entry of the audit log event.
|
|
205
|
-
attr_reader :entry
|
|
206
|
-
|
|
207
|
-
# @return [Integer] the raw action type of the audit log entry.
|
|
208
|
-
attr_reader :action
|
|
209
|
-
|
|
210
|
-
# @return [Integer] the ID of the user or bot that made the entry.
|
|
211
|
-
attr_reader :user_id
|
|
212
|
-
|
|
213
|
-
# @return [Integer, nil] the ID of the affected webhook, user, etc.
|
|
214
|
-
attr_reader :target_id
|
|
215
|
-
|
|
216
|
-
# @!visibility private
|
|
217
|
-
def initialize(data, bot)
|
|
218
|
-
@bot = bot
|
|
219
|
-
@action = data['action_type']
|
|
220
|
-
@user_id = data['user_id']&.to_i
|
|
221
|
-
@target_id = data['target_id']&.to_i
|
|
222
|
-
@server = bot.server(data['guild_id'].to_i)
|
|
223
|
-
@entry = OnyxCord::AuditLogs::Entry.new(nil, @server, @bot, data)
|
|
224
|
-
end
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
# Event handler for GUILD_AUDIT_LOG_ENTRY_CREATE events.
|
|
228
|
-
class AuditLogEntryCreateEventHandler < EventHandler
|
|
229
|
-
# @!visibility private
|
|
230
|
-
def matches?(event)
|
|
231
|
-
# Check for the proper event type.
|
|
232
|
-
return false unless event.is_a?(AuditLogEntryCreateEvent)
|
|
233
|
-
|
|
234
|
-
[
|
|
235
|
-
matches_all(@attributes[:action], event) do |a, e|
|
|
236
|
-
case a
|
|
237
|
-
when Numeric
|
|
238
|
-
a == e.action
|
|
239
|
-
when String, Symbol
|
|
240
|
-
a.to_sym == e.entry.action
|
|
241
|
-
end
|
|
242
|
-
end,
|
|
243
|
-
|
|
244
|
-
matches_all(@attributes[:reason], event.entry) do |a, e|
|
|
245
|
-
if e.reason
|
|
246
|
-
case a
|
|
247
|
-
when String
|
|
248
|
-
a == e.reason
|
|
249
|
-
when Regexp
|
|
250
|
-
a.match?(e.reason)
|
|
251
|
-
end
|
|
252
|
-
end
|
|
253
|
-
end,
|
|
254
|
-
|
|
255
|
-
matches_all(@attributes[:user], event.user_id) do |a, e|
|
|
256
|
-
a&.resolve_id == e&.resolve_id
|
|
257
|
-
end,
|
|
258
|
-
|
|
259
|
-
matches_all(@attributes[:server], event.server) do |a, e|
|
|
260
|
-
a&.resolve_id == e&.resolve_id
|
|
261
|
-
end,
|
|
262
|
-
|
|
263
|
-
matches_all(@attributes[:target], event.target_id) do |a, e|
|
|
264
|
-
a&.resolve_id == e&.resolve_id
|
|
265
|
-
end
|
|
266
|
-
].reduce(true, &:&)
|
|
267
|
-
end
|
|
268
|
-
end
|
|
269
|
-
end
|
|
3
|
+
require 'onyxcord/events/guilds/base'
|
|
4
|
+
require 'onyxcord/events/guilds/emoji'
|
|
5
|
+
require 'onyxcord/events/guilds/audit_logs'
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OnyxCord
|
|
4
|
+
module EventContainer
|
|
5
|
+
# This **event** is raised when a channel is created.
|
|
6
|
+
# @param attributes [Hash] The event's attributes.
|
|
7
|
+
# @option attributes [Integer] :type Matches the type of channel that is being created (0: text, 1: private, 2: voice, 3: group)
|
|
8
|
+
# @option attributes [String] :name Matches the name of the created channel.
|
|
9
|
+
# @yield The block is executed when the event is raised.
|
|
10
|
+
# @yieldparam event [ChannelCreateEvent] The event that was raised.
|
|
11
|
+
# @return [ChannelCreateEventHandler] the event handler that was registered.
|
|
12
|
+
def channel_create(attributes = {}, &block)
|
|
13
|
+
register_event(ChannelCreateEvent, attributes, block)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# This **event** is raised when a channel is updated.
|
|
17
|
+
# @param attributes [Hash] The event's attributes.
|
|
18
|
+
# @option attributes [Integer] :type Matches the type of channel that is being updated (0: text, 1: private, 2: voice, 3: group).
|
|
19
|
+
# @option attributes [String] :name Matches the new name of the channel.
|
|
20
|
+
# @yield The block is executed when the event is raised.
|
|
21
|
+
# @yieldparam event [ChannelUpdateEvent] The event that was raised.
|
|
22
|
+
# @return [ChannelUpdateEventHandler] the event handler that was registered.
|
|
23
|
+
|
|
24
|
+
# This **event** is raised when a channel is updated.
|
|
25
|
+
# @param attributes [Hash] The event's attributes.
|
|
26
|
+
# @option attributes [Integer] :type Matches the type of channel that is being updated (0: text, 1: private, 2: voice, 3: group).
|
|
27
|
+
# @option attributes [String] :name Matches the new name of the channel.
|
|
28
|
+
# @yield The block is executed when the event is raised.
|
|
29
|
+
# @yieldparam event [ChannelUpdateEvent] The event that was raised.
|
|
30
|
+
# @return [ChannelUpdateEventHandler] the event handler that was registered.
|
|
31
|
+
def channel_update(attributes = {}, &block)
|
|
32
|
+
register_event(ChannelUpdateEvent, attributes, block)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# This **event** is raised when a channel is deleted.
|
|
36
|
+
# @param attributes [Hash] The event's attributes.
|
|
37
|
+
# @option attributes [Integer] :type Matches the type of channel that is being deleted (0: text, 1: private, 2: voice, 3: group).
|
|
38
|
+
# @option attributes [String] :name Matches the name of the deleted channel.
|
|
39
|
+
# @yield The block is executed when the event is raised.
|
|
40
|
+
# @yieldparam event [ChannelDeleteEvent] The event that was raised.
|
|
41
|
+
# @return [ChannelDeleteEventHandler] the event handler that was registered.
|
|
42
|
+
|
|
43
|
+
# This **event** is raised when a channel is deleted.
|
|
44
|
+
# @param attributes [Hash] The event's attributes.
|
|
45
|
+
# @option attributes [Integer] :type Matches the type of channel that is being deleted (0: text, 1: private, 2: voice, 3: group).
|
|
46
|
+
# @option attributes [String] :name Matches the name of the deleted channel.
|
|
47
|
+
# @yield The block is executed when the event is raised.
|
|
48
|
+
# @yieldparam event [ChannelDeleteEvent] The event that was raised.
|
|
49
|
+
# @return [ChannelDeleteEventHandler] the event handler that was registered.
|
|
50
|
+
def channel_delete(attributes = {}, &block)
|
|
51
|
+
register_event(ChannelDeleteEvent, attributes, block)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# This **event** is raised when a recipient is added to a group channel.
|
|
55
|
+
# @param attributes [Hash] The event's attributes.
|
|
56
|
+
# @option attributes [String] :name Matches the name of the group channel that the recipient is added to.
|
|
57
|
+
# @option attributes [String, Integer] :owner_id Matches the ID of the group channel's owner.
|
|
58
|
+
# @option attributes [String, Integer] :id Matches the ID of the recipient added to the group channel.
|
|
59
|
+
# @yield The block is executed when the event is raised.
|
|
60
|
+
# @yieldparam event [ChannelRecipientAddEvent] The event that was raised.
|
|
61
|
+
# @return [ChannelRecipientAddHandler] the event handler that was registered.
|
|
62
|
+
|
|
63
|
+
# This **event** is raised when a recipient is added to a group channel.
|
|
64
|
+
# @param attributes [Hash] The event's attributes.
|
|
65
|
+
# @option attributes [String] :name Matches the name of the group channel that the recipient is added to.
|
|
66
|
+
# @option attributes [String, Integer] :owner_id Matches the ID of the group channel's owner.
|
|
67
|
+
# @option attributes [String, Integer] :id Matches the ID of the recipient added to the group channel.
|
|
68
|
+
# @yield The block is executed when the event is raised.
|
|
69
|
+
# @yieldparam event [ChannelRecipientAddEvent] The event that was raised.
|
|
70
|
+
# @return [ChannelRecipientAddHandler] the event handler that was registered.
|
|
71
|
+
def channel_recipient_add(attributes = {}, &block)
|
|
72
|
+
register_event(ChannelRecipientAddEvent, attributes, block)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# This **event** is raised when a recipient is removed from a group channel.
|
|
76
|
+
# @param attributes [Hash] The event's attributes.
|
|
77
|
+
# @option attributes [String] :name Matches the name of the group channel that the recipient is added to.
|
|
78
|
+
# @option attributes [String, Integer] :owner_id Matches the ID of the group channel's owner.
|
|
79
|
+
# @option attributes [String, Integer] :id Matches the ID of the recipient removed from the group channel.
|
|
80
|
+
# @yield The block is executed when the event is raised.
|
|
81
|
+
# @yieldparam event [ChannelRecipientRemoveEvent] The event that was raised.
|
|
82
|
+
# @return [ChannelRecipientRemoveHandler] the event handler that was registered.
|
|
83
|
+
|
|
84
|
+
# This **event** is raised when a recipient is removed from a group channel.
|
|
85
|
+
# @param attributes [Hash] The event's attributes.
|
|
86
|
+
# @option attributes [String] :name Matches the name of the group channel that the recipient is added to.
|
|
87
|
+
# @option attributes [String, Integer] :owner_id Matches the ID of the group channel's owner.
|
|
88
|
+
# @option attributes [String, Integer] :id Matches the ID of the recipient removed from the group channel.
|
|
89
|
+
# @yield The block is executed when the event is raised.
|
|
90
|
+
# @yieldparam event [ChannelRecipientRemoveEvent] The event that was raised.
|
|
91
|
+
# @return [ChannelRecipientRemoveHandler] the event handler that was registered.
|
|
92
|
+
def channel_recipient_remove(attributes = {}, &block)
|
|
93
|
+
register_event(ChannelRecipientRemoveEvent, attributes, block)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# This **event** is raised when a user's voice state changes. This includes when a user joins, leaves, or
|
|
97
|
+
# moves between voice channels, as well as their mute and deaf status for themselves and on the server.
|
|
98
|
+
# @param attributes [Hash] The event's attributes.
|
|
99
|
+
# @option attributes [String, Integer, User] :from Matches the user that raised the event.
|
|
100
|
+
# @option attributes [String, Integer, Channel] :channel Matches the voice channel the user has joined.
|
|
101
|
+
# @option attributes [String, Integer, Channel] :old_channel Matches the voice channel the user was in previously.
|
|
102
|
+
# @option attributes [true, false] :mute Matches whether or not the user is muted server-wide.
|
|
103
|
+
# @option attributes [true, false] :deaf Matches whether or not the user is deafened server-wide.
|
|
104
|
+
# @option attributes [true, false] :self_mute Matches whether or not the user is muted by the bot.
|
|
105
|
+
# @option attributes [true, false] :self_deaf Matches whether or not the user is deafened by the bot.
|
|
106
|
+
# @yield The block is executed when the event is raised.
|
|
107
|
+
# @yieldparam event [VoiceStateUpdateEvent] The event that was raised.
|
|
108
|
+
# @return [VoiceStateUpdateEventHandler] the event handler that was registered.
|
|
109
|
+
|
|
110
|
+
# This **event** is raised whenever a message is pinned or unpinned.
|
|
111
|
+
# @param attributes [Hash] The event's attributes.
|
|
112
|
+
# @option attributes [String, Integer, Channel] :channel A channel to match against.
|
|
113
|
+
# @option attributes [String, Integer, Server] :server A server to match against.
|
|
114
|
+
# @yield The block is executed when the event is raised.
|
|
115
|
+
# @yieldparam event [ChannelPinsUpdateEvent] The event that was raised.
|
|
116
|
+
# @return [ChannelPinsUpdateEventHandler] The event handler that was registered.
|
|
117
|
+
def channel_pins_update(attributes = {}, &block)
|
|
118
|
+
register_event(ChannelPinsUpdateEvent, attributes, block)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# This **event** is raised whenever an autocomplete interaction is created.
|
|
122
|
+
# @param name [String, Symbol, nil] An option name to match against.
|
|
123
|
+
# @param attributes [Hash] The event's attributes.
|
|
124
|
+
# @option attributes [String, Integer] :command_id A command ID to match against.
|
|
125
|
+
# @option attributes [String, Symbol] :subcommand A subcommand name to match against.
|
|
126
|
+
# @option attributes [String, Symbol] :subcommand_group A subcommand group to match against.
|
|
127
|
+
# @option attributes [String, Symbol] :command_name A command name to match against.
|
|
128
|
+
# @option attributes [String, Integer, Server] :server A server to match against.
|
|
129
|
+
# @yield The block is executed when the event is raised.
|
|
130
|
+
# @yieldparam event [AutocompleteEvent] The event that was raised.
|
|
131
|
+
# @return [AutocompleteEventHandler] The event handler that was registered.
|
|
132
|
+
end
|
|
133
|
+
end
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OnyxCord
|
|
4
|
+
module EventContainer
|
|
5
|
+
# Removes an event handler from this container. If you're looking for a way to do temporary events, I recommend
|
|
6
|
+
# {Await}s instead of this.
|
|
7
|
+
# @param handler [OnyxCord::Events::EventHandler] The handler to remove.
|
|
8
|
+
def remove_handler(handler)
|
|
9
|
+
if handler.is_a?(OnyxCord::Events::RawDispatchHandler)
|
|
10
|
+
@raw_handlers&.delete(handler)
|
|
11
|
+
return
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
clazz = EventContainer.event_class(handler.class)
|
|
15
|
+
@event_handlers ||= {}
|
|
16
|
+
@event_handlers[clazz].delete(handler)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Remove an application command handler
|
|
20
|
+
# @param name [String, Symbol] The name of the command handler to remove.
|
|
21
|
+
|
|
22
|
+
# Remove an application command handler
|
|
23
|
+
# @param name [String, Symbol] The name of the command handler to remove.
|
|
24
|
+
def remove_application_command_handler(name)
|
|
25
|
+
@application_commands.delete(name)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Removes all events from this event handler.
|
|
29
|
+
|
|
30
|
+
# Removes all events from this event handler.
|
|
31
|
+
def clear!
|
|
32
|
+
@event_handlers&.clear
|
|
33
|
+
@raw_handlers&.clear
|
|
34
|
+
@application_commands&.clear
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Adds an event handler to this container. Usually, it's more expressive to just use one of the shorthand adder
|
|
38
|
+
# methods like {#message}, but if you want to create one manually you can use this.
|
|
39
|
+
# @param handler [OnyxCord::Events::EventHandler] The handler to add.
|
|
40
|
+
|
|
41
|
+
# Adds an event handler to this container. Usually, it's more expressive to just use one of the shorthand adder
|
|
42
|
+
# methods like {#message}, but if you want to create one manually you can use this.
|
|
43
|
+
# @param handler [OnyxCord::Events::EventHandler] The handler to add.
|
|
44
|
+
def add_handler(handler)
|
|
45
|
+
clazz = EventContainer.event_class(handler.class)
|
|
46
|
+
@event_handlers ||= {}
|
|
47
|
+
@event_handlers[clazz] ||= []
|
|
48
|
+
@event_handlers[clazz] << handler
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Adds all event handlers from another container into this one. Existing event handlers will be overwritten.
|
|
52
|
+
# @param container [Module] A module that `extend`s {EventContainer} from which the handlers will be added.
|
|
53
|
+
|
|
54
|
+
# Adds all event handlers from another container into this one. Existing event handlers will be overwritten.
|
|
55
|
+
# @param container [Module] A module that `extend`s {EventContainer} from which the handlers will be added.
|
|
56
|
+
def include_events(container)
|
|
57
|
+
application_command_handlers = container.instance_variable_get(:@application_commands)
|
|
58
|
+
handlers = container.instance_variable_get :@event_handlers
|
|
59
|
+
raw_handlers = container.instance_variable_get(:@raw_handlers)
|
|
60
|
+
return unless handlers || application_command_handlers || raw_handlers
|
|
61
|
+
|
|
62
|
+
@event_handlers ||= {}
|
|
63
|
+
@event_handlers.merge!(handlers || {}) { |_, old, new| old + new }
|
|
64
|
+
|
|
65
|
+
@raw_handlers ||= []
|
|
66
|
+
@raw_handlers.concat(raw_handlers || [])
|
|
67
|
+
|
|
68
|
+
@application_commands ||= {}
|
|
69
|
+
|
|
70
|
+
@application_commands.merge!(application_command_handlers || {}) do |_, old, new|
|
|
71
|
+
old.subcommands.merge!(new.subcommands)
|
|
72
|
+
old
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
alias_method :include!, :include_events
|
|
77
|
+
alias_method :<<, :add_handler
|
|
78
|
+
|
|
79
|
+
# Returns the handler class for an event class type
|
|
80
|
+
# @see #event_class
|
|
81
|
+
# @param event_class [Class] The event type
|
|
82
|
+
# @return [Class] the handler type
|
|
83
|
+
|
|
84
|
+
# Returns the handler class for an event class type
|
|
85
|
+
# @see #event_class
|
|
86
|
+
# @param event_class [Class] The event type
|
|
87
|
+
# @return [Class] the handler type
|
|
88
|
+
def self.handler_class(event_class)
|
|
89
|
+
class_from_string("#{event_class}Handler")
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Returns the event class for a handler class type
|
|
93
|
+
# @see #handler_class
|
|
94
|
+
# @param handler_class [Class] The handler type
|
|
95
|
+
# @return [Class, nil] the event type, or nil if the handler_class isn't a handler class (i.e. ends with Handler)
|
|
96
|
+
|
|
97
|
+
# Returns the event class for a handler class type
|
|
98
|
+
# @see #handler_class
|
|
99
|
+
# @param handler_class [Class] The handler type
|
|
100
|
+
# @return [Class, nil] the event type, or nil if the handler_class isn't a handler class (i.e. ends with Handler)
|
|
101
|
+
def self.event_class(handler_class)
|
|
102
|
+
class_name = handler_class.to_s
|
|
103
|
+
return nil unless class_name.end_with? 'Handler'
|
|
104
|
+
|
|
105
|
+
EventContainer.class_from_string(class_name[0..-8])
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Utility method to return a class object from a string of its name. Mostly useful for internal stuff
|
|
109
|
+
# @param str [String] The name of the class
|
|
110
|
+
# @return [Class] the class
|
|
111
|
+
|
|
112
|
+
# Utility method to return a class object from a string of its name. Mostly useful for internal stuff
|
|
113
|
+
# @param str [String] The name of the class
|
|
114
|
+
# @return [Class] the class
|
|
115
|
+
def self.class_from_string(str)
|
|
116
|
+
str.split('::').inject(Object) do |mod, class_name|
|
|
117
|
+
mod.const_get(class_name)
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
private
|
|
122
|
+
|
|
123
|
+
include OnyxCord::Events
|
|
124
|
+
|
|
125
|
+
# @return [EventHandler]
|
|
126
|
+
|
|
127
|
+
# @return [EventHandler]
|
|
128
|
+
def register_event(clazz, attributes, block)
|
|
129
|
+
handler = EventContainer.handler_class(clazz).new(attributes, block)
|
|
130
|
+
|
|
131
|
+
@event_handlers ||= {}
|
|
132
|
+
@event_handlers[clazz] ||= []
|
|
133
|
+
@event_handlers[clazz] << handler
|
|
134
|
+
|
|
135
|
+
# Return the handler so it can be removed later
|
|
136
|
+
handler
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def register_raw_handler(filter, block)
|
|
140
|
+
handler = OnyxCord::Events::RawDispatchHandler.new(filter, block)
|
|
141
|
+
@raw_handlers ||= []
|
|
142
|
+
@raw_handlers << handler
|
|
143
|
+
handler
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|