diff --git a/docs/plugin-api.md b/docs/plugin-api.md index 87f013e..dbde608 100644 --- a/docs/plugin-api.md +++ b/docs/plugin-api.md @@ -70,6 +70,7 @@ Scroll down to [PluginAPI](#PluginAPI) for a list of properties available to plu | --- | --- | | addStorageType | AddAttachmentStorageTypeFn | | downloadAttachment | DownloadAttachmentFn | +| saveAttachment | SaveAttachmentFn | diff --git a/src/data/attachments.js b/src/data/attachments.js index a5392c0..8b9be56 100644 --- a/src/data/attachments.js +++ b/src/data/attachments.js @@ -60,6 +60,13 @@ function getErrorResult(msg = null) { * @return {void} */ +/** + * Saves the given attachment based on the configured storage system + * @callback SaveAttachmentFn + * @param {Eris.Attachment} attachment + * @returns {Promise<{ url: string }>} + */ + /** * @type {AttachmentStorageTypeHandler} */ @@ -206,11 +213,9 @@ async function attachmentToDiscordFileObject(attachment) { } /** - * Saves the given attachment based on the configured storage system - * @param {Eris.Attachment} attachment - * @returns {Promise<{ url: string }>} + * @type {SaveAttachmentFn} */ -function saveAttachment(attachment) { +const saveAttachment = (attachment) => { if (attachmentSavePromises[attachment.id]) { return attachmentSavePromises[attachment.id]; } @@ -226,7 +231,7 @@ function saveAttachment(attachment) { }); return attachmentSavePromises[attachment.id]; -} +}; /** * @type AddAttachmentStorageTypeFn diff --git a/src/pluginApi.js b/src/pluginApi.js index 0a101dc..dd776c8 100644 --- a/src/pluginApi.js +++ b/src/pluginApi.js @@ -33,6 +33,7 @@ const displayRoles = require("./data/displayRoles"); * @typedef {object} PluginAttachmentsAPI * @property {AddAttachmentStorageTypeFn} addStorageType * @property {DownloadAttachmentFn} downloadAttachment + * @property {SaveAttachmentFn} saveAttachment */ /** diff --git a/src/plugins.js b/src/plugins.js index 894c529..7ee9fce 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -115,7 +115,8 @@ module.exports = { }, attachments: { addStorageType: attachments.addStorageType, - downloadAttachment: attachments.downloadAttachment + downloadAttachment: attachments.downloadAttachment, + saveAttachment: attachments.saveAttachment, }, logs: { addStorageType: logs.addStorageType,