attachmentConverter top-level constant

Converter<Attachment> const attachmentConverter

A converter that converts input to an Attachment.

This will first attempt to parse the input to a snowflake that will then be resolved as the ID of one of the attachments in the message or interaction. If this fails, then the attachment will be looked up by name.

This converter has a Discord Slash Command argument type of CommandOptionType.attachment.

Implementation

const Converter<Attachment> attachmentConverter = FallbackConverter(
  [
    CombineConverter<Snowflake, Attachment>(snowflakeConverter, snowflakeToAttachment),
    Converter(convertAttachment),
  ],
  type: CommandOptionType.attachment,
  toSelectMenuOption: attachmentToSelectMenuOption,
  toButton: attachmentToButton,
);