mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
Add Attachment structure (#1731)
* Add Attachment structure * Fix linter issues + @private * Fixed array sends, also added embed sends * fixed proving path to attachment * fixed incorrect name assumption from path * linting fix * ;) * im really good at this * changes as requested by gus and computer from #1459 * am a dum * update webhook#send * readonly addition to getters * i... uh... oops * farming deez commits * fix webhook split * removed some ugly * removed .every checks
This commit is contained in:
committed by
Schuyler Cebulskie
parent
317a352337
commit
62fc9fce6d
@@ -215,6 +215,28 @@ class ClientDataResolver {
|
||||
return Promise.reject(new TypeError('REQ_RESOURCE_TYPE'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a Stream to a Buffer.
|
||||
* @param {Stream} resource The stream to convert
|
||||
* @returns {Promise<Buffer>}
|
||||
*/
|
||||
resolveFile(resource) {
|
||||
return resource ? this.resolveBuffer(resource)
|
||||
.catch(() => {
|
||||
if (resource.pipe && typeof resource.pipe === 'function') {
|
||||
return new Promise((resolve, reject) => {
|
||||
const buffers = [];
|
||||
resource.once('error', reject);
|
||||
resource.on('data', data => buffers.push(data));
|
||||
resource.once('end', () => resolve(Buffer.concat(buffers)));
|
||||
});
|
||||
} else {
|
||||
throw new TypeError('REQ_RESOURCE_TYPE');
|
||||
}
|
||||
}) :
|
||||
Promise.reject(new TypeError('REQ_RESOURCE_TYPE'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Data that can be resolved to give an emoji identifier. This can be:
|
||||
* * The unicode representation of an emoji
|
||||
|
||||
Reference in New Issue
Block a user