mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Rename ClientDataResolver.resolveFile -> resolveBuffer
This commit is contained in:
@@ -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<Buffer>}
|
||||
*/
|
||||
resolveFile(resource) {
|
||||
resolveBuffer(resource) {
|
||||
if (resource instanceof Buffer) return Promise.resolve(resource);
|
||||
|
||||
if (typeof resource === 'string') {
|
||||
|
||||
@@ -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<ClientUser>}
|
||||
* @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 {
|
||||
* <warn>This is only available for user accounts, not bot accounts!</warn>
|
||||
* @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<Guild>} 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 })
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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<Emoji>} 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);
|
||||
|
||||
@@ -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>} 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);
|
||||
|
||||
@@ -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<Webhook>}
|
||||
*/
|
||||
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);
|
||||
});
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user