packages/discord.js/src/structures/interfaces/InteractionResponses.js
/**
   * Creates a reply to this interaction.
   * <info>Use the `fetchReply` option to get the bot's reply message.</info>
   * @param {string|MessagePayload|InteractionReplyOptions} options The options for the reply
   * @returns {Promise<Message|APIMessage|InteractionResponse>}
   * @example
   * // Reply to the interaction and fetch the response
   * interaction.reply({ content: 'Pong!', fetchReply: true })
   *   .then((message) => console.log(`Reply sent with content ${message.content}`))
   *   .catch(console.error);
   * @example
   * // Create an ephemeral reply with an embed
   * const embed = new EmbedBuilder().setDescription('Pong!');
   *
   * interaction.reply({ embeds: [embed], ephemeral: true })
   *   .then(() => console.log('Reply sent.'))
   *   .catch(console.error);
   */
Creates a reply to this interaction.


Creates a reply to this interaction .
async reply(options) {
    if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
    this.ephemeral = options.ephemeral ?? false;
    let messagePayload;
    if (options instanceof MessagePayload) messagePayload = options;
    else messagePayload = MessagePayload.create(this, options);
    const { body: data, files } = await messagePayload.resolveBody().resolveFiles();
    await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
      body: {
        type: InteractionResponseType.ChannelMessageWithSource,
        data,
      },
      files,
      auth: false,
    });
    this.replied = true;
    return options.fetchReply ? this.fetchReply() : new InteractionResponse(this);
  }
async reply ( options ) { if ( this . deferred || this . replied ) throw new Error ( 'INTERACTION_ALREADY_REPLIED' ) ; this . ephemeral = options . ephemeral ?? false ; let messagePayload ; if ( options instanceof MessagePayload ) messagePayload = options ; else messagePayload = MessagePayload . create ( this , options ) ; const { body : data , files } = await messagePayload . resolveBody ( ) . resolveFiles ( ) ; await this . client . rest . post ( Routes . interactionCallback ( this . id , this . token ) , { body : { type : InteractionResponseType . ChannelMessageWithSource , data , } , files , auth : false , } ) ; this . replied = true ; return options . fetchReply ? this . fetchReply ( ) : new InteractionResponse ( this ) ; }
Creates a reply to this interaction.
Creates a reply to this interaction .