From 5fa9e3548bc63eed7e85622ddd1ab95c7e42b5d3 Mon Sep 17 00:00:00 2001 From: Schuyler Cebulskie Date: Sun, 30 Oct 2016 16:29:56 -0400 Subject: [PATCH] Rename ClientDataResolver.resolveFile -> resolveBuffer --- src/client/ClientDataResolver.js | 8 ++++---- src/structures/ClientUser.js | 8 ++++---- src/structures/Guild.js | 4 ++-- src/structures/TextChannel.js | 4 ++-- src/structures/Webhook.js | 8 ++++---- src/structures/interface/TextBasedChannel.js | 4 ++-- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/client/ClientDataResolver.js b/src/client/ClientDataResolver.js index e729454bd..7888cad11 100644 --- a/src/client/ClientDataResolver.js +++ b/src/client/ClientDataResolver.js @@ -228,15 +228,15 @@ class ClientDataResolver { * * A Buffer * * The path to a local file * * A URL - * @typedef {string|Buffer} FileResolvable + * @typedef {string|Buffer} BufferResolvable */ /** - * Resolves a FileResolvable to a Buffer - * @param {FileResolvable} resource The file resolvable to resolve + * Resolves a BufferResolvable to a Buffer + * @param {BufferResolvable} resource The buffer resolvable to resolve * @returns {Promise} */ - resolveFile(resource) { + resolveBuffer(resource) { if (resource instanceof Buffer) return Promise.resolve(resource); if (typeof resource === 'string') { diff --git a/src/structures/ClientUser.js b/src/structures/ClientUser.js index b9877f741..69f37e5b9 100644 --- a/src/structures/ClientUser.js +++ b/src/structures/ClientUser.js @@ -90,7 +90,7 @@ class ClientUser extends User { /** * Set the avatar of the logged in Client. - * @param {FileResolvable|Base64Resolvable} avatar The new avatar + * @param {BufferResolvable|Base64Resolvable} avatar The new avatar * @returns {Promise} * @example * // set avatar @@ -102,7 +102,7 @@ class ClientUser extends User { if (avatar.startsWith('data:')) { return this.client.rest.methods.updateCurrentUser({ avatar }); } else { - return this.client.resolver.resolveFile(avatar).then(data => + return this.client.resolver.resolveBuffer(avatar).then(data => this.client.rest.methods.updateCurrentUser({ avatar: data }) ); } @@ -166,7 +166,7 @@ class ClientUser extends User { * This is only available for user accounts, not bot accounts! * @param {string} name The name of the guild * @param {string} region The region for the server - * @param {FileResolvable|Base64Resolvable} [icon=null] The icon for the guild + * @param {BufferResolvable|Base64Resolvable} [icon=null] The icon for the guild * @returns {Promise} The guild that was created */ createGuild(name, region, icon = null) { @@ -174,7 +174,7 @@ class ClientUser extends User { if (icon.startsWith('data:')) { return this.client.rest.methods.createGuild({ name, icon, region }); } else { - return this.client.resolver.resolveFile(icon).then(data => + return this.client.resolver.resolveBuffer(icon).then(data => this.client.rest.methods.createGuild({ name, icon: data, region }) ); } diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 1eabea56d..1aa99d53a 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -582,7 +582,7 @@ class Guild { /** * Creates a new custom emoji in the guild. - * @param {FileResolvable} attachment The image for the emoji. + * @param {BufferResolvable} attachment The image for the emoji. * @param {string} name The name for the emoji. * @returns {Promise} The created emoji. * @example @@ -597,7 +597,7 @@ class Guild { * .catch(console.error); */ createEmoji(attachment, name) { - return this.client.resolver.resolveFile(attachment).then(file => { + return this.client.resolver.resolveBuffer(attachment).then(file => { let base64 = new Buffer(file, 'binary').toString('base64'); let dataURI = `data:;base64,${base64}`; return this.client.rest.methods.createEmoji(this, dataURI, name); diff --git a/src/structures/TextChannel.js b/src/structures/TextChannel.js index 08439c268..620a229b7 100644 --- a/src/structures/TextChannel.js +++ b/src/structures/TextChannel.js @@ -53,7 +53,7 @@ class TextChannel extends GuildChannel { /** * Create a webhook for the channel. * @param {string} name The name of the webhook. - * @param {FileResolvable} avatar The avatar for the webhook. + * @param {BufferResolvable} avatar The avatar for the webhook. * @returns {Promise} webhook The created webhook. * @example * channel.createWebhook('Snek', 'http://snek.s3.amazonaws.com/topSnek.png') @@ -62,7 +62,7 @@ class TextChannel extends GuildChannel { */ createWebhook(name, avatar) { if (avatar) { - return this.client.resolver.resolveFile(avatar).then(file => { + return this.client.resolver.resolveBuffer(avatar).then(file => { let base64 = new Buffer(file, 'binary').toString('base64'); let dataURI = `data:;base64,${base64}`; return this.client.rest.methods.createWebhook(this, name, dataURI); diff --git a/src/structures/Webhook.js b/src/structures/Webhook.js index 1791e2c9d..85daa06c6 100644 --- a/src/structures/Webhook.js +++ b/src/structures/Webhook.js @@ -127,7 +127,7 @@ class Webhook { /** * Send a file with this webhook - * @param {FileResolvable} attachment The file to send + * @param {BufferResolvable} attachment The file to send * @param {string} [fileName="file.jpg"] The name and extension of the file * @param {StringResolvable} [content] Text message to send with the attachment * @param {WebhookMessageOptions} [options] The options to provide @@ -143,7 +143,7 @@ class Webhook { fileName = 'file.jpg'; } } - return this.client.resolver.resolveFile(attachment).then(file => + return this.client.resolver.resolveBuffer(attachment).then(file => this.client.rest.methods.sendWebhookMessage(this, content, options, { file, name: fileName, @@ -171,12 +171,12 @@ class Webhook { /** * Edit the Webhook. * @param {string} name The new name for the Webhook - * @param {FileResolvable} avatar The new avatar for the Webhook. + * @param {BufferResolvable} avatar The new avatar for the Webhook. * @returns {Promise} */ edit(name = this.name, avatar) { if (avatar) { - return this.client.resolver.resolveFile(avatar).then(file => { + return this.client.resolver.resolveBuffer(avatar).then(file => { const dataURI = this.client.resolver.resolveBase64(file); return this.client.rest.methods.editWebhook(this, name, dataURI); }); diff --git a/src/structures/interface/TextBasedChannel.js b/src/structures/interface/TextBasedChannel.js index f6c0e7078..35ba29ba5 100644 --- a/src/structures/interface/TextBasedChannel.js +++ b/src/structures/interface/TextBasedChannel.js @@ -76,7 +76,7 @@ class TextBasedChannel { /** * Send a file to this channel - * @param {FileResolvable} attachment The file to send + * @param {BufferResolvable} attachment The file to send * @param {string} [fileName="file.jpg"] The name and extension of the file * @param {StringResolvable} [content] Text message to send with the attachment * @param {MessageOptions} [options] The options to provide @@ -92,7 +92,7 @@ class TextBasedChannel { fileName = 'file.jpg'; } } - return this.client.resolver.resolveFile(attachment).then(file => + return this.client.resolver.resolveBuffer(attachment).then(file => this.client.rest.methods.sendMessage(this, content, options, { file, name: fileName,