MCPcopy Create free account
hub / github.com/ScattrdBlade/bigFileUpload / interceptUploadAddFiles

Function interceptUploadAddFiles

index.tsx:81–105  ·  view source on GitHub ↗
(event: unknown)

Source from the content-addressed store, hash-verified

79}
80
81function interceptUploadAddFiles(event: unknown): void {
82 if (!event || typeof event !== "object" || !("type" in event)) return;
83
84 const payload = event as UploadAddFilesEvent;
85 if (payload.type !== "UPLOAD_ATTACHMENT_ADD_FILES") return;
86
87 if (payload.draftType !== DraftType.ChannelMessage) return;
88
89 if (!settings.store.bypassDiscordUpload || !isConfigured()) return;
90
91 const files = [
92 ...extractFilesFromValue(payload.files),
93 ...extractFilesFromValue(payload.uploads),
94 ...extractFilesFromValue(payload.items)
95 ];
96 const uniqueFiles = Array.from(new Set(files)).filter(f => isFileTypeAllowed(f) && !handledDropFiles.has(f));
97
98 if (!uniqueFiles.length) return;
99 if (!shouldInterceptUploadFiles(uniqueFiles, getGuildIdForChannel(payload.channelId))) return;
100
101 payload.files = [];
102 payload.uploads = [];
103 payload.items = [];
104 void uploadProvidedFiles(uniqueFiles);
105}
106
107function handlePaste(event: ClipboardEvent) {
108 const files = Array.from(event.clipboardData?.files || []);

Callers 1

startFunction · 0.85

Calls 6

isConfiguredFunction · 0.90
isFileTypeAllowedFunction · 0.90
uploadProvidedFilesFunction · 0.90
extractFilesFromValueFunction · 0.85
getGuildIdForChannelFunction · 0.85

Tested by

no test coverage detected