feat(interaction-router): Adds error handling
This commit is contained in:
parent
62a32c8222
commit
05d113cccf
1 changed files with 20 additions and 16 deletions
|
|
@ -37,22 +37,26 @@ export class InteractionRouter {
|
|||
async route(interaction: Interaction) {
|
||||
const interactionType = this.findInteractionType(interaction);
|
||||
|
||||
switch (interactionType) {
|
||||
case InteractionRoutingType.Unrouted:
|
||||
this.logger.debug("Unroutable interaction found...")
|
||||
break;
|
||||
case InteractionRoutingType.Command:
|
||||
await this.handleCommand(<ChatInputCommandInteraction>interaction);
|
||||
break;
|
||||
case InteractionRoutingType.AutoComplete:
|
||||
await this.handleAutocomplete(<AutocompleteInteraction>interaction)
|
||||
break;
|
||||
case InteractionRoutingType.ModalSubmit:
|
||||
this.events.dispatch(new ModalInteractionEvent(<ModalSubmitInteraction>interaction));
|
||||
break;
|
||||
case InteractionRoutingType.ButtonSubmit:
|
||||
case InteractionRoutingType.MenuSubmit:
|
||||
this.events.dispatch(new ComponentInteractionEvent(<ButtonInteraction|AnySelectMenuInteraction>interaction))
|
||||
try {
|
||||
switch (interactionType) {
|
||||
case InteractionRoutingType.Unrouted:
|
||||
this.logger.debug("Unroutable interaction found...")
|
||||
break;
|
||||
case InteractionRoutingType.Command:
|
||||
await this.handleCommand(<ChatInputCommandInteraction>interaction);
|
||||
break;
|
||||
case InteractionRoutingType.AutoComplete:
|
||||
await this.handleAutocomplete(<AutocompleteInteraction>interaction)
|
||||
break;
|
||||
case InteractionRoutingType.ModalSubmit:
|
||||
this.events.dispatch(new ModalInteractionEvent(<ModalSubmitInteraction>interaction));
|
||||
break;
|
||||
case InteractionRoutingType.ButtonSubmit:
|
||||
case InteractionRoutingType.MenuSubmit:
|
||||
this.events.dispatch(new ComponentInteractionEvent(<ButtonInteraction | AnySelectMenuInteraction>interaction))
|
||||
}
|
||||
} catch (err: any) {
|
||||
this.logger.fatal(err);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue