Browse Source

Fix cast bug when sending media

painor 4 years ago
parent
commit
5481d3d2b0
2 changed files with 4 additions and 3 deletions
  1. 3 2
      gramjs/client/uploads.ts
  2. 1 1
      package.json

+ 3 - 2
gramjs/client/uploads.ts

@@ -266,7 +266,7 @@ async function _fileToMedia(
         !Buffer.isBuffer(file) &&
         !(file instanceof Api.InputFile) &&
         !(file instanceof Api.InputFileBig) &&
-        "read" in file
+        !("read" in file)
     ) {
         try {
             return {
@@ -307,6 +307,7 @@ async function _fileToMedia(
         } else {
             let name;
             if ("name" in file) {
+                // @ts-ignore
                 name = file.name;
             } else {
                 name = "unnamed";
@@ -316,7 +317,7 @@ async function _fileToMedia(
             }
         }
         if (!createdFile) {
-            throw new Error(`Could not create file from ${file}`);
+            throw new Error(`Could not create file from ${JSON.stringify(file)}`);
         }
         fileHandle = await uploadFile(client, {
             file: createdFile,

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "telegram",
-  "version": "1.7.12",
+  "version": "1.7.13",
   "description": "NodeJS MTProto API Telegram client library,",
   "main": "index.js",
   "types": "index.d.ts",