createMessageContext method
- ApplicationCommandInteraction interaction,
- MessageCommand command
Create a MessageContext
from an ApplicationCommandInteraction.
interaction
is the interaction event that triggered the command and command
is the
command executed by the event.
Implementation
Future<MessageContext> createMessageContext(
ApplicationCommandInteraction interaction,
MessageCommand command,
) async {
Member? member = interaction.member;
User user = member?.user ?? interaction.user!;
Guild? guild = await interaction.guild?.get();
TextChannel channel = await interaction.channel!.get() as TextChannel;
return MessageContext(
commands: commands,
client: interaction.manager.client as NyxxGateway,
interaction: interaction,
command: command,
channel: channel,
member: member,
user: user,
guild: guild,
targetMessage: await channel.messages[interaction.data.targetId!].get(),
);
}