Skip to content

Commit

Permalink
feat: Ad await before reply
Browse files Browse the repository at this point in the history
  • Loading branch information
fjodor-rybakov committed Apr 5, 2024
1 parent d06e2f9 commit 938037a
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions packages/core/src/explorers/event/event.explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 938037a

Please sign in to comment.