parseInteractionCreate method

InteractionCreateEvent<Interaction> parseInteractionCreate(
  1. Map<String, Object?> raw
)

Parse an InteractionCreateEvent from raw.

Implementation

InteractionCreateEvent<Interaction<dynamic>> parseInteractionCreate(Map<String, Object?> raw) {
  final interaction = client.interactions.parse(raw);

  // Needed to get proper type promotion.
  return switch (interaction.type) {
    InteractionType.ping => InteractionCreateEvent<PingInteraction>(gateway: this, interaction: interaction as PingInteraction),
    InteractionType.applicationCommand =>
      InteractionCreateEvent<ApplicationCommandInteraction>(gateway: this, interaction: interaction as ApplicationCommandInteraction),
    InteractionType.messageComponent =>
      InteractionCreateEvent<MessageComponentInteraction>(gateway: this, interaction: interaction as MessageComponentInteraction),
    InteractionType.modalSubmit => InteractionCreateEvent<ModalSubmitInteraction>(gateway: this, interaction: interaction as ModalSubmitInteraction),
    InteractionType.applicationCommandAutocomplete =>
      InteractionCreateEvent<ApplicationCommandAutocompleteInteraction>(gateway: this, interaction: interaction as ApplicationCommandAutocompleteInteraction),
  } as InteractionCreateEvent<Interaction<dynamic>>;
}