From 938037aae8fb671060b0b1d3d802d94e4e0dc2fb Mon Sep 17 00:00:00 2001 From: rybak Date: Fri, 5 Apr 2024 12:16:11 +0300 Subject: [PATCH] feat: Ad await before reply --- .../src/explorers/event/event.explorer.ts | 39 +++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/packages/core/src/explorers/event/event.explorer.ts b/packages/core/src/explorers/event/event.explorer.ts index 4063ae69..ac4eeb85 100644 --- a/packages/core/src/explorers/event/event.explorer.ts +++ b/packages/core/src/explorers/event/event.explorer.ts @@ -55,29 +55,28 @@ export class EventExplorer implements MethodExplorer { this.discordClientService .getClient() - [eventMethod]( - event, - async (...eventArgs: ClientEvents[keyof ClientEvents]) => { - try { - const response = await handler(...eventArgs, { - event, - collectors: [], - } as EventContext); + [ + eventMethod + ](event, async (...eventArgs: ClientEvents[keyof ClientEvents]) => { + try { + const response = await handler(...eventArgs, { + event, + collectors: [], + } as EventContext); - const [eventArg] = eventArgs; + const [eventArg] = eventArgs; - if (response && this.hasReply(eventArg)) { - eventArg['reply'](response); - } - } catch (exception) { - if ( - exception instanceof ForbiddenException && - this.optionService.getClientData().isTrowForbiddenException - ) - throw exception; + if (response && this.hasReply(eventArg)) { + await eventArg['reply'](response); } - }, - ); + } catch (exception) { + if ( + exception instanceof ForbiddenException && + this.optionService.getClientData().isTrowForbiddenException + ) + throw exception; + } + }); } private hasReply(value: any): value is Message {