createButtonComponentContext method

Future<ButtonComponentContext> createButtonComponentContext(
  1. MessageComponentInteraction interaction
)

Create a ButtonComponentContext from a MessageComponentInteraction.

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

Implementation

Future<ButtonComponentContext> createButtonComponentContext(
  MessageComponentInteraction interaction,
) async {
  Member? member = interaction.member;
  User user = member?.user ?? interaction.user!;

  return ButtonComponentContext(
    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,
  );
}