Fix sendEmbed with array content

This commit is contained in:
Schuyler Cebulskie
2017-01-10 19:22:03 -05:00
parent c37cd3fd91
commit 8b0e5aad38

View File

@@ -2,6 +2,7 @@ const path = require('path');
const Message = require('../Message');
const MessageCollector = require('../MessageCollector');
const Collection = require('../../util/Collection');
let GuildMember;
/**
* 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
* @property {boolean} [tts=false] Whether or not the message should be spoken aloud
* @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 {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.
* @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) {
options = {};
}
if (options.file) {
if (typeof options.file === 'string') options.file = { attachment: options.file };
if (!options.file.name) {
@@ -81,6 +84,7 @@ class TextBasedChannel {
options.file.name = 'file.jpg';
}
}
return this.client.resolver.resolveBuffer(options.file.attachment).then(file =>
this.client.rest.methods.sendMessage(this, content, options, {
file,
@@ -88,12 +92,13 @@ class TextBasedChannel {
})
);
}
return this.client.rest.methods.sendMessage(this, content, options);
}
/**
* 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
* @returns {Promise<Message|Message[]>}
* @example
@@ -114,7 +119,7 @@ class TextBasedChannel {
* @returns {Promise<Message>}
*/
sendEmbed(embed, content, options) {
if (!options && typeof content === 'object') {
if (!options && typeof content === 'object' && !(content instanceof Array)) {
options = content;
content = '';
} else if (!options) {