Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(CommandInteraction): ephemeral followup messages #5618

Merged
merged 5 commits into from May 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/structures/CommandInteraction.js
Expand Up @@ -187,6 +187,24 @@ class CommandInteraction extends Interaction {
* @property {Role|Object} [role] The resolved role
*/

/**
* 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
* @returns {Promise<Message|Object>}
*/
async followUp(content, options) {
const apiMessage = content instanceof APIMessage ? content : APIMessage.create(this, content, options);
const { data, files } = await apiMessage.resolveData().resolveFiles();

const raw = await this.client.api.webhooks(this.applicationID, this.token).post({
data,
files,
});

return this.channel?.messages.add(raw) ?? raw;
}

/**
* Transforms an option received from the API.
* @param {Object} option The received option
Expand Down
4 changes: 4 additions & 0 deletions typings/index.d.ts
Expand Up @@ -425,6 +425,10 @@ declare module 'discord.js' {
): Promise<Message | RawMessage>;
public editReply(content: string, options?: WebhookEditMessageOptions): Promise<Message | RawMessage>;
public fetchReply(): Promise<Message | RawMessage>;
public followUp(
content: string | APIMessage | InteractionReplyOptions | MessageAdditions,
): Promise<Message | RawMessage>;
public followUp(content: string, options?: InteractionReplyOptions): Promise<Message | RawMessage>;
public reply(content: string | APIMessage | InteractionReplyOptions | MessageAdditions): Promise<void>;
public reply(content: string, options?: InteractionReplyOptions): Promise<void>;
private transformOption(option: object, resolved: object): CommandInteractionOption;
Expand Down