|
1 | 1 | import type { Piece, Store } from '@sapphire/pieces';
|
| 2 | +import type { Option } from '@sapphire/result'; |
2 | 3 | import {
|
3 | 4 | Events as DJSEvents,
|
4 | 5 | type AutocompleteInteraction,
|
@@ -246,6 +247,25 @@ export const Events = {
|
246 | 247 | PluginLoaded: 'pluginLoaded' as const,
|
247 | 248 |
|
248 | 249 | // Interaction handlers
|
| 250 | + /** |
| 251 | + * Emitted when the `parse` method of an interaction handler passes successfully (no errors are encountered) |
| 252 | + * Use the {@link option} parameter to determine if `some` or `none` was passed. |
| 253 | + * @param {Option.None | Option.Some<unknown>} option The {@link Option} from the `parse` method. |
| 254 | + * @param {InteractionHandlerParseSuccess} payload The contextual payload |
| 255 | + */ |
| 256 | + InteractionHandlerParseSuccess: 'interactionHandlerParseSuccess' as const, |
| 257 | + /** |
| 258 | + * Emitted when the `parse` method of an interaction handler passes successfully (no errors are encountered) and `some` is returned. |
| 259 | + * @param {Option.Some<unknown>} option The {@link Option.Some} from the `parse` method. |
| 260 | + * @param {InteractionHandlerParseSome} payload The contextual payload |
| 261 | + */ |
| 262 | + InteractionHandlerParseSome: 'interactionHandlerParseSome' as const, |
| 263 | + /** |
| 264 | + * Emitted when the `parse` method of an interaction handler passes successfully (no errors are encountered) and `none` is returned. |
| 265 | + * @param {Option.None} option The {@link Option.None} from the `parse` method. |
| 266 | + * @param {InteractionHandlerParseNone} payload The contextual payload |
| 267 | + */ |
| 268 | + InteractionHandlerParseNone: 'interactionHandlerParseNone' as const, |
249 | 269 | /**
|
250 | 270 | * Emitted when the `parse` method of an interaction handler encounters an error.
|
251 | 271 | * @param {*} error The error that was encountered
|
@@ -551,6 +571,17 @@ export interface IInteractionHandlerPayload {
|
551 | 571 | handler: InteractionHandler;
|
552 | 572 | }
|
553 | 573 |
|
| 574 | +export interface InteractionHandlerParseSuccess extends IInteractionHandlerPayload {} |
| 575 | + |
| 576 | +export interface InteractionHandlerParseSome<T = unknown> extends IInteractionHandlerPayload { |
| 577 | + /** |
| 578 | + * The value that was passed to the `some` function. |
| 579 | + */ |
| 580 | + value: T; |
| 581 | +} |
| 582 | + |
| 583 | +export interface InteractionHandlerParseNone extends IInteractionHandlerPayload {} |
| 584 | + |
554 | 585 | export interface InteractionHandlerParseError extends IInteractionHandlerPayload {}
|
555 | 586 |
|
556 | 587 | export interface InteractionHandlerError extends IInteractionHandlerPayload {}
|
@@ -597,6 +628,9 @@ declare module 'discord.js' {
|
597 | 628 |
|
598 | 629 | [SapphireEvents.PluginLoaded]: [hook: PluginHook, name: string | undefined];
|
599 | 630 |
|
| 631 | + [SapphireEvents.InteractionHandlerParseSuccess]: [option: Option<unknown>, payload: InteractionHandlerParseSuccess]; |
| 632 | + [SapphireEvents.InteractionHandlerParseSome]: [option: Option.Some<unknown>, payload: InteractionHandlerParseSome]; |
| 633 | + [SapphireEvents.InteractionHandlerParseNone]: [option: Option.None, payload: InteractionHandlerParseNone]; |
600 | 634 | [SapphireEvents.InteractionHandlerParseError]: [error: unknown, payload: InteractionHandlerParseError];
|
601 | 635 | [SapphireEvents.InteractionHandlerError]: [error: unknown, payload: InteractionHandlerError];
|
602 | 636 |
|
|
0 commit comments