diff --git a/index.js b/index.js index ff17d9d..0b15b7f 100644 --- a/index.js +++ b/index.js @@ -1392,6 +1392,29 @@ async function dispatchUiMessage (platform, msg, hooks = {}) { }) return true } + if (t === 'request-attachment-download') { + const attachmentId = msg.attachmentId + try { + const row = await platform.attachments?.get(attachmentId) + if (!row) throw new Error('attachment not found') + const { buf, source } = await platform.readAttachmentBytesWithSource(attachmentId) + send({ + type: 'attachment-download', + attachmentId: row.id, + filename: row.filename || 'download', + mimeType: row.mimeType || 'application/octet-stream', + dataBase64: b4a.toString(buf, 'base64'), + fetchSource: source + }) + } catch (err) { + send({ + type: 'attachment-download-error', + attachmentId, + message: err?.message || String(err) + }) + } + return true + } if (t === 'upsert-guild-emoji') { await platform.upsertGuildEmoji({ name: msg.name,