parseApplicationCommandInteractionData method

ApplicationCommandInteractionData parseApplicationCommandInteractionData(
  1. Map<String, Object?> raw,
  2. {Snowflake? guildId,
  3. Snowflake? channelId}
)

Implementation

ApplicationCommandInteractionData parseApplicationCommandInteractionData(Map<String, Object?> raw, {Snowflake? guildId, Snowflake? channelId}) {
  return ApplicationCommandInteractionData(
    id: Snowflake.parse(raw['id']!),
    name: raw['name'] as String,
    type: ApplicationCommandType.parse(raw['type'] as int),
    resolved: maybeParse(raw['resolved'], (Map<String, Object?> raw) => parseResolvedData(raw, guildId: guildId, channelId: channelId)),
    options: maybeParseMany(raw['options'], parseInteractionOption),
    // This guild_id is the ID of the guild the command is registered in, so it may be null even if the command was executed in a guild.
    // Because of this, we still need the guildId parameter for the actual guild the command was executed in.
    guildId: maybeParse(raw['guild_id'], Snowflake.parse),
    targetId: maybeParse(raw['target_id'], Snowflake.parse),
  );
}