fix(InteractionResponses): check if ephemeral message flag is used (#10021)

This commit is contained in:
Danial Raza
2023-12-04 21:16:26 +01:00
committed by GitHub
parent 941642ad2f
commit 62e31cb9ee

View File

@@ -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');
@@ -100,7 +101,6 @@ 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;
@@ -108,6 +108,8 @@ class InteractionResponses {
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,