createModalContext method

Future<ModalContext> createModalContext(
  1. ModalSubmitInteraction interaction
)

Create a ModalContext from a ModalSubmitInteraction.

interaction is the interaction event that triggered this context's creation.

Implementation

Future<ModalContext> createModalContext(ModalSubmitInteraction interaction) async {
  Member? member = interaction.member;
  User user = member?.user ?? interaction.user!;

  return ModalContext(
    user: user,
    member: member,
    guild: await interaction.guild?.get(),
    channel: await interaction.channel!.get() as TextChannel,
    commands: commands,
    client: interaction.manager.client as NyxxGateway,
    interaction: interaction,
  );
}