createInteractionChatContext method
- ApplicationCommandInteraction interaction,
- List<
InteractionOption> options, - 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:
- createMessageChatContext, for creating ChatContexts from message events.
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,
);
}