Centralise message sending logic in one method, remove sendTTSMessage, add client shortcut in RESTMethods (#1031)

* start wip rewrite of sending/editing messages

* pass the build, modify the edit method to fit the new system

* simplify the applyToClass method

* change handling of file options

* add back message splitting

* i couldn't help myself

* add some smart message options

* clean up, add sexy options

* fix indentation

* fix up splitting

* add \b

* add back old methods for hydar happiness

* clean up more

* move code handling to the rest method

* clean up this.rest.client

* Update TextBasedChannel.js

* add docs back for the bad methods

* fix reply in group dms

* srsly gawdl3y

* make code better

* fix changes for gawdl3y

* fix checking

* remove getter

* make code handling more robust

* k

* fix up sendEmbed docs

* stupid

* fix up more docs because aaaaa

* no more pls
This commit is contained in:
Gus Caplan
2016-12-28 22:58:30 -06:00
committed by Schuyler Cebulskie
parent a014b59790
commit ed8fcf651a
6 changed files with 201 additions and 198 deletions

View File

@@ -369,12 +369,13 @@ class Message {
* Options that can be passed into editMessage
* @typedef {Object} MessageEditOptions
* @property {Object} [embed] An embed to be added/edited
* @property {string} [code] Language for optional codeblock formatting to apply
*/
/**
* Edit the content of the message
* @param {StringResolvable} content The new content for the message
* @param {MessageEditOptions} [options={}] The options to provide
* @param {StringResolvable} [content] The new content for the message
* @param {MessageEditOptions} [options] The options to provide
* @returns {Promise<Message>}
* @example
* // update the content of a message
@@ -382,7 +383,13 @@ class Message {
* .then(msg => console.log(`Updated the content of a message from ${msg.author}`))
* .catch(console.error);
*/
edit(content, options = {}) {
edit(content, options) {
if (!options && typeof content === 'object') {
options = content;
content = '';
} else if (!options) {
options = {};
}
return this.client.rest.methods.updateMessage(this, content, options);
}
@@ -467,16 +474,8 @@ class Message {
* .catch(console.error);
*/
reply(content, options = {}) {
content = this.client.resolver.resolveString(content);
const prepend = this.guild ? `${this.author}, ` : '';
content = `${prepend}${content}`;
if (options.split) {
if (typeof options.split !== 'object') options.split = {};
if (!options.split.prepend) options.split.prepend = prepend;
}
return this.client.rest.methods.sendMessage(this.channel, content, options);
content = `${this.guild || this.channel.type === 'group' ? `${this.author}, ` : ''}${content}`;
return this.channel.send(content, options);
}
/**