onyxcord 2.0.13 → 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.
Files changed (270) hide show
  1. checksums.yaml +4 -4
  2. data/lib/onyxcord/application_commands/command.rb +4 -97
  3. data/lib/onyxcord/application_commands/context.rb +4 -94
  4. data/lib/onyxcord/application_commands/option.rb +4 -75
  5. data/lib/onyxcord/application_commands/registry.rb +4 -45
  6. data/lib/onyxcord/application_commands.rb +8 -5
  7. data/lib/onyxcord/bot.rb +24 -1759
  8. data/lib/onyxcord/{cache.rb → cache/manager.rb} +16 -14
  9. data/lib/onyxcord/cache/stores/gateway.rb +272 -0
  10. data/lib/onyxcord/commands/bot/channels.rb +48 -0
  11. data/lib/onyxcord/commands/bot/execution.rb +174 -0
  12. data/lib/onyxcord/commands/bot/message_dispatch.rb +58 -0
  13. data/lib/onyxcord/commands/bot/permissions.rb +72 -0
  14. data/lib/onyxcord/commands/bot.rb +209 -0
  15. data/lib/onyxcord/commands/container.rb +21 -2
  16. data/lib/onyxcord/commands/parser.rb +30 -1
  17. data/lib/onyxcord/container.rb +16 -960
  18. data/lib/onyxcord/core/bot/application_commands.rb +210 -0
  19. data/lib/onyxcord/core/bot/awaits.rb +112 -0
  20. data/lib/onyxcord/core/bot/invites.rb +42 -0
  21. data/lib/onyxcord/core/bot/messaging.rb +161 -0
  22. data/lib/onyxcord/core/bot/oauth.rb +27 -0
  23. data/lib/onyxcord/core/bot/presence.rb +103 -0
  24. data/lib/onyxcord/core/bot/runtime.rb +183 -0
  25. data/lib/onyxcord/core/bot/voice.rb +69 -0
  26. data/lib/onyxcord/{errors.rb → core/errors.rb} +18 -3
  27. data/lib/onyxcord/{logger.rb → core/logger.rb} +5 -0
  28. data/lib/onyxcord/core/version.rb +5 -0
  29. data/lib/onyxcord/events/await/base.rb +48 -0
  30. data/lib/onyxcord/events/await.rb +1 -46
  31. data/lib/onyxcord/events/ban/base.rb +54 -0
  32. data/lib/onyxcord/events/ban/remove.rb +11 -0
  33. data/lib/onyxcord/events/bans.rb +2 -58
  34. data/lib/onyxcord/events/channels/base.rb +91 -0
  35. data/lib/onyxcord/events/channels/delete.rb +73 -0
  36. data/lib/onyxcord/events/channels/pins.rb +44 -0
  37. data/lib/onyxcord/events/channels/recipients.rb +77 -0
  38. data/lib/onyxcord/events/channels.rb +4 -239
  39. data/lib/onyxcord/events/guilds/audit_logs.rb +79 -0
  40. data/lib/onyxcord/events/guilds/base.rb +97 -0
  41. data/lib/onyxcord/events/guilds/emoji.rb +147 -0
  42. data/lib/onyxcord/events/guilds.rb +3 -267
  43. data/lib/onyxcord/events/handlers/channels.rb +133 -0
  44. data/lib/onyxcord/events/handlers/core.rb +146 -0
  45. data/lib/onyxcord/events/handlers/guilds.rb +375 -0
  46. data/lib/onyxcord/events/handlers/interactions.rb +238 -0
  47. data/lib/onyxcord/events/handlers/lifetime.rb +71 -0
  48. data/lib/onyxcord/events/handlers/messages.rb +218 -0
  49. data/lib/onyxcord/events/handlers/presence.rb +56 -0
  50. data/lib/onyxcord/events/handlers/raw.rb +39 -0
  51. data/lib/onyxcord/events/handlers/reactions.rb +98 -0
  52. data/lib/onyxcord/events/handlers/scheduled_events.rb +243 -0
  53. data/lib/onyxcord/events/handlers/voice.rb +46 -0
  54. data/lib/onyxcord/events/integration/base.rb +45 -0
  55. data/lib/onyxcord/events/integration/create.rb +11 -0
  56. data/lib/onyxcord/events/integration/delete.rb +48 -0
  57. data/lib/onyxcord/events/integration/update.rb +11 -0
  58. data/lib/onyxcord/events/integrations.rb +4 -98
  59. data/lib/onyxcord/events/interactions/application_commands.rb +185 -0
  60. data/lib/onyxcord/events/interactions/autocomplete.rb +62 -0
  61. data/lib/onyxcord/events/interactions/base.rb +175 -0
  62. data/lib/onyxcord/events/interactions/components.rb +221 -0
  63. data/lib/onyxcord/events/interactions/permissions.rb +53 -0
  64. data/lib/onyxcord/events/interactions.rb +5 -622
  65. data/lib/onyxcord/events/invite/create.rb +79 -0
  66. data/lib/onyxcord/events/invite/delete.rb +55 -0
  67. data/lib/onyxcord/events/invites.rb +2 -125
  68. data/lib/onyxcord/events/lifetime/base.rb +31 -0
  69. data/lib/onyxcord/events/lifetime.rb +1 -29
  70. data/lib/onyxcord/events/member/add.rb +12 -0
  71. data/lib/onyxcord/events/member/base.rb +67 -0
  72. data/lib/onyxcord/events/member/delete.rb +21 -0
  73. data/lib/onyxcord/events/member/update.rb +25 -0
  74. data/lib/onyxcord/events/members.rb +4 -108
  75. data/lib/onyxcord/events/message/base.rb +295 -0
  76. data/lib/onyxcord/events/message/ids.rb +71 -0
  77. data/lib/onyxcord/events/message/mentions.rb +55 -0
  78. data/lib/onyxcord/events/message/updates.rb +27 -0
  79. data/lib/onyxcord/events/message.rb +4 -397
  80. data/lib/onyxcord/events/poll/add.rb +11 -0
  81. data/lib/onyxcord/events/poll/base.rb +106 -0
  82. data/lib/onyxcord/events/poll/remove.rb +11 -0
  83. data/lib/onyxcord/events/polls.rb +3 -116
  84. data/lib/onyxcord/events/presence/playing.rb +77 -0
  85. data/lib/onyxcord/events/presence/status.rb +60 -0
  86. data/lib/onyxcord/events/presence.rb +2 -129
  87. data/lib/onyxcord/events/raw/base.rb +74 -0
  88. data/lib/onyxcord/events/raw.rb +1 -72
  89. data/lib/onyxcord/events/reactions/base.rb +143 -0
  90. data/lib/onyxcord/events/reactions/clear.rb +99 -0
  91. data/lib/onyxcord/events/reactions.rb +2 -216
  92. data/lib/onyxcord/events/role/create.rb +46 -0
  93. data/lib/onyxcord/events/role/delete.rb +40 -0
  94. data/lib/onyxcord/events/role/update.rb +11 -0
  95. data/lib/onyxcord/events/roles.rb +3 -85
  96. data/lib/onyxcord/events/scheduled_events/events.rb +112 -0
  97. data/lib/onyxcord/events/scheduled_events/users.rb +91 -0
  98. data/lib/onyxcord/events/scheduled_events.rb +2 -169
  99. data/lib/onyxcord/events/thread/base.rb +49 -0
  100. data/lib/onyxcord/events/thread/members.rb +44 -0
  101. data/lib/onyxcord/events/thread/update.rb +18 -0
  102. data/lib/onyxcord/events/threads.rb +3 -98
  103. data/lib/onyxcord/events/typing/base.rb +73 -0
  104. data/lib/onyxcord/events/typing.rb +1 -71
  105. data/lib/onyxcord/events/voice/server_update.rb +48 -0
  106. data/lib/onyxcord/events/voice/state_update.rb +137 -0
  107. data/lib/onyxcord/events/voice_server_update.rb +2 -46
  108. data/lib/onyxcord/events/voice_state_update.rb +2 -135
  109. data/lib/onyxcord/events/webhook/update.rb +65 -0
  110. data/lib/onyxcord/events/webhooks.rb +1 -63
  111. data/lib/onyxcord/gateway/client.rb +460 -0
  112. data/lib/onyxcord/interactions/command.rb +120 -0
  113. data/lib/onyxcord/interactions/context.rb +109 -0
  114. data/lib/onyxcord/interactions/internal/application_command.rb +203 -0
  115. data/lib/onyxcord/interactions/internal/message.rb +152 -0
  116. data/lib/onyxcord/interactions/internal/metadata.rb +109 -0
  117. data/lib/onyxcord/interactions/internal/option_builder.rb +230 -0
  118. data/lib/onyxcord/interactions/internal/permission_builder.rb +90 -0
  119. data/lib/onyxcord/interactions/option.rb +88 -0
  120. data/lib/onyxcord/interactions/registry.rb +50 -0
  121. data/lib/onyxcord/interactions.rb +16 -0
  122. data/lib/onyxcord/internal/async_runtime.rb +32 -0
  123. data/lib/onyxcord/internal/event_bus.rb +591 -0
  124. data/lib/onyxcord/internal/event_executor.rb +155 -0
  125. data/lib/onyxcord/internal/gateway/opcodes.rb +22 -0
  126. data/lib/onyxcord/internal/gateway/session.rb +45 -0
  127. data/lib/onyxcord/internal/http.rb +189 -0
  128. data/lib/onyxcord/internal/json.rb +51 -0
  129. data/lib/onyxcord/internal/message_payload.rb +78 -0
  130. data/lib/onyxcord/internal/rate_limiter/async_rest.rb +151 -0
  131. data/lib/onyxcord/internal/rate_limiter/gateway.rb +44 -0
  132. data/lib/onyxcord/internal/rate_limiter/rest.rb +144 -0
  133. data/lib/onyxcord/internal/upload.rb +39 -0
  134. data/lib/onyxcord/internal/websocket.rb +79 -0
  135. data/lib/onyxcord/light/data.rb +1 -1
  136. data/lib/onyxcord/light/integrations.rb +1 -1
  137. data/lib/onyxcord/light/light_bot.rb +7 -7
  138. data/lib/onyxcord/{data → models}/activity.rb +2 -2
  139. data/lib/onyxcord/{data → models}/application.rb +3 -3
  140. data/lib/onyxcord/{data → models}/avatar_decoration.rb +1 -1
  141. data/lib/onyxcord/{data → models}/channel.rb +23 -23
  142. data/lib/onyxcord/{data → models}/collectibles.rb +1 -1
  143. data/lib/onyxcord/{data → models}/emoji.rb +1 -1
  144. data/lib/onyxcord/models/interaction.rb +450 -0
  145. data/lib/onyxcord/{data → models}/invite.rb +1 -1
  146. data/lib/onyxcord/{data → models}/member.rb +11 -11
  147. data/lib/onyxcord/{data → models}/message.rb +22 -14
  148. data/lib/onyxcord/{data → models}/poll.rb +2 -2
  149. data/lib/onyxcord/{data → models}/primary_server.rb +1 -1
  150. data/lib/onyxcord/{data → models}/profile.rb +4 -4
  151. data/lib/onyxcord/{data → models}/role.rb +6 -12
  152. data/lib/onyxcord/{data → models}/scheduled_event.rb +5 -5
  153. data/lib/onyxcord/{data → models}/server.rb +41 -41
  154. data/lib/onyxcord/{data → models}/server_preview.rb +2 -2
  155. data/lib/onyxcord/{data → models}/team.rb +1 -1
  156. data/lib/onyxcord/{data → models}/user.rb +5 -5
  157. data/lib/onyxcord/{data → models}/webhook.rb +13 -11
  158. data/lib/onyxcord/models.rb +57 -0
  159. data/lib/onyxcord/{api.rb → rest/client.rb} +83 -27
  160. data/lib/onyxcord/{api → rest/routes}/application.rb +79 -57
  161. data/lib/onyxcord/rest/routes/channel/base.rb +73 -0
  162. data/lib/onyxcord/rest/routes/channel/groups.rb +78 -0
  163. data/lib/onyxcord/rest/routes/channel/messages.rb +130 -0
  164. data/lib/onyxcord/rest/routes/channel/permissions.rb +73 -0
  165. data/lib/onyxcord/rest/routes/channel/pins.rb +45 -0
  166. data/lib/onyxcord/rest/routes/channel/polls.rb +32 -0
  167. data/lib/onyxcord/rest/routes/channel/reactions.rb +86 -0
  168. data/lib/onyxcord/rest/routes/channel/threads.rb +176 -0
  169. data/lib/onyxcord/rest/routes/channel/webhooks.rb +47 -0
  170. data/lib/onyxcord/rest/routes/channel.rb +12 -0
  171. data/lib/onyxcord/{api/interaction.rb → rest/routes/interaction/base.rb} +10 -33
  172. data/lib/onyxcord/rest/routes/interaction/response.rb +24 -0
  173. data/lib/onyxcord/rest/routes/interaction.rb +4 -0
  174. data/lib/onyxcord/{api → rest/routes}/invite.rb +7 -7
  175. data/lib/onyxcord/rest/routes/server/admin.rb +174 -0
  176. data/lib/onyxcord/rest/routes/server/assets.rb +25 -0
  177. data/lib/onyxcord/rest/routes/server/bans.rb +67 -0
  178. data/lib/onyxcord/rest/routes/server/base.rb +77 -0
  179. data/lib/onyxcord/rest/routes/server/channels.rb +58 -0
  180. data/lib/onyxcord/rest/routes/server/emoji.rb +48 -0
  181. data/lib/onyxcord/rest/routes/server/members.rb +109 -0
  182. data/lib/onyxcord/rest/routes/server/messages.rb +19 -0
  183. data/lib/onyxcord/rest/routes/server/roles.rb +156 -0
  184. data/lib/onyxcord/rest/routes/server/scheduled_events.rb +86 -0
  185. data/lib/onyxcord/rest/routes/server.rb +12 -0
  186. data/lib/onyxcord/{api → rest/routes}/user.rb +23 -23
  187. data/lib/onyxcord/{api → rest/routes}/webhook.rb +30 -32
  188. data/lib/onyxcord/{allowed_mentions.rb → utils/allowed_mentions.rb} +9 -1
  189. data/lib/onyxcord/utils/timestamp.rb +69 -0
  190. data/lib/onyxcord/voice/{voice_bot.rb → client.rb} +4 -4
  191. data/lib/onyxcord/voice/encoder.rb +1 -1
  192. data/lib/onyxcord/voice/network/udp.rb +135 -0
  193. data/lib/onyxcord/voice/network/websocket.rb +225 -0
  194. data/lib/onyxcord/voice/network.rb +5 -357
  195. data/lib/onyxcord/webhooks/builder.rb +1 -1
  196. data/lib/onyxcord/webhooks/client.rb +13 -13
  197. data/lib/onyxcord/webhooks/modal/group_builder.rb +55 -0
  198. data/lib/onyxcord/webhooks/modal/label_builder.rb +183 -0
  199. data/lib/onyxcord/webhooks/modal.rb +2 -239
  200. data/lib/onyxcord/webhooks/version.rb +3 -3
  201. data/lib/onyxcord/webhooks/view/container_builder.rb +80 -0
  202. data/lib/onyxcord/webhooks/view/file_builder.rb +24 -0
  203. data/lib/onyxcord/webhooks/view/media_gallery_builder.rb +50 -0
  204. data/lib/onyxcord/webhooks/view/row_builder.rb +120 -0
  205. data/lib/onyxcord/webhooks/view/section_builder.rb +61 -0
  206. data/lib/onyxcord/webhooks/view/select_menu_builder.rb +77 -0
  207. data/lib/onyxcord/webhooks/view/separator_builder.rb +22 -0
  208. data/lib/onyxcord/webhooks/view/text_display_builder.rb +20 -0
  209. data/lib/onyxcord/webhooks/view.rb +9 -425
  210. data/lib/onyxcord.rb +106 -40
  211. metadata +208 -91
  212. data/.github/CONTRIBUTING.md +0 -13
  213. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  214. data/.github/ISSUE_TEMPLATE/feature_request.md +0 -24
  215. data/.github/pull_request_template.md +0 -37
  216. data/.github/workflows/ci.yml +0 -78
  217. data/.github/workflows/codeql.yml +0 -65
  218. data/.github/workflows/deploy.yml +0 -54
  219. data/.github/workflows/release.yml +0 -51
  220. data/.gitignore +0 -17
  221. data/.markdownlint.json +0 -4
  222. data/.overcommit.yml +0 -7
  223. data/.rspec +0 -2
  224. data/.rubocop.yml +0 -129
  225. data/.yardopts +0 -1
  226. data/CHANGELOG.md +0 -202
  227. data/Gemfile +0 -6
  228. data/LICENSE.txt +0 -21
  229. data/README.md +0 -448
  230. data/Rakefile +0 -13
  231. data/lib/onyxcord/api/channel.rb +0 -705
  232. data/lib/onyxcord/api/server.rb +0 -775
  233. data/lib/onyxcord/async/runtime.rb +0 -30
  234. data/lib/onyxcord/commands/command_bot.rb +0 -505
  235. data/lib/onyxcord/data/interaction.rb +0 -1143
  236. data/lib/onyxcord/data.rb +0 -57
  237. data/lib/onyxcord/event_executor.rb +0 -153
  238. data/lib/onyxcord/gateway.rb +0 -500
  239. data/lib/onyxcord/http.rb +0 -115
  240. data/lib/onyxcord/json.rb +0 -49
  241. data/lib/onyxcord/rate_limiter/async_rest.rb +0 -149
  242. data/lib/onyxcord/rate_limiter/gateway.rb +0 -42
  243. data/lib/onyxcord/rate_limiter/rest.rb +0 -142
  244. data/lib/onyxcord/version.rb +0 -7
  245. data/lib/onyxcord/websocket.rb +0 -77
  246. data/onyxcord.gemspec +0 -63
  247. /data/lib/onyxcord/{configuration.rb → core/configuration.rb} +0 -0
  248. /data/lib/onyxcord/{data → models}/attachment.rb +0 -0
  249. /data/lib/onyxcord/{data → models}/audit_logs.rb +0 -0
  250. /data/lib/onyxcord/{data → models}/call.rb +0 -0
  251. /data/lib/onyxcord/{data → models}/channel_tag.rb +0 -0
  252. /data/lib/onyxcord/{data → models}/component.rb +0 -0
  253. /data/lib/onyxcord/{data → models}/embed.rb +0 -0
  254. /data/lib/onyxcord/{data → models}/install_params.rb +0 -0
  255. /data/lib/onyxcord/{data → models}/integration.rb +0 -0
  256. /data/lib/onyxcord/{data → models}/message_activity.rb +0 -0
  257. /data/lib/onyxcord/{data → models}/overwrite.rb +0 -0
  258. /data/lib/onyxcord/{data → models}/reaction.rb +0 -0
  259. /data/lib/onyxcord/{data → models}/recipient.rb +0 -0
  260. /data/lib/onyxcord/{data → models}/role_connection_data.rb +0 -0
  261. /data/lib/onyxcord/{data → models}/role_subscription.rb +0 -0
  262. /data/lib/onyxcord/{data → models}/snapshot.rb +0 -0
  263. /data/lib/onyxcord/{data → models}/timestamp.rb +0 -0
  264. /data/lib/onyxcord/{data → models}/voice_region.rb +0 -0
  265. /data/lib/onyxcord/{data → models}/voice_state.rb +0 -0
  266. /data/lib/onyxcord/{colour_rgb.rb → utils/colour_rgb.rb} +0 -0
  267. /data/lib/onyxcord/{id_object.rb → utils/id_object.rb} +0 -0
  268. /data/lib/onyxcord/{message_components.rb → utils/message_components.rb} +0 -0
  269. /data/lib/onyxcord/{paginator.rb → utils/paginator.rb} +0 -0
  270. /data/lib/onyxcord/{permissions.rb → utils/permissions.rb} +0 -0
