Skip to content

Commit

Permalink
feat(InteractionResponse): add new methods (#9132)
Browse files Browse the repository at this point in the history
* feat(InteractionResponse): add new methods

* types: fix options parameter type

Co-authored-by: Jaworek <jaworekwiadomosci@gmail.com>

* Update packages/discord.js/src/structures/InteractionResponse.js

Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>

* Update packages/discord.js/src/structures/InteractionResponse.js

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>

* docs: add description for edit

---------

Co-authored-by: Jaworek <jaworekwiadomosci@gmail.com>
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
5 people committed Feb 17, 2023
1 parent da23cd5 commit dc9924f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/discord.js/src/structures/InteractionResponse.js
Expand Up @@ -70,6 +70,31 @@ class InteractionResponse {
interactionType: InteractionType.MessageComponent,
});
}

/**
* Fetches the response as a {@link Message} object.
* @returns {Promise<Message>}
*/
fetch() {
return this.interaction.fetchReply();
}

/**
* Deletes the response.
* @returns {Promise<void>}
*/
delete() {
return this.interaction.deleteReply();
}

/**
* Edits the response.
* @param {string|MessagePayload|WebhookMessageEditOptions} options The new options for the response.
* @returns {Promise<Message>}
*/
edit(options) {
return this.interaction.editReply(options);
}
}

// eslint-disable-next-line import/order
Expand Down
3 changes: 3 additions & 0 deletions packages/discord.js/typings/index.d.ts
Expand Up @@ -580,6 +580,9 @@ export class InteractionResponse<Cached extends boolean = boolean> {
public createMessageComponentCollector<T extends MessageComponentType>(
options?: MessageCollectorOptionsParams<T, Cached>,
): InteractionCollector<MappedInteractionTypes<Cached>[T]>;
public delete(): Promise<void>;
public edit(options: string | MessagePayload | WebhookMessageEditOptions): Promise<Message>;
public fetch(): Promise<Message>;
}

export abstract class BaseGuild extends Base {
Expand Down

2 comments on commit dc9924f

@vercel
Copy link

@vercel vercel bot commented on dc9924f Feb 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on dc9924f Feb 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.