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:
@@ -544,8 +544,7 @@ class Message extends Base {
|
||||
|
||||
/**
|
||||
* Edits the content of the message.
|
||||
* @param {?(string|APIMessage)} [content] The new content for the message
|
||||
* @param {MessageEditOptions|MessageEmbed|MessageAttachment|MessageAttachment[]} [options] The options to provide
|
||||
* @param {string|APIMessage|MessageEditOptions} options The options to provide
|
||||
* @returns {Promise<Message>}
|
||||
* @example
|
||||
* // Update the content of a message
|
||||
@@ -553,8 +552,7 @@ class Message extends Base {
|
||||
* .then(msg => console.log(`Updated the content of a message to ${msg.content}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
edit(content, options) {
|
||||
options = content instanceof APIMessage ? content : APIMessage.create(this, content, options);
|
||||
edit(options) {
|
||||
return this.channel.messages.edit(this.id, options);
|
||||
}
|
||||
|
||||
@@ -650,8 +648,7 @@ class Message extends Base {
|
||||
|
||||
/**
|
||||
* Send an inline reply to this message.
|
||||
* @param {string|APIMessage} [content=''] The content for the message
|
||||
* @param {ReplyMessageOptions|MessageAdditions} [options] The additional options to provide
|
||||
* @param {string|APIMessage|ReplyMessageOptions} options The options to provide
|
||||
* @returns {Promise<Message|Message[]>}
|
||||
* @example
|
||||
* // Reply to a message
|
||||
@@ -659,17 +656,20 @@ class Message extends Base {
|
||||
* .then(() => console.log(`Replied to message "${message.content}"`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
reply(content, options) {
|
||||
return this.channel.send(
|
||||
content instanceof APIMessage
|
||||
? content
|
||||
: APIMessage.transformOptions(content, options, {
|
||||
reply: {
|
||||
messageReference: this,
|
||||
failIfNotExists: options?.failIfNotExists ?? content?.failIfNotExists ?? true,
|
||||
},
|
||||
}),
|
||||
);
|
||||
reply(options) {
|
||||
let data;
|
||||
|
||||
if (options instanceof APIMessage) {
|
||||
data = options;
|
||||
} else {
|
||||
data = APIMessage.create(this, options, {
|
||||
reply: {
|
||||
messageReference: this,
|
||||
failIfNotExists: options?.failIfNotExists ?? true,
|
||||
},
|
||||
});
|
||||
}
|
||||
return this.channel.send(data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user