mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
Fix sendEmbed with array content
This commit is contained in:
@@ -2,6 +2,7 @@ const path = require('path');
|
|||||||
const Message = require('../Message');
|
const Message = require('../Message');
|
||||||
const MessageCollector = require('../MessageCollector');
|
const MessageCollector = require('../MessageCollector');
|
||||||
const Collection = require('../../util/Collection');
|
const Collection = require('../../util/Collection');
|
||||||
|
let GuildMember;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for classes that have text-channel-like features
|
* Interface for classes that have text-channel-like features
|
||||||
@@ -23,7 +24,7 @@ class TextBasedChannel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options that can be passed into send, sendMessage, sendFile, sendEmbed, sendCode, and Message#reply
|
* Options provided when sending or editing a message
|
||||||
* @typedef {Object} MessageOptions
|
* @typedef {Object} MessageOptions
|
||||||
* @property {boolean} [tts=false] Whether or not the message should be spoken aloud
|
* @property {boolean} [tts=false] Whether or not the message should be spoken aloud
|
||||||
* @property {string} [nonce=''] The nonce for the message
|
* @property {string} [nonce=''] The nonce for the message
|
||||||
@@ -35,6 +36,7 @@ class TextBasedChannel {
|
|||||||
* @property {string|boolean} [code] Language for optional codeblock formatting to apply
|
* @property {string|boolean} [code] Language for optional codeblock formatting to apply
|
||||||
* @property {boolean|SplitOptions} [split=false] Whether or not the message should be split into multiple messages if
|
* @property {boolean|SplitOptions} [split=false] Whether or not the message should be split into multiple messages if
|
||||||
* it exceeds the character limit. If an object is provided, these are the options for splitting the message.
|
* it exceeds the character limit. If an object is provided, these are the options for splitting the message.
|
||||||
|
* @property {UserResolvable} [reply] User to reply to (prefixes the message with a mention, except in DMs)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,6 +72,7 @@ class TextBasedChannel {
|
|||||||
} else if (!options) {
|
} else if (!options) {
|
||||||
options = {};
|
options = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.file) {
|
if (options.file) {
|
||||||
if (typeof options.file === 'string') options.file = { attachment: options.file };
|
if (typeof options.file === 'string') options.file = { attachment: options.file };
|
||||||
if (!options.file.name) {
|
if (!options.file.name) {
|
||||||
@@ -81,6 +84,7 @@ class TextBasedChannel {
|
|||||||
options.file.name = 'file.jpg';
|
options.file.name = 'file.jpg';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.client.resolver.resolveBuffer(options.file.attachment).then(file =>
|
return this.client.resolver.resolveBuffer(options.file.attachment).then(file =>
|
||||||
this.client.rest.methods.sendMessage(this, content, options, {
|
this.client.rest.methods.sendMessage(this, content, options, {
|
||||||
file,
|
file,
|
||||||
@@ -88,12 +92,13 @@ class TextBasedChannel {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.client.rest.methods.sendMessage(this, content, options);
|
return this.client.rest.methods.sendMessage(this, content, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a message to this channel
|
* Send a message to this channel
|
||||||
* @param {StringResolvable} content Text for the message
|
* @param {StringResolvable} [content] Text for the message
|
||||||
* @param {MessageOptions} [options={}] Options for the message
|
* @param {MessageOptions} [options={}] Options for the message
|
||||||
* @returns {Promise<Message|Message[]>}
|
* @returns {Promise<Message|Message[]>}
|
||||||
* @example
|
* @example
|
||||||
@@ -114,7 +119,7 @@ class TextBasedChannel {
|
|||||||
* @returns {Promise<Message>}
|
* @returns {Promise<Message>}
|
||||||
*/
|
*/
|
||||||
sendEmbed(embed, content, options) {
|
sendEmbed(embed, content, options) {
|
||||||
if (!options && typeof content === 'object') {
|
if (!options && typeof content === 'object' && !(content instanceof Array)) {
|
||||||
options = content;
|
options = content;
|
||||||
content = '';
|
content = '';
|
||||||
} else if (!options) {
|
} else if (!options) {
|
||||||
|
|||||||
Reference in New Issue
Block a user