From 8b0e5aad3837ecc704eeca83f6466972e05637c5 Mon Sep 17 00:00:00 2001 From: Schuyler Cebulskie Date: Tue, 10 Jan 2017 19:22:03 -0500 Subject: [PATCH] Fix sendEmbed with array content --- src/structures/interface/TextBasedChannel.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/structures/interface/TextBasedChannel.js b/src/structures/interface/TextBasedChannel.js index 5e06cb543..7b20dd4f5 100644 --- a/src/structures/interface/TextBasedChannel.js +++ b/src/structures/interface/TextBasedChannel.js @@ -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} * @example @@ -114,7 +119,7 @@ class TextBasedChannel { * @returns {Promise} */ sendEmbed(embed, content, options) { - if (!options && typeof content === 'object') { + if (!options && typeof content === 'object' && !(content instanceof Array)) { options = content; content = ''; } else if (!options) {