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.
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:
image.png,.gif,.jpg,.jpeg,.jfif,.webp,.avifvideo.mp4,.mov,.qt,.webmaudio.mp3,.m4a,.wav,.ogg,.opus,.flacWhile 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_typesfield will be added to:The
file_typesfield can be aOptional<Vec<String>>, allowing the user to construct the array themselves. We could create aFileGrouphelper enum that goes into theVec<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.