Interaction.from constructor

Interaction.from({
  1. required dynamic payload,
  2. required PartialChannel? channel,
})

Implementation

factory Interaction.from({ required dynamic payload, required PartialChannel? channel }) {
  PartialMessage? message;
  if(payload['message'] != null) {
    message = (payload['guild_id'] != null ? Message.from(channel: channel as GuildChannel, payload: payload['message']) : DmMessage.from(channel: channel as DmChannel, payload: payload['message'])) as PartialMessage<PartialChannel>;
  }

  return Interaction(
    payload['id'],
    null,
    payload['application_id'],
    payload['version'],
    payload['type'],
    payload['token'],
    payload['member']?['user']?['id'] ?? payload['user']?['id'],
    payload['guild_id'],
    message
  );
}