createInteractionChatContext method

Future<InteractionChatContext> createInteractionChatContext(
  1. ApplicationCommandInteraction interaction,
  2. List<InteractionOption> options,
  3. ChatCommand command
)

Create an InteractionChatContext from an ApplicationCommandInteraction.

interaction is the interaction that triggered the command and command is the command executed by the event.

You might also be interested in:

Implementation

Future<InteractionChatContext> createInteractionChatContext(
  ApplicationCommandInteraction interaction,
  List<InteractionOption> options,
  ChatCommand command,
) async {
  Member? member = interaction.member;
  User user = member?.user ?? interaction.user!;

  Map<String, dynamic> rawArguments = <String, dynamic>{};

  for (final option in options) {
    rawArguments[option.name] = option.value;
  }

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