mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
refactor: enforce single param on sending/editing methods (#5758)
Co-authored-by: ckohen <chaikohen@gmail.com> Co-authored-by: Jan <66554238+vaporox@users.noreply.github.com> Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
This commit is contained in:
@@ -117,8 +117,7 @@ class TextBasedChannel {
|
||||
|
||||
/**
|
||||
* Sends a message to this channel.
|
||||
* @param {string|APIMessage} [content=''] The content to send
|
||||
* @param {MessageOptions|MessageAdditions} [options={}] The options to provide
|
||||
* @param {string|APIMessage|MessageOptions} options The options to provide
|
||||
* @returns {Promise<Message|Message[]>}
|
||||
* @example
|
||||
* // Send a basic message
|
||||
@@ -158,20 +157,20 @@ class TextBasedChannel {
|
||||
* .then(console.log)
|
||||
* .catch(console.error);
|
||||
*/
|
||||
async send(content, options) {
|
||||
async send(options) {
|
||||
const User = require('../User');
|
||||
const GuildMember = require('../GuildMember');
|
||||
|
||||
if (this instanceof User || this instanceof GuildMember) {
|
||||
return this.createDM().then(dm => dm.send(content, options));
|
||||
return this.createDM().then(dm => dm.send(options));
|
||||
}
|
||||
|
||||
let apiMessage;
|
||||
|
||||
if (content instanceof APIMessage) {
|
||||
apiMessage = content.resolveData();
|
||||
if (options instanceof APIMessage) {
|
||||
apiMessage = options.resolveData();
|
||||
} else {
|
||||
apiMessage = APIMessage.create(this, content, options).resolveData();
|
||||
apiMessage = APIMessage.create(this, options).resolveData();
|
||||
if (Array.isArray(apiMessage.data.content)) {
|
||||
return Promise.all(apiMessage.split().map(this.send.bind(this)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user