diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2024-03-14 20:43:25 +0200 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2024-03-14 20:43:25 +0200 |
| commit | 0057931a0e009cf40c0b1bb651d60432347e0dc7 (patch) | |
| tree | aafc81e3ea15e5bc55b1497a694ce9335aae1c43 /src/index.ts | |
| parent | bc339b5b8a3357002909047409be0d7bc7474fe9 (diff) | |
Add user handle to response, small improvements
Diffstat (limited to 'src/index.ts')
| -rw-r--r-- | src/index.ts | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/index.ts b/src/index.ts index a485a95..3a48757 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,11 +23,21 @@ app.command("/veeti", async ({ command, ack, respond, client }) => { const url = command.text.trim(); if (!url.includes("instagram.com")) { - respond("Only instagram.com URLs are supported"); + void respond({ + text: "Only instagram.com URLs are supported at the moment", + response_type: "ephemeral", + }); return; } - const respondWithFile = async (message: string, filePath: string) => { + // send a message only visible to the user who sent the command + void respond({ + text: "Sharing instagram video, this can take a minute...", + thread_ts: command.ts, + response_type: "ephemeral", + }); + + const respondWithFile = async (filePath: string) => { try { console.log("Uploading file", filePath); const fileContent = fs.readFileSync(filePath); @@ -36,13 +46,18 @@ app.command("/veeti", async ({ command, ack, respond, client }) => { console.log("Sending message to channel", command.channel_id); await client.filesUploadV2({ channel_id: command.channel_id, - initial_comment: message, + initial_comment: `By: @${command.user_name}`, file: fileContent, filename: fileName, }); console.log("Success"); } catch (e) { console.error("Failed to upload file", e); + void respond({ + text: + "Failed to share file, please try again later. Error: " + String(e), + response_type: "ephemeral", + }); } }; |
