mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 00:53: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:
@@ -53,8 +53,7 @@ class InteractionResponses {
|
||||
|
||||
/**
|
||||
* Creates a reply to this interaction.
|
||||
* @param {string|APIMessage|MessageAdditions} content The content for the reply
|
||||
* @param {InteractionReplyOptions} [options] Additional options for the reply
|
||||
* @param {string|APIMessage|InteractionReplyOptions} options The options for the reply
|
||||
* @returns {Promise<void>}
|
||||
* @example
|
||||
* // Reply to the interaction with an embed
|
||||
@@ -65,13 +64,17 @@ class InteractionResponses {
|
||||
* .catch(console.error);
|
||||
* @example
|
||||
* // Create an ephemeral reply
|
||||
* interaction.reply('Pong!', { ephemeral: true })
|
||||
* interaction.reply({ content: 'Pong!', ephemeral: true })
|
||||
* .then(console.log)
|
||||
* .catch(console.error);
|
||||
*/
|
||||
async reply(content, options) {
|
||||
async reply(options) {
|
||||
if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
|
||||
const apiMessage = content instanceof APIMessage ? content : APIMessage.create(this, content, options);
|
||||
|
||||
let apiMessage;
|
||||
if (options instanceof APIMessage) apiMessage = options;
|
||||
else apiMessage = APIMessage.create(this, options);
|
||||
|
||||
const { data, files } = await apiMessage.resolveData().resolveFiles();
|
||||
|
||||
await this.client.api.interactions(this.id, this.token).callback.post({
|
||||
@@ -101,8 +104,7 @@ class InteractionResponses {
|
||||
/**
|
||||
* Edits the initial reply to this interaction.
|
||||
* @see Webhook#editMessage
|
||||
* @param {string|APIMessage|MessageAdditions} content The new content for the message
|
||||
* @param {WebhookEditMessageOptions} [options] The options to provide
|
||||
* @param {string|APIMessage|WebhookEditMessageOptions} options The new options for the message
|
||||
* @returns {Promise<Message|Object>}
|
||||
* @example
|
||||
* // Edit the reply to this interaction
|
||||
@@ -110,8 +112,8 @@ class InteractionResponses {
|
||||
* .then(console.log)
|
||||
* .catch(console.error);
|
||||
*/
|
||||
editReply(content, options) {
|
||||
return this.webhook.editMessage('@original', content, options);
|
||||
editReply(options) {
|
||||
return this.webhook.editMessage('@original', options);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,12 +132,11 @@ class InteractionResponses {
|
||||
|
||||
/**
|
||||
* Send a follow-up message to this interaction.
|
||||
* @param {string|APIMessage|MessageAdditions} content The content for the reply
|
||||
* @param {InteractionReplyOptions} [options] Additional options for the reply
|
||||
* @param {string|APIMessage|InteractionReplyOptions} options The options for the reply
|
||||
* @returns {Promise<Message|Object>}
|
||||
*/
|
||||
followUp(content, options) {
|
||||
return this.webhook.send(content, options);
|
||||
followUp(options) {
|
||||
return this.webhook.send(options);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,8 +160,7 @@ class InteractionResponses {
|
||||
|
||||
/**
|
||||
* Updates the original message whose button was pressed
|
||||
* @param {string|APIMessage|MessageAdditions} content The content for the reply
|
||||
* @param {WebhookEditMessageOptions} [options] Additional options for the reply
|
||||
* @param {string|APIMessage|WebhookEditMessageOptions} options The options for the reply
|
||||
* @returns {Promise<void>}
|
||||
* @example
|
||||
* // Remove the buttons from the message
|
||||
@@ -168,9 +168,13 @@ class InteractionResponses {
|
||||
* .then(console.log)
|
||||
* .catch(console.error);
|
||||
*/
|
||||
async update(content, options) {
|
||||
async update(options) {
|
||||
if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
|
||||
const apiMessage = content instanceof APIMessage ? content : APIMessage.create(this, content, options);
|
||||
|
||||
let apiMessage;
|
||||
if (options instanceof APIMessage) apiMessage = options;
|
||||
else apiMessage = APIMessage.create(this, options);
|
||||
|
||||
const { data, files } = await apiMessage.resolveData().resolveFiles();
|
||||
|
||||
await this.client.api.interactions(this.id, this.token).callback.post({
|
||||
|
||||
Reference in New Issue
Block a user