@@ -0,0 +1,375 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OnyxCord
4
+ module EventContainer
5
+ # This **event** is raised when a new user joins a server.
6
+ # @param attributes [Hash] The event's attributes.
7
+ # @option attributes [String] :username Matches the username of the joined user.
8
+ # @yield The block is executed when the event is raised.
9
+ # @yieldparam event [ServerMemberAddEvent] The event that was raised.
10
+ # @return [ServerMemberAddEventHandler] the event handler that was registered.
11
+ def member_join(attributes = {}, &block)
12
+ register_event(ServerMemberAddEvent, attributes, block)
13
+ end
14
+
15
+ # This **event** is raised when a member update happens. This includes when a members nickname
16
+ # or roles are updated.
17
+ # @param attributes [Hash] The event's attributes.
18
+ # @option attributes [String] :username Matches the username of the updated user.
19
+ # @yield The block is executed when the event is raised.
20
+ # @yieldparam event [ServerMemberUpdateEvent] The event that was raised.
21
+ # @return [ServerMemberUpdateEventHandler] the event handler that was registered.
22
+
23
+ # This **event** is raised when a member update happens. This includes when a members nickname
24
+ # or roles are updated.
25
+ # @param attributes [Hash] The event's attributes.
26
+ # @option attributes [String] :username Matches the username of the updated user.
27
+ # @yield The block is executed when the event is raised.
28
+ # @yieldparam event [ServerMemberUpdateEvent] The event that was raised.
29
+ # @return [ServerMemberUpdateEventHandler] the event handler that was registered.
30
+ def member_update(attributes = {}, &block)
31
+ register_event(ServerMemberUpdateEvent, attributes, block)
32
+ end
33
+
34
+ # This **event** is raised when a member leaves a server.
35
+ # @param attributes [Hash] The event's attributes.
36
+ # @option attributes [String] :username Matches the username of the member.
37
+ # @yield The block is executed when the event is raised.
38
+ # @yieldparam event [ServerMemberDeleteEvent] The event that was raised.
39
+ # @return [ServerMemberDeleteEventHandler] the event handler that was registered.
40
+
41
+ # This **event** is raised when a member leaves a server.
42
+ # @param attributes [Hash] The event's attributes.
43
+ # @option attributes [String] :username Matches the username of the member.
44
+ # @yield The block is executed when the event is raised.
45
+ # @yieldparam event [ServerMemberDeleteEvent] The event that was raised.
46
+ # @return [ServerMemberDeleteEventHandler] the event handler that was registered.
47
+ def member_leave(attributes = {}, &block)
48
+ register_event(ServerMemberDeleteEvent, attributes, block)
49
+ end
50
+
51
+ # This **event** is raised when a user is banned from a server.
52
+ # @param attributes [Hash] The event's attributes.
53
+ # @option attributes [String, Integer, User] :user Matches the user that was banned.
54
+ # @option attributes [String, Integer, Server] :server Matches the server from which the user was banned.
55
+ # @yield The block is executed when the event is raised.
56
+ # @yieldparam event [UserBanEvent] The event that was raised.
57
+ # @return [UserBanEventHandler] the event handler that was registered.
58
+
59
+ # This **event** is raised when a user is banned from a server.
60
+ # @param attributes [Hash] The event's attributes.
61
+ # @option attributes [String, Integer, User] :user Matches the user that was banned.
62
+ # @option attributes [String, Integer, Server] :server Matches the server from which the user was banned.
63
+ # @yield The block is executed when the event is raised.
64
+ # @yieldparam event [UserBanEvent] The event that was raised.
65
+ # @return [UserBanEventHandler] the event handler that was registered.
66
+ def user_ban(attributes = {}, &block)
67
+ register_event(UserBanEvent, attributes, block)
68
+ end
69
+
70
+ # This **event** is raised whenever an audit log entry is created in a server.
71
+ # @param attributes [Hash] The event's attributes.
72
+ # @option attributes [String, Integer, Server] :server Matches the server the entry was created in.
73
+ # @option attributes [String, Symbol, Integer] :action Matches the type of the entry.
74
+ # @option attributes [String, Regexp] :reason Matches the reason associated with the entry.
75
+ # @option attributes [String, Integer, User, Member, Recipient] :user Matches the user or bot that made the changes.
76
+ # @option attributes [String, Integer, #resolve_id] :target Matches the ID of the affected entity.
77
+ # @yield The block is executed when the event is raised.
78
+ # @yieldparam event [AuditLogEntryCreateEvent] The event that was raised.
79
+ # @return [AuditLogEntryCreateEventHandler] the event handler that was registered.
80
+
81
+ # This **event** is raised whenever an audit log entry is created in a server.
82
+ # @param attributes [Hash] The event's attributes.
83
+ # @option attributes [String, Integer, Server] :server Matches the server the entry was created in.
84
+ # @option attributes [String, Symbol, Integer] :action Matches the type of the entry.
85
+ # @option attributes [String, Regexp] :reason Matches the reason associated with the entry.
86
+ # @option attributes [String, Integer, User, Member, Recipient] :user Matches the user or bot that made the changes.
87
+ # @option attributes [String, Integer, #resolve_id] :target Matches the ID of the affected entity.
88
+ # @yield The block is executed when the event is raised.
89
+ # @yieldparam event [AuditLogEntryCreateEvent] The event that was raised.
90
+ # @return [AuditLogEntryCreateEventHandler] the event handler that was registered.
91
+ def audit_log_entry(attributes = {}, &block)
92
+ register_event(AuditLogEntryCreateEvent, attributes, block)
93
+ end
94
+
95
+ # This **event** is raised when a user is unbanned from a server.
96
+ # @param attributes [Hash] The event's attributes.
97
+ # @option attributes [String, Integer, User] :user Matches the user that was unbanned.
98
+ # @option attributes [String, Integer, Server] :server Matches the server from which the user was unbanned.
99
+ # @yield The block is executed when the event is raised.
100
+ # @yieldparam event [UserUnbanEvent] The event that was raised.
101
+ # @return [UserUnbanEventHandler] the event handler that was registered.
102
+
103
+ # This **event** is raised when a user is unbanned from a server.
104
+ # @param attributes [Hash] The event's attributes.
105
+ # @option attributes [String, Integer, User] :user Matches the user that was unbanned.
106
+ # @option attributes [String, Integer, Server] :server Matches the server from which the user was unbanned.
107
+ # @yield The block is executed when the event is raised.
108
+ # @yieldparam event [UserUnbanEvent] The event that was raised.
109
+ # @return [UserUnbanEventHandler] the event handler that was registered.
110
+ def user_unban(attributes = {}, &block)
111
+ register_event(UserUnbanEvent, attributes, block)
112
+ end
113
+
114
+ # This **event** is raised when a server is created respective to the bot, i.e. the bot joins a server or creates
115
+ # a new one itself.
116
+ # @param attributes [Hash] The event's attributes.
117
+ # @option attributes [String, Integer, Server] :server Matches the server that was created.
118
+ # @yield The block is executed when the event is raised.
119
+ # @yieldparam event [ServerCreateEvent] The event that was raised.
120
+ # @return [ServerCreateEventHandler] the event handler that was registered.
121
+
122
+ # This **event** is raised when a server is created respective to the bot, i.e. the bot joins a server or creates
123
+ # a new one itself.
124
+ # @param attributes [Hash] The event's attributes.
125
+ # @option attributes [String, Integer, Server] :server Matches the server that was created.
126
+ # @yield The block is executed when the event is raised.
127
+ # @yieldparam event [ServerCreateEvent] The event that was raised.
128
+ # @return [ServerCreateEventHandler] the event handler that was registered.
129
+ def server_create(attributes = {}, &block)
130
+ register_event(ServerCreateEvent, attributes, block)
131
+ end
132
+
133
+ # This **event** is raised when a server is updated, for example if the name or region has changed.
134
+ # @param attributes [Hash] The event's attributes.
135
+ # @option attributes [String, Integer, Server] :server Matches the server that was updated.
136
+ # @yield The block is executed when the event is raised.
137
+ # @yieldparam event [ServerUpdateEvent] The event that was raised.
138
+ # @return [ServerUpdateEventHandler] the event handler that was registered.
139
+
140
+ # This **event** is raised when a server is updated, for example if the name or region has changed.
141
+ # @param attributes [Hash] The event's attributes.
142
+ # @option attributes [String, Integer, Server] :server Matches the server that was updated.
143
+ # @yield The block is executed when the event is raised.
144
+ # @yieldparam event [ServerUpdateEvent] The event that was raised.
145
+ # @return [ServerUpdateEventHandler] the event handler that was registered.
146
+ def server_update(attributes = {}, &block)
147
+ register_event(ServerUpdateEvent, attributes, block)
148
+ end
149
+
150
+ # This **event** is raised when a server is deleted, or when the bot leaves a server. (These two cases are identical
151
+ # to Discord.)
152
+ # @param attributes [Hash] The event's attributes.
153
+ # @option attributes [String, Integer, Server] :server Matches the server that was deleted.
154
+ # @yield The block is executed when the event is raised.
155
+ # @yieldparam event [ServerDeleteEvent] The event that was raised.
156
+ # @return [ServerDeleteEventHandler] the event handler that was registered.
157
+
158
+ # This **event** is raised when a server is deleted, or when the bot leaves a server. (These two cases are identical
159
+ # to Discord.)
160
+ # @param attributes [Hash] The event's attributes.
161
+ # @option attributes [String, Integer, Server] :server Matches the server that was deleted.
162
+ # @yield The block is executed when the event is raised.
163
+ # @yieldparam event [ServerDeleteEvent] The event that was raised.
164
+ # @return [ServerDeleteEventHandler] the event handler that was registered.
165
+ def server_delete(attributes = {}, &block)
166
+ register_event(ServerDeleteEvent, attributes, block)
167
+ end
168
+
169
+ # This **event** is raised when an emoji or collection of emojis is created/deleted/updated.
170
+ # @param attributes [Hash] The event's attributes.
171
+ # @option attributes [String, Integer, Server] :server Matches the server.
172
+ # @yield The block is executed when the event is raised.
173
+ # @yieldparam event [ServerEmojiChangeEvent] The event that was raised.
174
+ # @return [ServerEmojiChangeEventHandler] the event handler that was registered.
175
+
176
+ # This **event** is raised when an emoji or collection of emojis is created/deleted/updated.
177
+ # @param attributes [Hash] The event's attributes.
178
+ # @option attributes [String, Integer, Server] :server Matches the server.
179
+ # @yield The block is executed when the event is raised.
180
+ # @yieldparam event [ServerEmojiChangeEvent] The event that was raised.
181
+ # @return [ServerEmojiChangeEventHandler] the event handler that was registered.
182
+ def server_emoji(attributes = {}, &block)
183
+ register_event(ServerEmojiChangeEvent, attributes, block)
184
+ end
185
+
186
+ # This **event** is raised when an emoji is created.
187
+ # @param attributes [Hash] The event's attributes.
188
+ # @option attributes [String, Integer, Server] :server Matches the server.
189
+ # @option attributes [String, Integer] :id Matches the ID of the emoji.
190
+ # @option attributes [String] :name Matches the name of the emoji.
191
+ # @yield The block is executed when the event is raised.
192
+ # @yieldparam event [ServerEmojiCreateEvent] The event that was raised.
193
+ # @return [ServerEmojiCreateEventHandler] the event handler that was registered.
194
+
195
+ # This **event** is raised when an emoji is created.
196
+ # @param attributes [Hash] The event's attributes.
197
+ # @option attributes [String, Integer, Server] :server Matches the server.
198
+ # @option attributes [String, Integer] :id Matches the ID of the emoji.
199
+ # @option attributes [String] :name Matches the name of the emoji.
200
+ # @yield The block is executed when the event is raised.
201
+ # @yieldparam event [ServerEmojiCreateEvent] The event that was raised.
202
+ # @return [ServerEmojiCreateEventHandler] the event handler that was registered.
203
+ def server_emoji_create(attributes = {}, &block)
204
+ register_event(ServerEmojiCreateEvent, attributes, block)
205
+ end
206
+
207
+ # This **event** is raised when an emoji is deleted.
208
+ # @param attributes [Hash] The event's attributes.
209
+ # @option attributes [String, Integer, Server] :server Matches the server.
210
+ # @option attributes [String, Integer] :id Matches the ID of the emoji.
211
+ # @option attributes [String] :name Matches the name of the emoji.
212
+ # @yield The block is executed when the event is raised.
213
+ # @yieldparam event [ServerEmojiDeleteEvent] The event that was raised.
214
+ # @return [ServerEmojiDeleteEventHandler] the event handler that was registered.
215
+
216
+ # This **event** is raised when an emoji is deleted.
217
+ # @param attributes [Hash] The event's attributes.
218
+ # @option attributes [String, Integer, Server] :server Matches the server.
219
+ # @option attributes [String, Integer] :id Matches the ID of the emoji.
220
+ # @option attributes [String] :name Matches the name of the emoji.
221
+ # @yield The block is executed when the event is raised.
222
+ # @yieldparam event [ServerEmojiDeleteEvent] The event that was raised.
223
+ # @return [ServerEmojiDeleteEventHandler] the event handler that was registered.
224
+ def server_emoji_delete(attributes = {}, &block)
225
+ register_event(ServerEmojiDeleteEvent, attributes, block)
226
+ end
227
+
228
+ # This **event** is raised when an emoji is updated.
229
+ # @param attributes [Hash] The event's attributes.
230
+ # @option attributes [String, Integer, Server] :server Matches the server.
231
+ # @option attributes [String, Integer] :id Matches the ID of the emoji.
232
+ # @option attributes [String] :name Matches the name of the emoji.
233
+ # @option attributes [String] :old_name Matches the name of the emoji before the update.
234
+ # @yield The block is executed when the event is raised.
235
+ # @yieldparam event [ServerEmojiUpdateEvent] The event that was raised.
236
+ # @return [ServerEmojiUpdateEventHandler] the event handler that was registered.
237
+
238
+ # This **event** is raised when an emoji is updated.
239
+ # @param attributes [Hash] The event's attributes.
240
+ # @option attributes [String, Integer, Server] :server Matches the server.
241
+ # @option attributes [String, Integer] :id Matches the ID of the emoji.
242
+ # @option attributes [String] :name Matches the name of the emoji.
243
+ # @option attributes [String] :old_name Matches the name of the emoji before the update.
244
+ # @yield The block is executed when the event is raised.
245
+ # @yieldparam event [ServerEmojiUpdateEvent] The event that was raised.
246
+ # @return [ServerEmojiUpdateEventHandler] the event handler that was registered.
247
+ def server_emoji_update(attributes = {}, &block)
248
+ register_event(ServerEmojiUpdateEvent, attributes, block)
249
+ end
250
+
251
+ # This **event** is raised when a role is created.
252
+ # @param attributes [Hash] The event's attributes.
253
+ # @option attributes [String] :name Matches the role name.
254
+ # @yield The block is executed when the event is raised.
255
+ # @yieldparam event [ServerRoleCreateEvent] The event that was raised.
256
+ # @return [ServerRoleCreateEventHandler] the event handler that was registered.
257
+
258
+ # This **event** is raised when a role is created.
259
+ # @param attributes [Hash] The event's attributes.
260
+ # @option attributes [String] :name Matches the role name.
261
+ # @yield The block is executed when the event is raised.
262
+ # @yieldparam event [ServerRoleCreateEvent] The event that was raised.
263
+ # @return [ServerRoleCreateEventHandler] the event handler that was registered.
264
+ def server_role_create(attributes = {}, &block)
265
+ register_event(ServerRoleCreateEvent, attributes, block)
266
+ end
267
+
268
+ # This **event** is raised when a role is deleted.
269
+ # @param attributes [Hash] The event's attributes.
270
+ # @option attributes [String, Integer] :id Matches the role ID.
271
+ # @yield The block is executed when the event is raised.
272
+ # @yieldparam event [ServerRoleDeleteEvent] The event that was raised.
273
+ # @return [ServerRoleDeleteEventHandler] the event handler that was registered.
274
+
275
+ # This **event** is raised when a role is deleted.
276
+ # @param attributes [Hash] The event's attributes.
277
+ # @option attributes [String, Integer] :id Matches the role ID.
278
+ # @yield The block is executed when the event is raised.
279
+ # @yieldparam event [ServerRoleDeleteEvent] The event that was raised.
280
+ # @return [ServerRoleDeleteEventHandler] the event handler that was registered.
281
+ def server_role_delete(attributes = {}, &block)
282
+ register_event(ServerRoleDeleteEvent, attributes, block)
283
+ end
284
+
285
+ # This **event** is raised when a role is updated.
286
+ # @param attributes [Hash] The event's attributes.
287
+ # @option attributes [String] :name Matches the role name.
288
+ # @yield The block is executed when the event is raised.
289
+ # @yieldparam event [ServerRoleUpdateEvent] The event that was raised.
290
+ # @return [ServerRoleUpdateEventHandler] the event handler that was registered.
291
+
292
+ # This **event** is raised when a role is updated.
293
+ # @param attributes [Hash] The event's attributes.
294
+ # @option attributes [String] :name Matches the role name.
295
+ # @yield The block is executed when the event is raised.
296
+ # @yieldparam event [ServerRoleUpdateEvent] The event that was raised.
297
+ # @return [ServerRoleUpdateEventHandler] the event handler that was registered.
298
+ def server_role_update(attributes = {}, &block)
299
+ register_event(ServerRoleUpdateEvent, attributes, block)
300
+ end
301
+
302
+ # This **event** is raised when a webhook is updated.
303
+ # @param attributes [Hash] The event's attributes.
304
+ # @option attributes [String, Integer, Server] :server Matches the server by name, ID or instance.
305
+ # @option attributes [String, Integer, Channel] :channel Matches the channel by name, ID or instance.
306
+ # @option attribute [String, Integer, Webhook] :webhook Matches the webhook by name, ID or instance.
307
+ # @yield The block is executed when the event is raised.
308
+ # @yieldparam event [WebhookUpdateEvent] The event that was raised.
309
+ # @return [WebhookUpdateEventHandler] the event handler that was registered.
310
+
311
+ # This **event** is raised when a webhook is updated.
312
+ # @param attributes [Hash] The event's attributes.
313
+ # @option attributes [String, Integer, Server] :server Matches the server by name, ID or instance.
314
+ # @option attributes [String, Integer, Channel] :channel Matches the channel by name, ID or instance.
315
+ # @option attribute [String, Integer, Webhook] :webhook Matches the webhook by name, ID or instance.
316
+ # @yield The block is executed when the event is raised.
317
+ # @yieldparam event [WebhookUpdateEvent] The event that was raised.
318
+ # @return [WebhookUpdateEventHandler] the event handler that was registered.
319
+ def webhook_update(attributes = {}, &block)
320
+ register_event(WebhookUpdateEvent, attributes, block)
321
+ end
322
+
323
+ # This **event** is raised when an {Await} is triggered. It provides an easy way to execute code
324
+ # on an await without having to rely on the await's block.
325
+ # @param attributes [Hash] The event's attributes.
326
+ # @option attributes [Symbol] :key Exactly matches the await's key.
327
+ # @option attributes [Class] :type Exactly matches the event's type.
328
+ # @yield The block is executed when the event is raised.
329
+ # @yieldparam event [AwaitEvent] The event that was raised.
330
+ # @return [AwaitEventHandler] the event handler that was registered.
331
+
332
+ # This **event** is raised when an invite is created.
333
+ # @param attributes [Hash] The event's attributes.
334
+ # @option attributes [String, Integer, User] :inviter Matches the user that created the invite.
335
+ # @option attributes [String, Integer, Channel] :channel Matches the channel the invite was created for.
336
+ # @option attributes [String, Integer, Server] :server Matches the server the invite was created for.
337
+ # @option attributes [true, false] :temporary Matches whether the invite is temporary or not.
338
+ # @yield The block is executed when the event is raised.
339
+ # @yieldparam event [InviteCreateEvent] The event that was raised.
340
+ # @return [InviteCreateEventHandler] The event handler that was registered.
341
+ def invite_create(attributes = {}, &block)
342
+ register_event(InviteCreateEvent, attributes, block)
343
+ end
344
+
345
+ # This **event** is raised when an invite is deleted.
346
+ # @param attributes [Hash] The event's attributes.
347
+ # @option attributes [String, Integer, Channel] :channel Matches the channel the deleted invite was for.
348
+ # @option attributes [String, Integer, Server] :server Matches the server the deleted invite was for.
349
+ # @yield The block is executed when the event is raised
350
+ # @yieldparam event [InviteDeleteEvent] The event that was raised.
351
+ # @return [InviteDeleteEventHandler] The event handler that was registered.
352
+
353
+ # This **event** is raised when an invite is deleted.
354
+ # @param attributes [Hash] The event's attributes.
355
+ # @option attributes [String, Integer, Channel] :channel Matches the channel the deleted invite was for.
356
+ # @option attributes [String, Integer, Server] :server Matches the server the deleted invite was for.
357
+ # @yield The block is executed when the event is raised
358
+ # @yieldparam event [InviteDeleteEvent] The event that was raised.
359
+ # @return [InviteDeleteEventHandler] The event handler that was registered.
360
+ def invite_delete(attributes = {}, &block)
361
+ register_event(InviteDeleteEvent, attributes, block)
362
+ end
363
+
364
+ # This **event** is raised whenever an interaction event is received.
365
+ # @param attributes [Hash] The event's attributes.
366
+ # @option attributes [Integer, Symbol, String] :type The interaction type, can be the integer value or the name
367
+ # of the key in {OnyxCord::Interaction::TYPES}.
368
+ # @option attributes [String, Integer, Server, nil] :server The server where this event was created. `nil` for DM channels.
369
+ # @option attributes [String, Integer, Channel] :channel The channel where this event was created.
370
+ # @option attributes [String, Integer, User] :user The user that triggered this event.
371
+ # @yield The block is executed when the event is raised.
372
+ # @yieldparam event [InteractionCreateEvent] The event that was raised.
373
+ # @return [InteractionCreateEventHandler] The event handler that was registered.
374
+ end
375
+ end
@@ -0,0 +1,238 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OnyxCord
4
+ module EventContainer
5
+ # This **event** is raised whenever an interaction event is received.
6
+ # @param attributes [Hash] The event's attributes.
7
+ # @option attributes [Integer, Symbol, String] :type The interaction type, can be the integer value or the name
8
+ # of the key in {OnyxCord::Interaction::TYPES}.
9
+ # @option attributes [String, Integer, Server, nil] :server The server where this event was created. `nil` for DM channels.
10
+ # @option attributes [String, Integer, Channel] :channel The channel where this event was created.
11
+ # @option attributes [String, Integer, User] :user The user that triggered this event.
12
+ # @yield The block is executed when the event is raised.
13
+ # @yieldparam event [InteractionCreateEvent] The event that was raised.
14
+ # @return [InteractionCreateEventHandler] The event handler that was registered.
15
+ def interaction_create(attributes = {}, &block)
16
+ register_event(InteractionCreateEvent, attributes, block)
17
+ end
18
+
19
+ # This **event** is raised whenever an application command (slash command) is executed.
20
+ # @param name [Symbol, String] The name of the application command this handler is for.
21
+ # @param attributes [Hash] The event's attributes.
22
+ # @yield The block is executed when the event is raised.
23
+ # @yieldparam event [ApplicationCommandEvent] The event that was raised.
24
+ # @return [ApplicationCommandEventHandler] The event handler that was registered.
25
+
26
+ # This **event** is raised whenever an application command (slash command) is executed.
27
+ # @param name [Symbol, String] The name of the application command this handler is for.
28
+ # @param attributes [Hash] The event's attributes.
29
+ # @yield The block is executed when the event is raised.
30
+ # @yieldparam event [ApplicationCommandEvent] The event that was raised.
31
+ # @return [ApplicationCommandEventHandler] The event handler that was registered.
32
+ def application_command(name, attributes = {}, &block)
33
+ name = name.to_sym
34
+ @application_commands ||= {}
35
+
36
+ unless block
37
+ @application_commands[name] ||= ApplicationCommandEventHandler.new(attributes, nil)
38
+ return @application_commands[name]
39
+ end
40
+
41
+ @application_commands[name] = ApplicationCommandEventHandler.new(attributes, block)
42
+ end
43
+
44
+ # This **event** is raised whenever an button interaction is created.
45
+ # @param attributes [Hash] The event's attributes.
46
+ # @option attributes [String, Regexp] :custom_id A custom_id to match against.
47
+ # @option attributes [String, Integer, Message] :message The message to filter for.
48
+ # @yield The block is executed when the event is raised.
49
+ # @yieldparam event [ButtonEvent] The event that was raised.
50
+ # @return [ButtonEventHandler] The event handler that was registered.
51
+
52
+ # This **event** is raised whenever an button interaction is created.
53
+ # @param attributes [Hash] The event's attributes.
54
+ # @option attributes [String, Regexp] :custom_id A custom_id to match against.
55
+ # @option attributes [String, Integer, Message] :message The message to filter for.
56
+ # @yield The block is executed when the event is raised.
57
+ # @yieldparam event [ButtonEvent] The event that was raised.
58
+ # @return [ButtonEventHandler] The event handler that was registered.
59
+ def button(attributes = {}, &block)
60
+ register_event(ButtonEvent, attributes, block)
61
+ end
62
+
63
+ # This **event** is raised whenever an select string interaction is created.
64
+ # @param attributes [Hash] The event's attributes.
65
+ # @option attributes [String, Regexp] :custom_id A custom_id to match against.
66
+ # @option attributes [String, Integer, Message] :message The message to filter for.
67
+ # @yield The block is executed when the event is raised.
68
+ # @yieldparam event [StringSelectEvent] The event that was raised.
69
+ # @return [StringSelectEventHandler] The event handler that was registered.
70
+
71
+ # This **event** is raised whenever an select string interaction is created.
72
+ # @param attributes [Hash] The event's attributes.
73
+ # @option attributes [String, Regexp] :custom_id A custom_id to match against.
74
+ # @option attributes [String, Integer, Message] :message The message to filter for.
75
+ # @yield The block is executed when the event is raised.
76
+ # @yieldparam event [StringSelectEvent] The event that was raised.
77
+ # @return [StringSelectEventHandler] The event handler that was registered.
78
+ def string_select(attributes = {}, &block)
79
+ register_event(StringSelectEvent, attributes, block)
80
+ end
81
+
82
+ alias_method :select_menu, :string_select
83
+
84
+ # This **event** is raised whenever a modal is submitted.
85
+ # @param attributes [Hash] The event's attributes.
86
+ # @option attributes [String, Regexp] :custom_id A custom_id to match against.
87
+ # @option attributes [String, Integer, Message] :message The message to filter for.
88
+ # @option attributes [String, Integer, Server, nil] :server The server where this event was created. `nil` for DM channels.
89
+ # @option attributes [String, Integer, Channel] :channel The channel where this event was created.
90
+ # @option attributes [String, Integer, User] :user The user that triggered this event. # @yield The block is executed when the event is raised.
91
+ # @yieldparam event [ModalSubmitEvent] The event that was raised.
92
+ # @return [ModalSubmitEventHandler] The event handler that was registered.
93
+
94
+ # This **event** is raised whenever a modal is submitted.
95
+ # @param attributes [Hash] The event's attributes.
96
+ # @option attributes [String, Regexp] :custom_id A custom_id to match against.
97
+ # @option attributes [String, Integer, Message] :message The message to filter for.
98
+ # @option attributes [String, Integer, Server, nil] :server The server where this event was created. `nil` for DM channels.
99
+ # @option attributes [String, Integer, Channel] :channel The channel where this event was created.
100
+ # @option attributes [String, Integer, User] :user The user that triggered this event. # @yield The block is executed when the event is raised.
101
+ # @yieldparam event [ModalSubmitEvent] The event that was raised.
102
+ # @return [ModalSubmitEventHandler] The event handler that was registered.
103
+ def modal_submit(attributes = {}, &block)
104
+ register_event(ModalSubmitEvent, attributes, block)
105
+ end
106
+
107
+ # This **event** is raised whenever an select user interaction is created.
108
+ # @param attributes [Hash] The event's attributes.
109
+ # @option attributes [String, Regexp] :custom_id A custom_id to match against.
110
+ # @option attributes [String, Integer, Message] :message The message to filter for.
111
+ # @yield The block is executed when the event is raised.
112
+ # @yieldparam event [UserSelectEvent] The event that was raised.
113
+ # @return [UserSelectEventHandler] The event handler that was registered.
114
+
115
+ # This **event** is raised whenever an select user interaction is created.
116
+ # @param attributes [Hash] The event's attributes.
117
+ # @option attributes [String, Regexp] :custom_id A custom_id to match against.
118
+ # @option attributes [String, Integer, Message] :message The message to filter for.
119
+ # @yield The block is executed when the event is raised.
120
+ # @yieldparam event [UserSelectEvent] The event that was raised.
121
+ # @return [UserSelectEventHandler] The event handler that was registered.
122
+ def user_select(attributes = {}, &block)
123
+ register_event(UserSelectEvent, attributes, block)
124
+ end
125
+
126
+ # This **event** is raised whenever an select role interaction is created.
127
+ # @param attributes [Hash] The event's attributes.
128
+ # @option attributes [String, Regexp] :custom_id A custom_id to match against.
129
+ # @option attributes [String, Integer, Message] :message The message to filter for.
130
+ # @yield The block is executed when the event is raised.
131
+ # @yieldparam event [RoleSelectEvent] The event that was raised.
132
+ # @return [RoleSelectEventHandler] The event handler that was registered.
133
+
134
+ # This **event** is raised whenever an select role interaction is created.
135
+ # @param attributes [Hash] The event's attributes.
136
+ # @option attributes [String, Regexp] :custom_id A custom_id to match against.
137
+ # @option attributes [String, Integer, Message] :message The message to filter for.
138
+ # @yield The block is executed when the event is raised.
139
+ # @yieldparam event [RoleSelectEvent] The event that was raised.
140
+ # @return [RoleSelectEventHandler] The event handler that was registered.
141
+ def role_select(attributes = {}, &block)
142
+ register_event(RoleSelectEvent, attributes, block)
143
+ end
144
+
145
+ # This **event** is raised whenever an select mentionable interaction is created.
146
+ # @param attributes [Hash] The event's attributes.
147
+ # @option attributes [String, Regexp] :custom_id A custom_id to match against.
148
+ # @option attributes [String, Integer, Message] :message The message to filter for.
149
+ # @yield The block is executed when the event is raised.
150
+ # @yieldparam event [MentionableSelectEvent] The event that was raised.
151
+ # @return [MentionableSelectEventHandler] The event handler that was registered.
152
+
153
+ # This **event** is raised whenever an select mentionable interaction is created.
154
+ # @param attributes [Hash] The event's attributes.
155
+ # @option attributes [String, Regexp] :custom_id A custom_id to match against.
156
+ # @option attributes [String, Integer, Message] :message The message to filter for.
157
+ # @yield The block is executed when the event is raised.
158
+ # @yieldparam event [MentionableSelectEvent] The event that was raised.
159
+ # @return [MentionableSelectEventHandler] The event handler that was registered.
160
+ def mentionable_select(attributes = {}, &block)
161
+ register_event(MentionableSelectEvent, attributes, block)
162
+ end
163
+
164
+ # This **event** is raised whenever an select channel interaction is created.
165
+ # @param attributes [Hash] The event's attributes.
166
+ # @option attributes [String, Regexp] :custom_id A custom_id to match against.
167
+ # @option attributes [String, Integer, Message] :message The message to filter for.
168
+ # @yield The block is executed when the event is raised.
169
+ # @yieldparam event [ChannelSelectEvent] The event that was raised.
170
+ # @return [ChannelSelectEventHandler] The event handler that was registered.
171
+
172
+ # This **event** is raised whenever an select channel interaction is created.
173
+ # @param attributes [Hash] The event's attributes.
174
+ # @option attributes [String, Regexp] :custom_id A custom_id to match against.
175
+ # @option attributes [String, Integer, Message] :message The message to filter for.
176
+ # @yield The block is executed when the event is raised.
177
+ # @yieldparam event [ChannelSelectEvent] The event that was raised.
178
+ # @return [ChannelSelectEventHandler] The event handler that was registered.
179
+ def channel_select(attributes = {}, &block)
180
+ register_event(ChannelSelectEvent, attributes, block)
181
+ end
182
+
183
+ # This **event** is raised whenever a message is pinned or unpinned.
184
+ # @param attributes [Hash] The event's attributes.
185
+ # @option attributes [String, Integer, Channel] :channel A channel to match against.
186
+ # @option attributes [String, Integer, Server] :server A server to match against.
187
+ # @yield The block is executed when the event is raised.
188
+ # @yieldparam event [ChannelPinsUpdateEvent] The event that was raised.
189
+ # @return [ChannelPinsUpdateEventHandler] The event handler that was registered.
190
+
191
+ # This **event** is raised whenever an autocomplete interaction is created.
192
+ # @param name [String, Symbol, nil] An option name to match against.
193
+ # @param attributes [Hash] The event's attributes.
194
+ # @option attributes [String, Integer] :command_id A command ID to match against.
195
+ # @option attributes [String, Symbol] :subcommand A subcommand name to match against.
196
+ # @option attributes [String, Symbol] :subcommand_group A subcommand group to match against.
197
+ # @option attributes [String, Symbol] :command_name A command name to match against.
198
+ # @option attributes [String, Integer, Server] :server A server to match against.
199
+ # @yield The block is executed when the event is raised.
200
+ # @yieldparam event [AutocompleteEvent] The event that was raised.
201
+ # @return [AutocompleteEventHandler] The event handler that was registered.
202
+ def autocomplete(name = nil, attributes = {}, &block)
203
+ register_event(AutocompleteEvent, attributes.merge!({ name: name&.to_s }), block)
204
+ end
205
+
206
+ # This **event** is raised whenever an application command's permissions are updated.
207
+ # @param attributes [Hash] The event's attributes.
208
+ # @option attributes [String, Integer] :command_id A command ID to match against.
209
+ # @option attributes [String, Integer] :application_id An application ID to match against.
210
+ # @option attributes [String, Integer, Server] :server A server to match against.
211
+ # @yield The block is executed when the event is raised.
212
+ # @yieldparam event [ApplicationCommandPermissionsUpdateEvent] The event that was raised.
213
+ # @return [ApplicationCommandPermissionsUpdateEventHandler] The event handler that was registered.
214
+
215
+ # This **event** is raised whenever an application command's permissions are updated.
216
+ # @param attributes [Hash] The event's attributes.
217
+ # @option attributes [String, Integer] :command_id A command ID to match against.
218
+ # @option attributes [String, Integer] :application_id An application ID to match against.
219
+ # @option attributes [String, Integer, Server] :server A server to match against.
220
+ # @yield The block is executed when the event is raised.
221
+ # @yieldparam event [ApplicationCommandPermissionsUpdateEvent] The event that was raised.
222
+ # @return [ApplicationCommandPermissionsUpdateEventHandler] The event handler that was registered.
223
+ def application_command_permissions_update(attributes = {}, &block)
224
+ register_event(ApplicationCommandPermissionsUpdateEvent, attributes, block)
225
+ end
226
+
227
+ # This **event** is raised whenever a user votes on a poll.
228
+ # @param attributes [Hash] The event's attributes.
229
+ # @option attributes [String, Integer, User, Member] :user A user to match against.
230
+ # @option attributes [String, Integer, Channel] :channel A channel to match against.
231
+ # @option attributes [String, Integer, Server] :server A server to match against.
232
+ # @option attributes [String, Integer, Message] :message A message to match against.
233
+ # @option attributes [String, Integer, Answer] :answer A poll answer to match against.
234
+ # @yield The block is executed when the event is raised.
235
+ # @yieldparam event [PollVoteAddEvent] The event that was raised.
236
+ # @return [PollVoteAddEventHandler] The event handler that was registered.
237
+ end
238
+ end