Skip to content

Commit

Permalink
fix(InteractionResponses): check if ephemeral message flag is used (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sdanialraza authored Dec 4, 2023
1 parent 941642a commit 62e31cb
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const { isJSONEncodable } = require('@discordjs/util');
const { InteractionResponseType, MessageFlags, Routes, InteractionType } = require('discord-api-types/v10');
const { DiscordjsError, ErrorCodes } = require('../../errors');
const MessageFlagsBitField = require('../../util/MessageFlagsBitField');
const InteractionCollector = require('../InteractionCollector');
const InteractionResponse = require('../InteractionResponse');
const MessagePayload = require('../MessagePayload');
Expand Down Expand Up @@ -100,14 +101,15 @@ class InteractionResponses {
*/
async reply(options) {
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
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();

this.ephemeral = new MessageFlagsBitField(data.flags).has(MessageFlags.Ephemeral);

await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
body: {
type: InteractionResponseType.ChannelMessageWithSource,
Expand Down

0 comments on commit 62e31cb

Please sign in to comment.