add more embed stuff (#939)

* add fun embed stuff

* add more docstrings

* fix gawdl3y

* Update RichEmbed.js
This commit is contained in:
Gus Caplan
2016-12-02 20:59:38 -06:00
committed by Schuyler Cebulskie
parent e141deb7ef
commit 6cfbf76406
7 changed files with 207 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ const path = require('path');
const Message = require('../Message');
const MessageCollector = require('../MessageCollector');
const Collection = require('../../util/Collection');
const RichEmbed = require('../RichEmbed');
const escapeMarkdown = require('../../util/EscapeMarkdown');
/**
@@ -76,6 +77,27 @@ class TextBasedChannel {
return this.client.rest.methods.sendMessage(this, content, options);
}
/**
* Send an embed to this channel
* @param {RichEmbed|Object} embed The embed to send
* @param {string|MessageOptions} contentOrOptions Content to send or message options
* @param {MessageOptions} options If contentOrOptions is content, this will be options
* @returns {Promise<Message>}
*/
sendEmbed(embed, contentOrOptions, options = {}) {
if (!(embed instanceof RichEmbed)) embed = new RichEmbed(embed);
let content;
if (contentOrOptions) {
if (typeof contentOrOptions === 'string') {
content = contentOrOptions;
} else {
options = contentOrOptions;
}
}
options.embed = embed;
return this.sendMessage(content, options);
}
/**
* Send a file to this channel
* @param {BufferResolvable} attachment The file to send
@@ -327,7 +349,7 @@ class TextBasedChannel {
}
exports.applyToClass = (structure, full = false) => {
const props = ['sendMessage', 'sendTTSMessage', 'sendFile', 'sendCode'];
const props = ['sendMessage', 'sendTTSMessage', 'sendEmbed', 'sendFile', 'sendCode'];
if (full) {
props.push('_cacheMessage');
props.push('fetchMessages');