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> |
|
| addStorageType | <code>AddAttachmentStorageTypeFn</code> |
|
||||||
| downloadAttachment | <code>DownloadAttachmentFn</code> |
|
| downloadAttachment | <code>DownloadAttachmentFn</code> |
|
||||||
|
| saveAttachment | <code>SaveAttachmentFn</code> |
|
||||||
|
|
||||||
<a name="PluginLogsAPI"></a>
|
<a name="PluginLogsAPI"></a>
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,13 @@ function getErrorResult(msg = null) {
|
||||||
* @return {void}
|
* @return {void}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the given attachment based on the configured storage system
|
||||||
|
* @callback SaveAttachmentFn
|
||||||
|
* @param {Eris.Attachment} attachment
|
||||||
|
* @returns {Promise<{ url: string }>}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {AttachmentStorageTypeHandler}
|
* @type {AttachmentStorageTypeHandler}
|
||||||
*/
|
*/
|
||||||
|
@ -206,11 +213,9 @@ async function attachmentToDiscordFileObject(attachment) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the given attachment based on the configured storage system
|
* @type {SaveAttachmentFn}
|
||||||
* @param {Eris.Attachment} attachment
|
|
||||||
* @returns {Promise<{ url: string }>}
|
|
||||||
*/
|
*/
|
||||||
function saveAttachment(attachment) {
|
const saveAttachment = (attachment) => {
|
||||||
if (attachmentSavePromises[attachment.id]) {
|
if (attachmentSavePromises[attachment.id]) {
|
||||||
return attachmentSavePromises[attachment.id];
|
return attachmentSavePromises[attachment.id];
|
||||||
}
|
}
|
||||||
|
@ -226,7 +231,7 @@ function saveAttachment(attachment) {
|
||||||
});
|
});
|
||||||
|
|
||||||
return attachmentSavePromises[attachment.id];
|
return attachmentSavePromises[attachment.id];
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type AddAttachmentStorageTypeFn
|
* @type AddAttachmentStorageTypeFn
|
||||||
|
|
|
@ -33,6 +33,7 @@ const displayRoles = require("./data/displayRoles");
|
||||||
* @typedef {object} PluginAttachmentsAPI
|
* @typedef {object} PluginAttachmentsAPI
|
||||||
* @property {AddAttachmentStorageTypeFn} addStorageType
|
* @property {AddAttachmentStorageTypeFn} addStorageType
|
||||||
* @property {DownloadAttachmentFn} downloadAttachment
|
* @property {DownloadAttachmentFn} downloadAttachment
|
||||||
|
* @property {SaveAttachmentFn} saveAttachment
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -115,7 +115,8 @@ module.exports = {
|
||||||
},
|
},
|
||||||
attachments: {
|
attachments: {
|
||||||
addStorageType: attachments.addStorageType,
|
addStorageType: attachments.addStorageType,
|
||||||
downloadAttachment: attachments.downloadAttachment
|
downloadAttachment: attachments.downloadAttachment,
|
||||||
|
saveAttachment: attachments.saveAttachment,
|
||||||
},
|
},
|
||||||
logs: {
|
logs: {
|
||||||
addStorageType: logs.addStorageType,
|
addStorageType: logs.addStorageType,
|
||||||
|
|
Loading…
Reference in New Issue