Add saveAttachment() to the attachments plugin API
parent
1210b2acaa
commit
32c8d02531
|
@ -70,6 +70,7 @@ Scroll down to [PluginAPI](#PluginAPI) for a list of properties available to plu
|
|||
| --- | --- |
|
||||
| addStorageType | <code>AddAttachmentStorageTypeFn</code> |
|
||||
| downloadAttachment | <code>DownloadAttachmentFn</code> |
|
||||
| saveAttachment | <code>SaveAttachmentFn</code> |
|
||||
|
||||
<a name="PluginLogsAPI"></a>
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -33,6 +33,7 @@ const displayRoles = require("./data/displayRoles");
|
|||
* @typedef {object} PluginAttachmentsAPI
|
||||
* @property {AddAttachmentStorageTypeFn} addStorageType
|
||||
* @property {DownloadAttachmentFn} downloadAttachment
|
||||
* @property {SaveAttachmentFn} saveAttachment
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
|
@ -115,7 +115,8 @@ module.exports = {
|
|||
},
|
||||
attachments: {
|
||||
addStorageType: attachments.addStorageType,
|
||||
downloadAttachment: attachments.downloadAttachment
|
||||
downloadAttachment: attachments.downloadAttachment,
|
||||
saveAttachment: attachments.saveAttachment,
|
||||
},
|
||||
logs: {
|
||||
addStorageType: logs.addStorageType,
|
||||
|
|
Loading…
Reference in New Issue