Skip to content

Support File Type Filtering for File Uploads & Command Attachments #2577

Description

@suhaybu

Discord now allows for file type filtering when users upload files via the File Upload Container or an Application Command Attachment.

References:

The official docs provide us with Group Names corresponding to specific file extension sets:

Group Name Extensions
image .png, .gif, .jpg, .jpeg, .jfif, .webp, .avif
video .mp4, .mov, .qt, .webm
audio .mp3, .m4a, .wav, .ogg, .opus, .flac

While file extensions can be passed individually, Discord warns us not to hardcode them as the extensions are subject to change. Instead, they recommend we pass Group Names in file_types.

Proposed Change

An optional file_types field will be added to:

The file_types field can be a Optional<Vec<String>>, allowing the user to construct the array themselves. We could create a FileGroup helper enum that goes into the Vec<String> for representing the standard Group Names, but I'm not sure if this is necessary since we can always list out the known Group Names in the documentation of the field.

I'm creating this issue to collect feedback before I open a PR. Let me know what you folks think.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions